nvim-treesitter-textobjects icon indicating copy to clipboard operation
nvim-treesitter-textobjects copied to clipboard

Broken rust query

Open antosha417 opened this issue 1 year ago • 4 comments

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))
Screenshot 2023-10-25 at 18 12 01

After commenting it out I don't see an error.

To Reproduce Steps to reproduce the behavior:

  1. Open any rust file
  2. 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.

antosha417 avatar Oct 25 '23 15:10 antosha417

same, getting this after update

alloc33 avatar Nov 04 '23 02:11 alloc33

This issue happens after a7a9ba714bcc31f5453a60d48598186b6487b75c commit. Using previous commit - 73e44f43c70289c70195b5e7bc6a077ceffddda4.

alloc33 avatar Nov 04 '23 02:11 alloc33

I also ran into the same problem. You can avoid the error by commenting out keymaps.

      textobjects = {
        select = {
          keymaps = {
            -- ["af"] = "@function.outer",
            -- ["if"] = "@function.inner",
          },

commit hash e69a504baf2951d52e1f1fbb05145d43f236cbf1

ktrysmt avatar Nov 06 '23 04:11 ktrysmt

This issue happens after a7a9ba714bcc31f5453a60d48598186b6487b75c commit. Using previous commit - 73e44f43c70289c70195b5e7bc6a077ceffddda4.

If anyone is using Lazy for package management, just add the commit hash while adding the plugin and sync.

  {
    'nvim-treesitter/nvim-treesitter-textobjects',
    commit = "73e44f43c70289c70195b5e7bc6a077ceffddda4",
    config = ...
  }

Mitigates the issue for now, until an upstream patch is available.

ananyo141 avatar Nov 29 '23 20:11 ananyo141