Clean up lsp servers configuration

main
Ensar Sarajčić 2022-05-09 11:33:44 +02:00
parent d3c792f613
commit 2e52f575be
3 changed files with 35 additions and 43 deletions

View File

@ -1 +0,0 @@
return require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())

View File

@ -2,9 +2,9 @@
-- - LSP servers common config -
-------------------------------------------------------------------------------
local M = {}
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
M.on_attach = function(client, bufnr)
local function on_attach(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
-- Lsp keymaps
@ -29,4 +29,7 @@ M.on_attach = function(client, bufnr)
end
end
return M
return {
on_attach = on_attach,
capabilities = capabilities
}

View File

@ -4,7 +4,27 @@
local lspconfig = require("lspconfig")
local common_config = require("esensar.lsp.server_config")
local capabilities = require("esensar.lsp.capabilities")
-- Language specific LSP config overrides
local configuration_overrides = {
gdscript = {
flags = {
-- Slow Godot LS
debounce_text_changes = 600,
}
},
omnisharp = {
cmd = {
vim.fn.glob("$HOME") .. "/lsp/dotnet/omnisharp/run",
"--languageserver",
"--hostPID",
tostring(vim.fn.getpid())
},
},
lemminx = {
cmd = { 'lemminx' }
}
}
-- Lsp default language servers
local servers = {
@ -15,11 +35,14 @@ local servers = {
"crystalline",
"cucumber_language_server",
"dockerls",
"gdscript",
"gopls",
"hls",
"jsonls",
"kotlin_language_server",
"lemminx",
"mint",
"omnisharp",
"pyright",
"rust_analyzer",
"solang",
@ -29,49 +52,16 @@ local servers = {
"zls",
}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup({
on_attach = common_config.on_attach,
capabilities = capabilities,
})
lspconfig[lsp].setup(vim.tbl_extend('force', common_config, configuration_overrides[lsp] or {}))
end
lspconfig["gdscript"].setup({
on_attach = common_config.on_attach,
capabilities = capabilities,
flags = {
-- Slow Godot LS
debounce_text_changes = 600,
},
})
-- Lua bultin lsp
require("nlua.lsp.nvim").setup(lspconfig, {
on_attach = common_config.on_attach,
capabilities = capabilities,
-- Include globals you want to tell the LSP are real :)
require("nlua.lsp.nvim").setup(lspconfig, vim.tbl_extend('force', common_config, {
-- Tell LSP which globals should be considered real
globals = {},
})
}))
-- Flutter tools
require("flutter-tools").setup({
lsp = {
on_attach = common_config.on_attach,
capabilities = capabilities,
},
})
-- Dotnet LS
local pid = vim.fn.getpid()
local omnisharp_bin = vim.fn.glob("$HOME") .. "/lsp/dotnet/omnisharp/run"
lspconfig.omnisharp.setup({
cmd = { omnisharp_bin, "--languageserver", "--hostPID", tostring(pid) },
on_attach = common_config.on_attach,
capabilities = capabilities,
})
-- Leminx (XML Language server)
lspconfig.lemminx.setup({
cmd = { "lemminx" },
on_attach = common_config.on_attach,
capabilities = capabilities,
lsp = common_config
})