lsp fix maybe
This commit is contained in:
@@ -1,31 +1,55 @@
|
|||||||
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 = {},
|
||||||
filetypes = { "html", "css", "javascriptreact", "typescriptreact" },
|
lua_ls = {},
|
||||||
init_options = {
|
pyright = {},
|
||||||
html = {
|
cssls = {}, -- No longer needs 'capabilities = capabilities'
|
||||||
options = {
|
ts_ls = {}, -- No longer needs 'capabilities = capabilities'
|
||||||
["bem.enabled"] = true,
|
rust_analyzer = {},
|
||||||
|
|
||||||
|
-- emmet_ls settings are preserved here
|
||||||
|
emmet_ls = {
|
||||||
|
filetypes = { "html", "css", "javascriptreact", "typescriptreact" },
|
||||||
|
init_options = {
|
||||||
|
html = {
|
||||||
|
options = {
|
||||||
|
["bem.enabled"] = true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
-- Note: We no longer need to define 'capabilities' here,
|
||||||
|
-- as it gets the merged default from the config function.
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
end,
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user