invalid node type error
joerdav opened this issue · comments
Apologies for the poor error report, but I'm getting the following error when opening templ files.
Please let me know if I can provide anything further:
treesitter/highlighter: Error executing lua: ...ed-0.9.4/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 1320 for language templ
I've had this issue when a query file (highlights.scm for example) tried to use a node that the templ grammar doesn't have.
Does it fail like this with any templ file ?
Are you using the latest templ parser ? (you can run :TSUpdateSync
)
Did it start to fail recently after an update or something ?
It does seem to be any file, for example it does it here: https://github.com/a-h/templ/blob/main/examples/blog/posts.templ
I'm up to date yes.
It started this week, I don't remember updating but it's entirely possible I did so without thinking.
I updated neovim in case that was the issue, am on 0.9.4
Can you paste the contents of these files:
$HOME/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/templ/highlights.scm
$HOME/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/templ/injections.scm
hm maybe you won't have this exact path if you don't use packer, but you should have these files somewhere.
Manage to find them, I'm using lazy:
; inherits: go
(component_declaration
name: (component_identifier) @function)
[
(tag_start)
(tag_end)
(self_closing_tag)
(style_element)
] @tag
(attribute
name: (attribute_name) @tag.attribute)
(attribute
value: (quoted_attribute_value) @string)
[
(element_text)
(style_element_text)
] @string.special
(css_identifier) @function
(css_property
name: (css_property_name) @property)
(css_property
value: (css_property_value) @string)
[
(expression)
(dynamic_class_attribute_value)
] @function.method
(component_import
name: (component_identifier) @function)
(component_render) @function.call
(element_comment) @comment @spell
"@" @operator
[
"templ"
"css"
"script"
] @keyword
; inherits: go
((element_comment) @injection.content
(#set! injection.language "comment"))
((script_block_text) @injection.content
(#set! injection.language "javascript"))
((script_element_text) @injection.content
(#set! injection.language "javascript"))
((style_element_text) @injection.content
(#set! injection.language "css"))
Thanks, they're the same as mine. I have no idea what's happening, it works fine for me.
What does :checkhealth
say ?
Do you maybe have other .scm
files in your queries/templ
directory ?
Oh interesting, I'm getting this for other grammars too:
==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()
Installation ~
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `node` found v20.9.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: Apple clang version 12.0.0 (clang-1200.0.32.29)
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
OS Info:
{
machine = "x86_64",
release = "22.6.0",
sysname = "Darwin",
version = "Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:56 PDT 2023; root:xnu-8796.141.3~6/RELEASE_X86_64"
} ~
Parser/Features H L F I J
- c ✓ ✓ ✓ ✓ ✓
- gitcommit ✓ . . . ✓
- go ✓ ✓ ✓ ✓ ✓
- javascript ✓ ✓ ✓ ✓ ✓
- json ✓ ✓ ✓ ✓ .
- lua ✓ ✓ ✓ ✓ ✓
- norg ✓ . ✓ . ✓
- query ✓ ✓ ✓ ✓ ✓
- rust x ✓ ✓ ✓ ✓
- templ x . . . ✓
- tsx ✓ ✓ ✓ ✓ ✓
- typescript ✓ ✓ ✓ ✓ ✓
- vim ✓ ✓ ✓ . ✓
- vimdoc x . . . ✓
Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang} ~
The following errors have been detected: ~
- ERROR rust(highlights): ...ed-0.9.4/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 662 for language rust
rust(highlights) is concatenated from the following files:
| [ERROR]:"/Users/joe.davidson/.local/share/nvim/lazy/nvim-treesitter/queries/rust/highlights.scm", failed to load: ...ed-0.9.4/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 662 for language rust
- ERROR templ(highlights): ...ed-0.9.4/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 1320 for language templ
templ(highlights) is concatenated from the following files:
| [ERROR]:"/Users/joe.davidson/.local/share/nvim/lazy/nvim-treesitter/queries/go/highlights.scm", failed to load: ...ed-0.9.4/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 1320 for language templ
| [OK]:"/Users/joe.davidson/.local/share/nvim/lazy/nvim-treesitter/queries/templ/highlights.scm"
- ERROR vimdoc(highlights): ...ed-0.9.4/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 746 for language vimdoc
vimdoc(highlights) is concatenated from the following files:
| [ERROR]:"/Users/joe.davidson/.local/share/nvim/lazy/nvim-treesitter/queries/vimdoc/highlights.scm", failed to load: ...ed-0.9.4/share/nvim/runtime/lua/vim/treesitter/query.lua:259: query: invalid node type at position 746 for language vimdoc
I managed to resolve it by following this issue:
nvim-treesitter/nvim-treesitter#3092
Nothing to do with your repo, sorry!
No worries!