Refactor LSP server configuration

This commit is contained in:
Oliver Davies 2024-06-01 14:48:25 +01:00
parent 4e54650790
commit 6336b36659

View file

@ -64,10 +64,10 @@ end
require("neodev").setup {} require("neodev").setup {}
local servers = { local servers = {
bashls = {}, bashls = true,
cssls = {}, cssls = true,
gopls = {}, gopls = true,
html = {}, html = true,
intelephense = { intelephense = {
filetypes = { "php", "module", "test", "inc" }, filetypes = { "php", "module", "test", "inc" },
}, },
@ -96,8 +96,8 @@ local servers = {
}, },
}, },
}, },
marksman = {}, marksman = true,
nil_ls = {}, nil_ls = true,
tailwindcss = { tailwindcss = {
filetypes = { "html", "javascript", "twig", "typescript", "vue" }, filetypes = { "html", "javascript", "twig", "typescript", "vue" },
@ -109,9 +109,9 @@ local servers = {
}, },
}, },
}, },
terraformls = {}, terraformls = true,
tsserver = {}, tsserver = true,
vuels = {}, vuels = true,
yamlls = { yamlls = {
settings = { settings = {
yaml = { yaml = {
@ -123,14 +123,16 @@ local servers = {
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
for server_name in pairs(servers) do for server_name, config in pairs(servers) do
local server = servers[server_name] or {} if config == true then
config = {}
end
lspconfig[server_name].setup { lspconfig[server_name].setup {
capabilities = capabilities, capabilities = capabilities,
filetypes = server.filetypes, filetypes = config.filetypes,
on_attach = custom_attach, on_attach = custom_attach,
settings = server.settings, settings = config.settings,
} }
end end