R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
127 stars 15 forks source link

Breaking changes introduced by the latest version of treesitter? #161

Open PMassicotte opened 4 days ago

PMassicotte commented 4 days ago

I am getting this error now:

Error executing lua callback: /usr/local/share/nvim/runtime/filetype.lua:35: Error executing lua: /usr/local/sha
re/nvim/runtime/filetype.lua:36: BufNewFile Autocommands for "*"..FileType Autocommands for "*": Vim(append):Err
or executing lua callback: /usr/local/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'                                                                      
        /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'                        
        /usr/local/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'fn'                            
        /usr/local/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-treesitte
r/lua/nvim-treesitter/configs.lua:132>                                                                          
        [C]: in function 'nvim_cmd'             

Introduced by this PR: https://github.com/nvim-treesitter/nvim-treesitter/commit/5373c90c55a33408604d17713edaa9560306b83d

jalvesaq commented 4 days ago

I updated my plugins and can replicate the bug. I removed R.nvim and cmp-r from my lazy.nvim config and the bug remains. So, the problem seems to be with nvim-treesitter.

jalvesaq commented 4 days ago

I deleted the nvim-treesitter directory (~/.local/share/nvim/lazy/nvim-treesitter). Everything was installed again by lazy.nvim and the error messages disappeared.

samtrek commented 4 days ago

Not fixed from on my own side

samtrek commented 4 days ago

better to remove some of the plugins that may be conflicting with nvim.tressitter, I remove hlargs.nvim and restarted nvim, everything is back to normal.

PMassicotte commented 4 days ago

https://github.com/r-lib/tree-sitter-r/issues/129#issuecomment-2195094260

samtrek commented 4 days ago

after the bug report I wrote was closed, I was referred to their pined comment this https://github.com/nvim-treesitter/nvim-treesitter/issues/3092 so you may check it out also to diagnose what the issue may be

PMassicotte commented 4 days ago

just using

        "nvim-treesitter/nvim-treesitter",
        commit = "173515a5d2be6e98c2996189f77ee5993620e2aa",

for now

jalvesaq commented 4 days ago

Did you try:

  1. Close Neovim.
  2. Delete all parsers:
    cd ~/.local/share/nvim/lazy
    rm -rf nvim-treesitter/
  3. Start Neovim again.

My nvim-treesitter config:

    {
        "nvim-treesitter/nvim-treesitter",
        tag = nil,
        branch = "master",
        run = ":TSUpdate",
        config = function ()
            require("nvim-treesitter.configs").setup({
                sync_install = true,
                ensure_installed = {
                    "bash",
                    "c",
                    "css",
                    "html",
                    "json",
                    "latex",
                    "lua",
                    "markdown",
                    "markdown_inline",
                    "python",
                    "query",
                    "r",
                    "rnoweb",
                    "vim",
                    "vimdoc",
                    "yaml",
                },
                highlight = {
                    enable = true,
                },
            })
            vim.o.foldmethod = "expr"
            vim.o.foldexpr = "nvim_treesitter#foldexpr()"
            vim.o.foldenable = false
        end
    },
PMassicotte commented 4 days ago

Yes. I tried it and get the same error. Looks like the bug is known per discussions going on in the PR. It works for you? Have you tried to re-update all plugins after re-instslling them?

jalvesaq commented 4 days ago

It fixed the bug here. I didn't uninstall any other plugins. I only deleted nvim-treesitter directory and let lazy.nvim install it again. I'm using the development version of Neovim.

typhooncamel commented 18 hours ago

I feel like I've been having some version of this issue as well. I initially fixed it, I thought, by deleting the nvim-treesitter directory, but now I'm getting errors again. When I delete the nvim-treesitter directory, and reinstall treesitter, I first get this error:

nvim-treesitter[r]: Error during tarball extraction.                                                                          
tar (child): tree-sitter-r.tar.gz: Cannot open: No such file or directory                                                     
tar (child): Error is not recoverable: exiting now                                                                            
tar: Child returned status 2                                                                                                  
tar: Error is not recoverable: exiting now

but once I close and reopen an R file, it goes back to the previous error (and then there's no syntax highlighting):

Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: /usr/share/nvim/runtime/filetype.lua:36: BufReadPost Autocommands for "*"..FileType Autocommands for "*": Vim(append):Error executing lua callback: /usr/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'
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'
        /usr/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'fn'
        /usr/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'
        /usr/share/nvim/runtime/filetype.lua:36: in function </usr/share/nvim/runtime/filetype.lua:35>
        [C]: in function 'pcall'
        vim/shared.lua: in function <vim/shared.lua:0>
        [C]: in function '_with'
        /usr/share/nvim/runtime/filetype.lua:35: in function </usr/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function '_with'
        /usr/share/nvim/runtime/filetype.lua:35: in function </usr/share/nvim/runtime/filetype.lua:10>

I should point out that everything was working absolutely fine until treesitter updated. Other file types also seem to be fine.

typhooncamel commented 14 hours ago

Apologies, it seems that my issue is with nvim-treesitter-textobjects, not R.nvim.

PMassicotte commented 14 hours ago

treesitter-r has been updated, and it breaks nvim-treesitter. Looks like they are working on it.

typhooncamel commented 14 hours ago

In my case, at least, disabling nvim-treesitter-textobjects means I no longer have error messages. When following the advice here , the result of :echo nvim_get_runtime_file('queries/<lang>/*.scm', v:true) includes subdirectories of that plugin that are not under nvim-treesitter. Unless I'm confusing things.

PMassicotte commented 13 hours ago

How do you disable textobjects?

typhooncamel commented 13 hours ago

I either comment out the dependency within the nvim-treesitter plugin setup, or I comment out the textobjects = { } table. Either means that the R file loads without errors, and with syntax highlighting.

PMassicotte commented 13 hours ago

Got it! The thing is I am using textobjecsts a lot!

typhooncamel commented 13 hours ago

Oh, I'd rather not have to disable it! I just don't know whether I should report it there too. Did disabling it fix it for you too?

PMassicotte commented 13 hours ago

yes it worked, but went back to an older commit of treesitter (see above) until they fix it. See https://github.com/nvim-treesitter/nvim-treesitter/pull/6774

typhooncamel commented 13 hours ago

Going back to that commit in treesitter for some reason still didn't work for me...

PMassicotte commented 13 hours ago

Are you using lazy? If so make sure you run :Lazy update.

typhooncamel commented 13 hours ago

Ah, yes, that did it. Thanks!