2022-06-16 18:30:25 +02:00
|
|
|
local opts = {}
|
2021-12-14 07:32:00 +01:00
|
|
|
|
2021-12-15 23:23:07 +01:00
|
|
|
local on_attach = function()
|
|
|
|
local function set_keymap(...) vim.api.nvim_set_keymap(...) end
|
|
|
|
local function set_option(...) vim.api.nvim_set_option(...) end
|
2021-12-14 07:32:00 +01:00
|
|
|
|
|
|
|
-- Enable completion triggered by <c-x><c-o>
|
2021-12-15 23:23:07 +01:00
|
|
|
set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
2021-12-14 07:32:00 +01:00
|
|
|
|
|
|
|
-- Mappings.
|
|
|
|
local opts = { noremap=true, silent=true }
|
|
|
|
|
|
|
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
2022-10-03 17:12:26 +02:00
|
|
|
set_keymap('', '<leader>lc', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>lf', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>lh', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>li', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>ls', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>lwa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>lwr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>lw', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
|
|
|
set_keymap('', '<leader>lt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>lr', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>la', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>le', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>lo', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>ln', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>lp', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
|
|
|
set_keymap('', '<leader>lm', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
2021-12-14 07:32:00 +01:00
|
|
|
end
|
2022-08-19 17:24:29 +02:00
|
|
|
require("mason-lspconfig").setup_handlers({
|
|
|
|
function(server_name)
|
|
|
|
require("lspconfig")[server_name].setup{}
|
|
|
|
on_attach()
|
|
|
|
end,
|
|
|
|
["rust_analyzer"] = function()
|
|
|
|
require('rust-tools-setup')
|
|
|
|
on_attach()
|
|
|
|
end,
|
|
|
|
["sumneko_lua"] = function ()
|
|
|
|
require('lspconfig').sumneko_lua.setup {
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
diagnostics = {
|
|
|
|
globals = { "vim" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
on_attach()
|
|
|
|
end,
|
|
|
|
})
|