Compare commits

...

2 commits

Author SHA1 Message Date
6b1b5300cd home: vim: lspconfig: simplify LSP config
All checks were successful
ci/woodpecker/push/check Pipeline was successful
Despite what I just said in the previous commit, I decided to remove the
`is_executable` checks and always enable all servers.

I figured out that NeoVim actually handles `PATH` modifications pretty
well in this scenario: making a previously unavailable server executable
will automatically enable it.
2025-10-03 12:39:18 +00:00
62533d435b home: vim: lspconfig: use native configuration
The `nvim-lspconfig` "framework" is being deprecated to use the native
`vim.lsp.config` and `vim.lsp.enable` functionality.

I _could_ remove the `is_executable` checks, as native LSP handling does
_not_ loudly error out when enabling a server which isn't executable.
However I think `:LspInfo` is more readable if I don't.
2025-10-03 12:18:42 +00:00

View file

@ -1,4 +1,3 @@
local lspconfig = require("lspconfig")
local lsp = require("ambroisie.lsp") local lsp = require("ambroisie.lsp")
local utils = require("ambroisie.utils") local utils = require("ambroisie.utils")
@ -25,59 +24,27 @@ vim.diagnostic.config({
-- Inform servers we are able to do completion, snippets, etc... -- Inform servers we are able to do completion, snippets, etc...
local capabilities = require("cmp_nvim_lsp").default_capabilities() local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- C/C++ -- Shared configuration
if utils.is_executable("clangd") then vim.lsp.config("*", {
lspconfig.clangd.setup({ capabilities = capabilities,
capabilities = capabilities, on_attach = lsp.on_attach,
on_attach = lsp.on_attach, })
})
end
-- Haskell local servers = {
if utils.is_executable("haskell-language-server-wrapper") then -- C/C++
lspconfig.hls.setup({ clangd = {},
capabilities = capabilities, -- Haskell
on_attach = lsp.on_attach, hls = {},
}) -- Nix
end nil_ls = {},
-- Python
-- Nix pyright = {},
if utils.is_executable("nil") then ruff = {},
lspconfig.nil_ls.setup({ -- Rust
capabilities = capabilities, rust_analyzer = {},
on_attach = lsp.on_attach, -- Shell
}) bashls = {
end
-- Python
if utils.is_executable("pyright") then
lspconfig.pyright.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
if utils.is_executable("ruff") then
lspconfig.ruff.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
-- Rust
if utils.is_executable("rust-analyzer") then
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
-- Shell
if utils.is_executable("bash-language-server") then
lspconfig.bashls.setup({
filetypes = { "bash", "sh", "zsh" }, filetypes = { "bash", "sh", "zsh" },
capabilities = capabilities,
on_attach = lsp.on_attach,
settings = { settings = {
bashIde = { bashIde = {
shfmt = { shfmt = {
@ -88,28 +55,17 @@ if utils.is_executable("bash-language-server") then
}, },
}, },
}, },
}) },
end -- Starlark
starpls = {},
-- Generic
harper_ls = {},
typos_lsp = {},
}
-- Starlark for server, config in pairs(servers) do
if utils.is_executable("starpls") then if not vim.tbl_isempty(config) then
lspconfig.starpls.setup({ vim.lsp.config(server, config)
capabilities = capabilities, end
on_attach = lsp.on_attach, vim.lsp.enable(server)
})
end
-- Generic
if utils.is_executable("harper-ls") then
lspconfig.harper_ls.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
if utils.is_executable("typos-lsp") then
lspconfig.typos_lsp.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end end