lsp fix maybe

This commit is contained in:
voidarclabs
2025-11-22 17:44:57 +00:00
parent 24c0f370d0
commit 189ba01b97

View File

@@ -1,23 +1,44 @@
return { return {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
config = function()
-- This custom config function will run *instead* of the default.
-- It receives the 'opts' table (second argument) and loops through it.
config = function(_, opts)
-- 1. Get the default capabilities from cmp_nvim_lsp
-- (Your emmet_ls config was already using this, so we'll make it
-- the default for all servers. This includes snippetSupport.)
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
-- Enable snippet capability for completion -- 2. Loop over the servers defined in 'opts.servers'
local capabilities = vim.lsp.protocol.make_client_capabilities() for server_name, server_config in pairs(opts.servers or {}) do
capabilities.textDocument.completion.completionItem.snippetSupport = true -- 3. Merge default capabilities with server-specific config
-- 'vim.tbl_deep_extend' ensures server-specific settings
-- (like for emmet_ls) are preserved.
local config = vim.tbl_deep_extend("force", {
capabilities = capabilities,
}, server_config or {})
lspconfig.lua_ls.setup({}) -- 4. Setup the server
lspconfig.pyright.setup({}) lspconfig[server_name].setup(config)
lspconfig.cssls.setup({ end
capabilities = capabilities, end,
})
lspconfig.ts_ls.setup({ -- 'opts' table now holds all server-specific configurations
capabilities = capabilities, opts = {
}) servers = {
lspconfig.rust_analyzer.setup({}) -- Servers with no special config are just empty tables
lspconfig.emmet_ls.setup({ nil_ls = {},
capabilities = require("cmp_nvim_lsp").default_capabilities(), nixd = {},
lua_ls = {},
pyright = {},
cssls = {}, -- No longer needs 'capabilities = capabilities'
ts_ls = {}, -- No longer needs 'capabilities = capabilities'
rust_analyzer = {},
-- emmet_ls settings are preserved here
emmet_ls = {
filetypes = { "html", "css", "javascriptreact", "typescriptreact" }, filetypes = { "html", "css", "javascriptreact", "typescriptreact" },
init_options = { init_options = {
html = { html = {
@@ -26,6 +47,9 @@ return {
}, },
}, },
}, },
}) -- Note: We no longer need to define 'capabilities' here,
end, -- as it gets the merged default from the config function.
},
},
},
} }