ShinKage / idris2-nvim

Simple configuration and extra tools for NVIM + LSP + Idris2
MIT License
46 stars 8 forks source link

Don't assume all LSP clients provide "textDocument/semanticTokens/full" #17

Open gekoke opened 2 years ago

gekoke commented 2 years ago

When using https://github.com/zbirenbaum/copilot.lua, GitHub Copilot runs as an LSP client in the buffer alongside other LSP providers (e.g. idris2-lsp), and doesn't provide the functionality this plugin expects. Is there perhaps a way to handle such errors gracefully, or to not request functionality from the wrong LSP clients in the first place?

What happens whenever the plugin runs alongside any such clients:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp.lua:1018: not found: "textDocument/semanticTokens/full" request handler for client "copilot".
stack traceback:
        [C]: in function 'error'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1018: in function 'request'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1485: in function 'fn'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:164: in function 'for_each_buffer_client'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1484: in function 'buf_request'
        ...te/pack/packer/start/idris2-nvim/lua/idris2/semantic.lua:8: in function 'request'
        ...m/site/pack/packer/start/idris2-nvim/lua/idris2/init.lua:18: in function '_on_attach'
        ...ck/packer/start/nvim-lspconfig/lua/lspconfig/configs.lua:273: in function '_setup_buffer'
        ...ck/packer/start/nvim-lspconfig/lua/lspconfig/configs.lua:183: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

The relevant code: https://github.com/ShinKage/idris2-nvim/blob/fdc47ba6f0e9d15c2754ee98b6455acad0fa7c95/lua/idris2/semantic.lua#L5-L9

ShinKage commented 2 years ago

I will work on it during the May IDM. I already have an idea on how to solve the issue, but I also want to do some refactoring.

ShinKage commented 2 years ago

@gekoke Can you check if #18 solves the issue?

gekoke commented 2 years ago

It doesn't seem like it - I'm still getting the same error running 46e69faf1287cd78f97eeb4bda4686c58db5b778

LSP[idris2_lsp]: Error SERVER_REQUEST_HANDLER_ERROR: '/usr/share/nvim/runtime/lua/vim/lsp.lua:1018: not fo
und: "textDocument/semanticTokens/full" request handler for client "copilot".'