nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects
Broken rust query
Nobody has claimed this yet.
- Dominant language
- Tree-sitter Query
- Stars
- 2.8k
- Forks
- 271
- Avg merge
- 8d 8h
- Merged PRs (30d)
- 1
Description
Describe the bug
Hey!
I'm getting an error when opening rust files.
Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: /usr/local/share/nvim/runtime/filetype.lua:24: Error executing lua: /usr/local/share/nvim/runtime/filetype.lua:25:
BufReadPost Autocommands for "*"..FileType Autocommands for "*": Vim(append):Error executing lua callback: /usr/local/share/nvim/runtime/lua/vi
m/treesitter/query.lua:259: query: invalid structure at position 5163 for language rust
stack traceback:
[C]: in function '_ts_parse_query'
/usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:259: in function 'get_query'
...r-textobjects/lua/nvim-treesitter/textobjects/shared.lua:99: in function 'available_textobjects'
...r-textobjects/lua/nvim-treesitter/textobjects/select.lua:172: in function 'attach'
...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:509: in function 'attach_module'
...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:532: in function 'reattach_module'
...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function <...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lu
a:132>
[C]: in function 'nvim_cmd'
/usr/local/share/nvim/runtime/filetype.lua:25: in function </usr/local/share/nvim/runtime/filetype.lua:24>
[C]: in function 'nvim_buf_call'
/usr/local/share/nvim/runtime/filetype.lua:24: in function </usr/local/share/nvim/runtime/filetype.lua:10>
stack traceback:
[C]: in function 'nvim_cmd'
/usr/local/share/nvim/runtime/filetype.lua:25: in function </usr/local/share/nvim/runtime/filetype.lua:24>
[C]: in function 'nvim_buf_call'
/usr/local/share/nvim/runtime/filetype.lua:24: in function </usr/local/share/nvim/runtime/filetype.lua:10>
stack traceback:
[C]: in function 'nvim_buf_call'
/usr/local/share/nvim/runtime/filetype.lua:24: in function </usr/local/share/nvim/runtime/filetype.lua:10>
Press ENTER or type command to continue
As far as I understand this tells me that some query is wrong. I tried to open queries for rust and saw that one of them is highlighted for some reason.
((token_tree
"," @_start . (_) @parameter.inner)
(#make-range! "parameter.outer" @_start @parameter.inner))
After commenting it out I don't see an error.
To Reproduce
Steps to reproduce the behavior:
- Open any rust file
- See error
Expected behavior
No error
Output of :checkhealth nvim-treesitter
==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()
Installation ~
- OK
tree-sitter found 0.20.7 (parser generator, only needed for :TSInstallFromGrammar)
- OK
node found v18.2.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 15.0.0 (clang-1500.0.40.1)
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
OS Info:
{
machine = "arm64",
release = "22.6.0",
sysname = "Darwin",
version = "Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000"
} ~
Parser/Features H L F I J
- bash ✓ ✓ ✓ . ✓
- c ✓ ✓ ✓ ✓ ✓
- comment ✓ . . . .
- fennel ✓ ✓ ✓ . ✓
- go ✓ ✓ ✓ ✓ ✓
- grpcnvim ✓ . . . ✓
- hocon ✓ . . . ✓
- http ✓ . . . ✓
- javascript ✓ ✓ ✓ ✓ ✓
- json ✓ ✓ ✓ ✓ .
- lua ✓ ✓ ✓ ✓ ✓
- markdown ✓ . ✓ ✓ ✓
- org ✓ . ✓ . ✓
- proto ✓ . ✓ . .
- python ✓ ✓ ✓ ✓ ✓
- query ✓ ✓ ✓ ✓ ✓
- rust ✓ ✓ ✓ ✓ ✓
- scala ✓ ✓ ✓ . ✓
- tlaplus ✓ ✓ ✓ . ✓
- toml ✓ ✓ ✓ ✓ ✓
- typescript ✓ ✓ ✓ ✓ ✓
- vim ✓ ✓ ✓ . ✓
- vimdoc ✓ . . . ✓
- yaml ✓ ✓ ✓ ✓ ✓
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} ~
Output of nvim --version
NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1692716794
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/share/nvim"
Run :checkhealth for more info
Additional context
Didn't manage to fix this query myself, don't really understand what it does. But will contribute a fix if someone willing to help.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Rust textobject query containing the token_tree pattern shown in the issue, then reproduce the failure by opening a Rust file with the reported Neovim and parser versions. Compare the query syntax with the Tree-sitter query requirements and verify that opening a Rust file no longer reports an invalid structure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100