nvim: swap mason with lazy-lsp for lsp installation

we don't need language-specific package managers in path now eg. cargo,
pip, npm, etc. this is done in a more "nix" way.
This commit is contained in:
Nico 2025-05-03 16:15:57 +10:00
parent 54b7a64e6a
commit 67080cb94b
3 changed files with 53 additions and 56 deletions

View file

@ -1,8 +1,6 @@
return {
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
@ -11,6 +9,7 @@ return {
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"j-hui/fidget.nvim",
"dundalek/lazy-lsp.nvim",
},
config = function()
@ -23,38 +22,44 @@ return {
cmp_lsp.default_capabilities())
require("fidget").setup({})
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"gopls",
"pyright",
"bashls",
"cssls",
"html",
require("lazy-lsp").setup {
-- By default all available servers are set up. Exclude unwanted or misbehaving servers.
excluded_servers = {
"ccls", "zk",
},
-- Alternatively specify preferred servers for a filetype (others will be ignored).
preferred_servers = {
markdown = {},
python = { "pyright" },
rust = { "nil" },
go = { "gopls" },
},
prefer_local = true, -- Prefer locally installed servers over nix-shell
-- Default config passed to all servers to specify on_attach callback and other options.
default_config = {
flags = {
debounce_text_changes = 150,
},
handlers = {
function(server_name) -- default handler (optional)
-- on_attach = on_attach,
-- capabilities = capabilities,
},
-- Override config for specific servers that will passed down to lspconfig setup.
-- Note that the default_config will be merged with this specific configuration so you don't need to specify everything twice.
configs = {
lua_ls = {
settings = {
Lua = {
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
},
},
},
},
}
require("lspconfig")[server_name].setup {
capabilities = capabilities
}
end,
["lua_ls"] = function()
local lspconfig = require("lspconfig")
lspconfig.lua_ls.setup {
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim", "it", "describe", "before_each", "after_each" },
}
}
}
}
end,
}
})
local cmp_select = { behavior = cmp.SelectBehavior.Select }