2021-10-02 23:36:29 +00:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
-- - LSP servers common config -
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
M.on_attach = function(client, bufnr)
|
2022-04-27 14:07:16 +00:00
|
|
|
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
|
2021-10-02 23:36:29 +00:00
|
|
|
|
2021-12-02 15:12:10 +00:00
|
|
|
-- Lsp keymaps
|
2022-04-27 14:07:16 +00:00
|
|
|
local opts = {buffer = bufnr}
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"<C-]>",
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.definition()
|
|
|
|
end,
|
|
|
|
opts
|
|
|
|
)
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"gD",
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.declaration()
|
|
|
|
end,
|
|
|
|
opts
|
|
|
|
)
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"gr",
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.references()
|
|
|
|
end,
|
|
|
|
opts
|
|
|
|
)
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"gi",
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.implementation()
|
|
|
|
end,
|
|
|
|
opts
|
|
|
|
)
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"<Leader>rn",
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.rename()
|
|
|
|
end,
|
|
|
|
opts
|
|
|
|
)
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"<C-k>",
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.signature_help()
|
|
|
|
end,
|
|
|
|
opts
|
|
|
|
)
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"K",
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.hover()
|
|
|
|
end,
|
|
|
|
opts
|
|
|
|
)
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"<A-CR>",
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.code_action()
|
|
|
|
end,
|
|
|
|
opts
|
|
|
|
)
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"<Leader>ac",
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.code_action()
|
|
|
|
end,
|
|
|
|
opts
|
|
|
|
)
|
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"<Leader>a",
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.code_action_range()
|
|
|
|
end,
|
|
|
|
opts
|
|
|
|
)
|
2021-10-02 23:36:29 +00:00
|
|
|
end
|
|
|
|
|
2021-12-02 15:12:10 +00:00
|
|
|
return M
|