neovim: enable codelens if lsp client supports it

This commit is contained in:
2026-03-20 17:06:42 +03:00
parent 63fb1f1222
commit aa2ffbe839
2 changed files with 8 additions and 0 deletions

View File

@@ -54,6 +54,11 @@ vim.api.nvim_create_autocmd("LspAttach", {
if not vim.lsp.buf.range_code_action == nil then
vim.keymap.set("v", "<leader>.", vim.lsp.buf.range_code_action, opts)
end
if client and client:supports_method("textDocument/codeLens") then
vim.lsp.codelens.enable(true, { bufnr = ev.buf })
vim.keymap.set("n", "<leader>c", vim.lsp.codelens.run, opts)
end
end,
})

View File

@@ -7,6 +7,9 @@ vim.lsp.config.gopls = {
root_markers = root_markers,
settings = {
gopls = {
codelenses = {
test = true,
},
linksInHover = true,
usePlaceholders = false, -- just to ensure it's off, incase in the future go team decides to toggle it on by default
completeUnimported = true,