Files
nvim-config/lua/plugins/lsp-config.lua
2024-07-07 16:16:02 +02:00

42 lines
1.1 KiB
Lua

return {
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
},
config = function()
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local handlers = {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }),
}
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"gopls",
"rust_analyzer",
"html",
"zls",
"pyright",
"ols",
"clangd",
},
handlers = {
function(server_name)
require("lspconfig")[server_name].setup {
capabilities = capabilities,
handlers = handlers
}
end
}
})
vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
vim.keymap.set("n", "gd", vim.lsp.buf.definition, {})
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, {})
vim.keymap.set("n", "<leader>cr", vim.lsp.buf.rename, {})
end,
}