nvim-treesitter / nvim-treesitter

Nvim Treesitter configurations and abstraction layer
Apache License 2.0
10.71k stars 896 forks source link

after updating nvim-treesitter, .R files yield nvim-treesitter lua errors #7001

Closed Tal500 closed 2 months ago

Tal500 commented 2 months ago

Describe the bug

after updating nvim-treesitter, .R files yield nvim-treesitter lua errors:


[Neo-tree ERROR] Error opening file: vim/_editor.lua:0: nvim_exec2()..BufReadPost Autocommands for "*": Vim(append):Error executing lua callback: .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35: Error executing lua: .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:36: nvim_exec2()..BufReadPost Autocommands for "*"..FileType Autocommands for "*": Vim(append):Error executing lua callback: ...vim-0.10/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 12:2. Invalid node type "if":
(if
 ^

stack traceback:
    [C]: in function '_ts_parse_query'
    ...vim-0.10/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'
    ...neovim-0.10/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'fn'
    ...neovim-0.10/share/nvim/runtime/lua/vim/func/_memoize.lua:58: 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:173: in function 'attach'
    ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:509: in function 'attach_module'
    ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:532: in function 'reattach_module'
    ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function <...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:132>
    [C]: in function 'nvim_cmd'
    .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:36: in function <.../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35>
    [C]: in function 'nvim_buf_call'
    .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35: in function <.../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:10>
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function <vim/_editor.lua:0>
    [C]: in function 'pcall'
    ...hare/nvim/lazy/neo-tree.nvim/lua/neo-tree/utils/init.lua:741: in function 'open_file'
    ...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:733: in function 'open'
    ...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:755: in function 'open_with_cmd'
    ...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:764: in function 'open'
    ...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:184: in function <...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:183>
stack traceback:
    [C]: in function 'nvim_cmd'
    .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:36: in function <.../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35>
    [C]: in function 'nvim_buf_call'
    .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35: in function <.../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:10>
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function <vim/_editor.lua:0>
    [C]: in function 'pcall'
    ...hare/nvim/lazy/neo-tree.nvim/lua/neo-tree/utils/init.lua:741: in function 'open_file'
    ...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:733: in function 'open'
    ...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:755: in function 'open_with_cmd'
    ...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:764: in function 'open'
    ...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:184: in function <...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:183>
stack traceback:
    [C]: in function 'nvim_buf_call'
    .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35: in function <.../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:10>
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function <vim/_editor.lua:0>
    [C]: in function 'pcall'
    ...hare/nvim/lazy/neo-tree.nvim/lua/neo-tree/utils/init.lua:741: in function 'open_file'
    ...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:733: in function 'open'
    ...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:755: in function 'open_with_cmd'
    ...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:764: in function 'open'
    ...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:184: in function <...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:183>

To Reproduce

Update nvim-treesitter to the latest version, and then:

:TSUninstall r
:TSInstall r
:e example.R (this is a new file)

Expected behavior

No response

Output of :checkhealth nvim-treesitter

3   nvim-treesitter: require("nvim-treesitter.health").check()
   4
   5   Installation
   6   - WARNING tree-sitter executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
   7   - OK node found v8.10.0 (only needed for :TSInstallFromGrammar)
   8   - OK git executable found.
   9   - OK cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  10     Version: cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
  11   - OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
  12
  13   OS Info:
  14   {
  15     machine = "x86_64",
  16     release = "5.4.0-150-generic",
  17     sysname = "Linux",
  18     version = "#167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023"
  19   }
  20
  21   Parser/Features         H L F I J
  22     - bash                ✓ ✓ ✓ . ✓
  23     - c                   ✓ ✓ ✓ ✓ ✓
  24     - lua                 ✓ ✓ ✓ ✓ ✓
  25     - luap                ✓ . . . .
  26     - make                ✓ . ✓ . ✓
  27     - markdown            ✓ . ✓ ✓ ✓
  28     - markdown_inline     ✓ . . . ✓
  29     - python              ✓ ✓ ✓ ✓ ✓
  30     - query               ✓ ✓ ✓ ✓ ✓
  31     - r                   ✓ ✓ . ✓ ✓
  32     - tmux                ✓ . . . ✓
  33     - vim                 ✓ ✓ ✓ . ✓
  34     - vimdoc              ✓ . . . ✓
  35     - yaml                ✓ ✓ ✓ ✓ ✓
  36
  37     Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
  38            +) multiple parsers found, only one will be used
  39            x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.10.0
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Additional context

No response

clason commented 2 months ago

Please check your other plugins; the error message refers not to nvim-treesitter.

Tal500 commented 2 months ago

Please check your other plugins; the error message refers not to nvim-treesitter.

But it is! The previous error message happen when I was opening the file via neotree. Here is the error when I open it directly with :e exmple.R, which doesn't leave the neotree trails:

:e example.R
Error detected while processing BufNewFile Autocommands for "*":
Error executing lua callback: .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35: Error executing lua: .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:36: BufNewFile Autocommands for "*"..F
ileType Autocommands for "*": Vim(append):Error executing lua callback: ...vim-0.10/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 12:2. Invalid node type "if":
(if
 ^

stack traceback:
        [C]: in function '_ts_parse_query'
        ...vim-0.10/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'
        ...neovim-0.10/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'fn'
        ...neovim-0.10/share/nvim/runtime/lua/vim/func/_memoize.lua:58: 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:173: in function 'attach'
        ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:509: in function 'attach_module'
        ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:532: in function 'reattach_module'
        ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function <...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:132>
        [C]: in function 'nvim_cmd'
        .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:36: in function <.../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35>
        [C]: in function 'nvim_buf_call'
        .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35: in function <.../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_cmd'
        .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:36: in function <.../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35>
        [C]: in function 'nvim_buf_call'
        .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35: in function <.../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_buf_call'
        .../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:35: in function <.../local/other/neovim-0.10/share/nvim/runtime/filetype.lua:10>
Tal500 commented 2 months ago

Please check your other plugins; the error message refers not to nvim-treesitter.

OK, you were right. I uninstalled nvim-treesitter-textobjects plugin and now it works.... That were hard to find in the logs, I really thought it's all just nvim-treesitter and plain nvim

Tal500 commented 2 months ago

Please check your other plugins; the error message refers not to nvim-treesitter.

OK, you were right. I uninstalled nvim-treesitter-textobjects plugin and now it works.... That were hard to find in the logs, I really thought it's all just nvim-treesitter and plain nvim

@clason can you please migrate this issue and reopen it in the project nvim-treesitter-textobjects instead?

clason commented 2 months ago

I can not; it's better to open a fresh issue using their issue template, with the fresh knowledge that their queries are outdated. (Or, better yet, try opening a PR!)

Tal500 commented 2 months ago

Verified - it is fixed by the PR https://github.com/nvim-treesitter/nvim-treesitter-textobjects/pull/645