diff --git a/lua/go/codelens.lua b/lua/go/codelens.lua index a88cc44..f0ad559 100644 --- a/lua/go/codelens.lua +++ b/lua/go/codelens.lua @@ -35,11 +35,6 @@ function M.refresh() if _GO_NVIM_CFG.lsp_codelens == false then return end - if not utils.check_capabilities("code_lens") then - -- _GO_NVIM_CFG.lsp_codelens = false - log("code lens not supported by your gopls") - return - end vim.lsp.codelens.refresh() end diff --git a/lua/go/lsp.lua b/lua/go/lsp.lua index 9b823e4..10da984 100644 --- a/lua/go/lsp.lua +++ b/lua/go/lsp.lua @@ -5,7 +5,6 @@ local diagnostic_map = function(bufnr) local opts = { noremap = true, silent = true } api.nvim_buf_set_keymap(bufnr, "n", "]O", ":lua vim.lsp.diagnostic.set_loclist()", opts) end - local on_attach = function(client, bufnr) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) @@ -24,6 +23,10 @@ local on_attach = function(client, bufnr) client.resolved_capabilities.document_formatting = false end + codelens_enabled = client.resolved_capabilities["code_lens"] + if not codelens_enabled and _GO_NVIM_CFG.lsp_codelens then + vim.notify("failed to enable codelens", vim.lsp.log_levels.WARN) + end if _GO_NVIM_CFG.lsp_keymaps == true then buf_set_keymap("n", "gD", ":lua vim.lsp.buf.formatting()", opts) buf_set_keymap("n", "gD", "lua vim.lsp.buf.declaration()", opts) diff --git a/lua/go/utils.lua b/lua/go/utils.lua index 6df5764..524e5f7 100644 --- a/lua/go/utils.lua +++ b/lua/go/utils.lua @@ -357,6 +357,7 @@ function util.load_plugin(name, modulename) return plugin end +-- deprecated function util.check_capabilities(feature, client_id) local clients = vim.lsp.buf_get_clients(client_id or 0)