ray-x / go.nvim

G'day Nvimer, Joyful Gopher: Discover the Feature-Rich Go Plugin for Neovim
MIT License
2.05k stars 123 forks source link

Error from InsertLeave Autocmd, codelens not supported #472

Closed garmr-ulfr closed 3 months ago

garmr-ulfr commented 3 months ago

On Neovim 0.10, this error is shown when exiting insert mode if multiple buffers, with LSP clients, are open and one doesn't support code lenses:

Error detected while processing InsertLeave Autocommands for "*.go":
method textDocument/codeLens is not supported by any of the servers registered for the current buffer

Neovim 0.10 changed vim.lsp.codelens.refresh to refresh all buffers. There's an open issue on the neovim github that has more information. go.nvim creates an autocmd that calls vim.lsp.codelens.refresh when exiting insert mode.

Passing { bufnr = 0 } to vim.lsp.codelens.refresh here fixed the issue for me. A warning will still be printed when running a code lens since vim.lsp.codelens.run calls vim.lsp.codelens.refresh without passing the buffer, however, it won't take away focus and the code lens still runs.