77 lines
3.1 KiB
Lua
77 lines
3.1 KiB
Lua
return {
|
|
-- LSP and Mason
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
dependencies = {
|
|
"williamboman/mason.nvim",
|
|
"williamboman/mason-lspconfig.nvim",
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
},
|
|
config = function()
|
|
-- Enable native virtual lines (rendered directly below the
|
|
-- affected line) with custom formatting
|
|
vim.diagnostic.config({
|
|
underline = false, -- virtual_lines already shows the message; skip the extra underline
|
|
virtual_text = false,
|
|
virtual_lines = {
|
|
format = function(diagnostic)
|
|
local msg = diagnostic.message or ""
|
|
msg = msg:gsub("^[a-z_][a-z0-9_%-]*:%s*", "")
|
|
return msg
|
|
end,
|
|
},
|
|
})
|
|
|
|
-- NOTE: modern Neovim (0.11+) dedupes diagnostics internally, and
|
|
-- the old vim.lsp.with()-based publishDiagnostics override is
|
|
-- deprecated, so it's intentionally not used here.
|
|
|
|
-- Which servers to set up (what Mason installs, what gets enabled,
|
|
-- and any per-server overrides) is defined in one table in
|
|
-- lua/config/lsp/servers.lua -- to add a language server, add it
|
|
-- there rather than here.
|
|
local servers = require("config.lsp.servers")
|
|
local server_names = vim.tbl_keys(servers)
|
|
table.sort(server_names)
|
|
|
|
require("mason").setup()
|
|
require("mason-lspconfig").setup({
|
|
ensure_installed = server_names,
|
|
})
|
|
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
|
|
-- Some clangd tweaks (e.g. several of its clang-tidy quick
|
|
-- fixes) are only sent to clients that advertise support for
|
|
-- resolving a code action's edit in a second round-trip, rather
|
|
-- than requiring the whole edit up front. cmp-nvim-lsp's
|
|
-- capabilities don't declare this on their own, so without it
|
|
-- clangd just leaves those actions out of the list entirely
|
|
-- instead of sending something the client can't apply.
|
|
capabilities.textDocument.codeAction = vim.tbl_deep_extend("force", capabilities.textDocument.codeAction or {}, {
|
|
dataSupport = true,
|
|
resolveSupport = { properties = { "edit" } },
|
|
})
|
|
|
|
-- Keymaps, applied per-buffer on LspAttach (lua/config/lsp/keymaps.lua).
|
|
require("config.lsp.keymaps").setup()
|
|
|
|
-- :LspRestart / :LspStart / :LspStop / :LspInfo / :LspLog. nvim-lspconfig
|
|
-- stopped providing these on Neovim 0.12 (core's own `:lsp` command
|
|
-- replaced them), so lua/config/lsp/commands.lua defines them as
|
|
-- aliases over the built-ins. It does nothing on older Neovim, where
|
|
-- nvim-lspconfig still registers the real ones.
|
|
require("config.lsp.commands").setup()
|
|
|
|
-- Setup LSPs via the built-in vim.lsp.config()/vim.lsp.enable()
|
|
-- API (replaces the deprecated require('lspconfig')[x].setup()
|
|
-- framework). Default per-server settings still come from
|
|
-- nvim-lspconfig, which only needs to be on the runtimepath.
|
|
for name, opts in pairs(servers) do
|
|
vim.lsp.config(name, vim.tbl_deep_extend("force", { capabilities = capabilities }, opts))
|
|
end
|
|
vim.lsp.enable(server_names)
|
|
end,
|
|
},
|
|
}
|