diff --git a/neovim/.config/nvim/after/plugin/autocmds.lua b/neovim/.config/nvim/after/plugin/autocmds.lua index a3176d3..3af9153 100644 --- a/neovim/.config/nvim/after/plugin/autocmds.lua +++ b/neovim/.config/nvim/after/plugin/autocmds.lua @@ -24,3 +24,11 @@ vim.api.nvim_create_autocmd("BufWinEnter", { vim.keymap.set("n", "p", ":Git push", opts) end, }) + +vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, { + pattern = "*", + group = group, + callback = function() + vim.lsp.codelens.refresh() + end, +}) diff --git a/neovim/.config/nvim/after/plugin/commands.lua b/neovim/.config/nvim/after/plugin/commands.lua index ae77a89..f5657cb 100644 --- a/neovim/.config/nvim/after/plugin/commands.lua +++ b/neovim/.config/nvim/after/plugin/commands.lua @@ -8,3 +8,30 @@ vim.api.nvim_create_user_command("FormattingEnable", formatting.enable, {}) vim.api.nvim_create_user_command("FormattingDisable", formatting.disable, {}) vim.api.nvim_create_user_command("FormattingToggle", formatting.toggle, {}) vim.api.nvim_create_user_command("FormattingStatus", formatting.status, {}) + +vim.api.nvim_create_user_command("GoCommands", function() + local clients = vim.lsp.get_active_clients() + for _, client in ipairs(clients) do + if client.name == "gopls" then + print(vim.inspect(client.server_capabilities.executeCommandProvider.commands)) + end + end +end, {}) + +vim.api.nvim_create_user_command("CodelensList", function() + vim.lsp.codelens.refresh() + + local codelens = vim.lsp.codelens.get() + vim.ui.select(codelens, { + prompt = "What codelens to run:", + format_item = function(item) + return item.command.title + end, + }, function(choice) + vim.lsp.buf.execute_command(choice.command) + end) +end, {}) + +vim.api.nvim_create_user_command("CodelensRefresh", function() + vim.lsp.codelens.refresh() +end, {}) diff --git a/neovim/.config/nvim/after/plugin/lsp.lua b/neovim/.config/nvim/after/plugin/lsp.lua index 07c0cc5..84ba482 100644 --- a/neovim/.config/nvim/after/plugin/lsp.lua +++ b/neovim/.config/nvim/after/plugin/lsp.lua @@ -57,6 +57,10 @@ local function on_attach(client, bufnr) if not vim.lsp.buf.range_code_action == nil then vim.keymap.set("v", ".", vim.lsp.buf.range_code_action, opts) end + + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(bufnr, true) + end end vim.keymap.set("n", "ee", function() @@ -84,21 +88,13 @@ for _, server in ipairs(servers) do opts.filetypes = { "html", "css", "scss", "javascripreact", "typescriptreact", "astro" } end - if server == "tsserver" then + if server == "gopls" then + -- https://github.com/golang/tools/blob/master/gopls/doc/settings.md opts.settings = { - tsserver = { - experimental = { - enableProjectDiagnostics = true, - }, - javascript = { - format = { - enable = false, - }, - }, - typescript = { - format = { - enable = false, - }, + gopls = { + linksInHover = true, + hints = { + constantValues = true, }, }, }