Skip to content

Commit 5ac9139

Browse files
committed
feat(lsp): resolve language servers discovery-first
Rewrite mason-lspconfig around the shared resolver + lsp.lua ordering (setup → user overrides → resolve). Per-filetype deferral is event-driven — no hardcoded eager set: a listed bucket resolves that ft, a dotted variant resolves its base bucket, an unlisted real-file ft drains the rest; enable() attaches by the module's real filetypes so deferring is correctness-safe. The user.configs.lsp override window records/replays per-server ops and closes so a captured proxy can't re-globalize. yamlls/gh_actions_ls claim yaml.github; yamlls prunes the traefik v2/v3 fileMatch conflict by pattern.
1 parent 1cd3db7 commit 5ac9139

5 files changed

Lines changed: 994 additions & 149 deletions

File tree

lua/modules/configs/completion/lsp.lua

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
return function()
2+
-- Handler/probe machinery first (no discovery yet): sets up the read
3+
-- trigger the override pass below relies on.
24
require("completion.mason-lspconfig").setup()
35

4-
local opts = {
5-
capabilities = require("modules.utils").get_lsp_capabilities(),
6-
}
7-
-- Configure LSPs that are not managed by Mason but are available in `nvim-lspconfig`.
8-
-- Servers are defined in `settings.external_lsp_deps` as { server_name = "executable" }.
9-
for lsp_name, exe in pairs(require("core.settings").external_lsp_deps) do
10-
if vim.fn.executable(exe) == 1 then
11-
local ok, _opts = pcall(require, "user.configs.lsp-servers." .. lsp_name)
12-
if not ok then
13-
local default_ok, default_opts = pcall(require, "completion.servers." .. lsp_name)
14-
if default_ok then
15-
_opts = default_opts
16-
end
17-
end
18-
if type(_opts) == "table" then
19-
local final_opts = vim.tbl_deep_extend("keep", _opts, opts)
20-
require("modules.utils").register_server(lsp_name, final_opts)
21-
else
22-
require("modules.utils").register_server(lsp_name, opts)
23-
end
24-
end
25-
end
6+
-- Run `user.configs.lsp` with its vim.lsp.config registrations recorded: a
7+
-- mid-session install registers after this point, and the replay keeps the
8+
-- user's overrides on top regardless of timing.
9+
-- `user.configs.lsp-servers.<name>` remains the richer per-server hook.
10+
require("completion.mason-lspconfig").run_user_lsp_overrides()
2611

27-
pcall(require, "user.configs.lsp")
12+
-- Discovery LAST (Mason-installed / on $PATH / installable / missing,
13+
-- driven by `settings.lsp_deps`): user runtime registrations above must be
14+
-- visible to the unknown/binary classification.
15+
require("completion.mason-lspconfig").resolve_deps()
2816

2917
-- Start LSPs
3018
pcall(vim.cmd.LspStart)

0 commit comments

Comments
 (0)