nix-config/modules/home/vim/plugin/settings/lspconfig.lua
Bruno BELANYI 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

92 lines
2 KiB
Lua

local lsp = require("ambroisie.lsp")
local utils = require("ambroisie.utils")
-- Diagnostics
vim.diagnostic.config({
-- Disable virtual test next to affected regions
virtual_text = false,
-- Also disable virtual diagnostics under the affected regions
virtual_lines = false,
-- Show diagnostics signs
signs = true,
-- Underline offending regions
underline = true,
-- Do not bother me in the middle of insertion
update_in_insert = false,
-- Show highest severity first
severity_sort = true,
jump = {
-- Show float on diagnostic jumps
float = true,
},
})
-- Inform servers we are able to do completion, snippets, etc...
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Shared configuration
vim.lsp.config("*", {
capabilities = capabilities,
on_attach = lsp.on_attach,
})
-- C/C++
if utils.is_executable("clangd") then
vim.lsp.enable("clangd")
end
-- Haskell
if utils.is_executable("haskell-language-server-wrapper") then
vim.lsp.enable("hls")
end
-- Nix
if utils.is_executable("nil") then
vim.lsp.enable("nil_ls")
end
-- Python
if utils.is_executable("pyright") then
vim.lsp.enable("pyright")
end
if utils.is_executable("ruff") then
vim.lsp.enable("ruff")
end
-- Rust
if utils.is_executable("rust-analyzer") then
vim.lsp.enable("rust_analyzer")
end
-- Shell
if utils.is_executable("bash-language-server") then
vim.lsp.config("bashls", {
filetypes = { "bash", "sh", "zsh" },
settings = {
bashIde = {
shfmt = {
-- Simplify the code
simplifyCode = true,
-- Indent switch cases
caseIndent = true,
},
},
},
})
vim.lsp.enable("bashls")
end
-- Starlark
if utils.is_executable("starpls") then
vim.lsp.enable("starpls")
end
-- Generic
if utils.is_executable("harper-ls") then
vim.lsp.enable("harper_ls")
end
if utils.is_executable("typos-lsp") then
vim.lsp.enable("typos_lsp")
end