neovim: go inlay hints, codelens and stuff
This commit is contained in:
@@ -24,3 +24,11 @@ vim.api.nvim_create_autocmd("BufWinEnter", {
|
||||
vim.keymap.set("n", "<leader>p", ":Git push<CR>", opts)
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, {
|
||||
pattern = "*",
|
||||
group = group,
|
||||
callback = function()
|
||||
vim.lsp.codelens.refresh()
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -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, {})
|
||||
|
||||
@@ -57,6 +57,10 @@ local function on_attach(client, bufnr)
|
||||
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.server_capabilities.inlayHintProvider then
|
||||
vim.lsp.inlay_hint.enable(bufnr, true)
|
||||
end
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>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,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user