fix(lsp): only auto-detach lsp.config clients #33834

Problem:
enable() routine detaches clients even if they were manually started
and not managed by vim.lsp.config.

Solution:
Skip clients that aren't managed by vim.lsp.config.

(cherry picked from commit 91e116f3a6)
This commit is contained in:
glepnir
2025-05-04 21:07:11 +08:00
committed by github-actions[bot]
parent 3b3cf1d7ef
commit 47686a1454

View File

@ -529,7 +529,7 @@ local function lsp_enable_callback(bufnr)
-- Stop any clients that no longer apply to this buffer. -- Stop any clients that no longer apply to this buffer.
local clients = lsp.get_clients({ bufnr = bufnr, _uninitialized = true }) local clients = lsp.get_clients({ bufnr = bufnr, _uninitialized = true })
for _, client in ipairs(clients) do for _, client in ipairs(clients) do
if not can_start(bufnr, client.name, lsp.config[client.name]) then if lsp.config[client.name] and not can_start(bufnr, client.name, lsp.config[client.name]) then
lsp.buf_detach_client(bufnr, client.id) lsp.buf_detach_client(bufnr, client.id)
end end
end end