[nvim] feat: cleanup server setup

This commit is contained in:
David JULIEN 2022-05-04 22:58:42 +02:00
parent 5d8c5ca6f4
commit f25ef3e9be
1 changed files with 5 additions and 22 deletions

View File

@ -28,16 +28,6 @@ vim.diagnostic.config({
update_in_insert = true
})
local enhance_server_opts = {
["clangd"] = function(opts)
require("plugin.lsp.clangd").setup(opts)
end,
["sumneko_lua"] = function(opts)
require("plugin.lsp.sumneko_lua").setup(opts)
end,
}
local on_attach = function(_, bufnr)
local opts = { buffer = bufnr }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
@ -67,34 +57,27 @@ end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
-- Enable the following language servers
-- Setup nvim-lsp-installer
local servers = { "clangd", "sumneko_lua" }
lsp_installer.setup {
ensure_installed = servers
}
-- Setup nvim-lsp-installer
lsp_installer.settings {
ensure_installed = servers,
ui = {
icons = {
server_installed = "",
server_pending = "o",
server_uninstalled = "x"
server_uninstalled = ""
}
}
}
for _, server in ipairs(servers) do
local opts = {
on_attach = on_attach,
capabilities = capabilities,
}
if enhance_server_opts[server] then
-- Enhance the default opts with the server-specific ones
enhance_server_opts[server](opts)
end
local plugin = string.format("%s.%s", "plugin.lsp", server)
require(plugin).setup(opts)
lspconfig[server].setup(opts)
end