feat(nvim): enable lsp inlay hints
This commit is contained in:
parent
c9ea7179a0
commit
33b51e5dea
2 changed files with 75 additions and 64 deletions
|
@ -38,6 +38,7 @@ require('lspconfig').gopls.setup {
|
||||||
allExperiments = true,
|
allExperiments = true,
|
||||||
semanticTokens = true,
|
semanticTokens = true,
|
||||||
analyses = {
|
analyses = {
|
||||||
|
appends = true,
|
||||||
assign = true,
|
assign = true,
|
||||||
atomic = true,
|
atomic = true,
|
||||||
atomicalign = true,
|
atomicalign = true,
|
||||||
|
@ -75,10 +76,13 @@ require('lspconfig').gopls.setup {
|
||||||
generate = true,
|
generate = true,
|
||||||
gc_details = true,
|
gc_details = true,
|
||||||
run_govulncheck = true,
|
run_govulncheck = true,
|
||||||
|
tidy = true,
|
||||||
|
upgrade_dependency = true,
|
||||||
},
|
},
|
||||||
hints = {
|
hints = {
|
||||||
assignVariableTypes = true,
|
assignVariableTypes = true,
|
||||||
compositeLiteralFields = true,
|
compositeLiteralFields = true,
|
||||||
|
compositeLiteralTypes = true,
|
||||||
constantValues = true,
|
constantValues = true,
|
||||||
functionTypeParameters = true,
|
functionTypeParameters = true,
|
||||||
parameterNames = true,
|
parameterNames = true,
|
||||||
|
@ -87,5 +91,3 @@ require('lspconfig').gopls.setup {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Change local setting to separate 3rd-party and local imports with go.mod prefix
|
|
||||||
|
|
|
@ -41,6 +41,12 @@ vim.keymap.set('n', '<space>dl', '<cmd>lua vim.diagnostic.setloclist()<CR>', opt
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
|
-- Enable inlay hints
|
||||||
|
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||||
|
if client.server_capabilities.inlayHintProvider then
|
||||||
|
vim.lsp.inlay_hint.enable(true, { bufnr = ev.buf })
|
||||||
|
end
|
||||||
|
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
||||||
|
|
||||||
|
@ -57,6 +63,9 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
vim.keymap.set('n', '<space>wl', function()
|
vim.keymap.set('n', '<space>wl', function()
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
end, opts)
|
end, opts)
|
||||||
|
vim.keymap.set('n', '<space>i', function()
|
||||||
|
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
|
||||||
|
end, opts)
|
||||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
||||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||||
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
||||||
|
|
Loading…
Add table
Reference in a new issue