major improvements, better stuff overall

This commit is contained in:
voidarclabs
2025-11-22 21:22:44 +00:00
parent 189ba01b97
commit f24a1029aa
8 changed files with 142 additions and 114 deletions

View File

@@ -1,55 +1,37 @@
return {
"neovim/nvim-lspconfig",
-- 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")
-- 2. Loop over the servers defined in 'opts.servers'
for server_name, server_config in pairs(opts.servers or {}) do
-- 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 {})
-- 4. Setup the server
lspconfig[server_name].setup(config)
end
end,
-- 'opts' table now holds all server-specific configurations
opts = {
servers = {
-- Servers with no special config are just empty tables
nil_ls = {},
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" },
init_options = {
html = {
options = {
["bem.enabled"] = true,
},
config = function()
vim.lsp.config("lua_ls", {
settings = {
Lua = {
-- Tell the server to let Neovim handle snippet expansion
completion = {
callSnippet = "Replace",
},
-- Use LuaJIT (which Neovim uses)
runtime = {
version = "LuaJIT",
},
},
-- Note: We no longer need to define 'capabilities' here,
-- as it gets the merged default from the config function.
},
},
},
})
vim.lsp.config("emmet_ls", {
-- capabilities = require("cmp_nvim_lsp").default_capabilities(),
filetypes = { "html", "css", "javascriptreact", "typescriptreact" },
init_options = {
html = {
options = {
["bem.enabled"] = true,
},
},
},
})
vim.lsp.enable({
"lua_ls",
"ts_ls",
"cssls",
"rust_analyzer",
"emmet_ls",
})
end,
}