yioneko / nvim-vtsls

181 stars 4 forks source link

Errors on Neovim nightly #5

Closed kristijanhusak closed 8 months ago

kristijanhusak commented 8 months ago

Hi,

Today I started getting some errors with nightly Neovim.

With this version: NVIM v0.10.0-dev-2341+g929e1b7f1

I started getting this error:

Error detected while processing LspAttach Autocommands for "*":                                                                                                                                                                                                                                                                                                                               
Error executing lua callback: ...jan/.local/share/nvim/lazy/nvim-vtsls/lua/vtsls/init.lua:58: attempt to index field 'commands' (a nil value)                                                                                                                                                                                                                                                 
stack traceback:                                                                                                                                                                                                                                                                                                                                                                              
        ...jan/.local/share/nvim/lazy/nvim-vtsls/lua/vtsls/init.lua:58: in function '_on_attach'                                                                                                                                                                                                                                                                                              
        ...stijan/.local/share/nvim/lazy/nvim-vtsls/plugin/init.lua:7: in function <...stijan/.local/share/nvim/lazy/nvim-vtsls/plugin/init.lua:5>                                                                                                                                                                                                                                            
        [C]: in function 'nvim_exec_autocmds'                                                                                                                                                                                                                                                                                                                                                 
        ...y/nvim-linux64/share/nvim/runtime/lua/vim/lsp/client.lua:757: in function 'on_attach'                                                                                                                                                                                                                                                                                              
        .../nightly/nvim-linux64/share/nvim/runtime/lua/vim/lsp.lua:481: in function <.../nightly/nvim-linux64/share/nvim/runtime/lua/vim/lsp.lua:471>                                                                                                                                                                                                                                        
        .../nightly/nvim-linux64/share/nvim/runtime/lua/vim/lsp.lua:548: in function <.../nightly/nvim-linux64/share/nvim/runtime/lua/vim/lsp.lua:545>                                                                                                                                                                                                                                        
        [C]: in function 'pcall'                                                                                                                                                                                                                                                                                                                                                              
        ...y/nvim-linux64/share/nvim/runtime/lua/vim/lsp/client.lua:432: in function ''                                                                                                                                                                                                                                                                                                       
        vim/_editor.lua: in function <vim/_editor.lua:0>  

When I switched to (currently) last commit on Neovim https://github.com/neovim/neovim/commit/0185152802d4a84258a9a04c1d86a7e27d37d721, I started getting this:

LSP[vtsls]: Error ON_ATTACH_ERROR: "...al/share/nvim/lazy/nvim-lspconfig/lua/lspconfig/util.lua:71: bad argument #1 to 'pairs' (table expected, got function)"

First one is probably related to this one https://github.com/neovim/neovim/commit/597ecf751603cde2d5f58021d503ae20a12eb2f2, but I'm not sure why the 2nd error happens.

yioneko commented 8 months ago

Related: https://github.com/neovim/nvim-lspconfig/issues/3009, I'll look for some workarounds for this error.

yioneko commented 8 months ago

Also related: it seems that direct access to client.commands will be deprecated on upstream, and it is forced to define them on setup of the server. So in the future we may require user to call our wrapped setup method instead of the one from lspconfig or vim.lsp.start_client.

yioneko commented 8 months ago

Fixed in latest nightly: https://github.com/neovim/neovim/commit/9f8c96240dc0318bd92a646966917e8fe0641144

kafendt commented 4 months ago

Sorry for reopening this.

LSP[vtsls]: Error ON_ATTACH_ERROR: "...al/share/nvim/lazy/nvim-lspconfig/lua/lspconfig/util.lua:71: bad argument #1 to 'pairs' (table expected, got function)"

I am getting the same error on neovim 0.10.0 I upgraded to neovim-nightly-0.11.0 but am still getting that error.

It read like it should be could be fixed in nightly? Did I get that wrong? Is there something I can do to get around that error? :slightly_smiling_face:

yioneko commented 4 months ago

@kafendt Could you provide your lsp setup? If you define custom commands through lspconfig commands field, then the error could happen.

kafendt commented 4 months ago

I am actually using https://astronvim.com/ so I didn't actually do to much configuration myself. I only installed vtsls through Mason and then tried to add this plugin through the config:

    {
      "yioneko/nvim-vtsls",
      event = "VeryLazy",
    }

I am on v3 of Astronvim still so I might actually just upgrade to v4 first and check again. I will come back to you once I tried that.

CEOehis commented 4 months ago

I just updated my neovim from 0.9.5 to 0.10.0 and I started having this issue.

yioneko commented 4 months ago

@CEOehis Could you try the branch fix-command-conflict to see if the problem still exists?

CEOehis commented 4 months ago

@yioneko I no longer have this error when using the fix-command-conflict branch.