commit 91e116f3a6719e9dc7652f4e0a4b1760dfbf1af0
parent cb2ca54331cdd089a6f018a933c6fc2be7f417d3
Author: glepnir <glephunter@gmail.com>
Date: Sun, 4 May 2025 21:07:11 +0800
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.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
@@ -547,7 +547,7 @@ local function lsp_enable_callback(bufnr)
-- Stop any clients that no longer apply to this buffer.
local clients = lsp.get_clients({ bufnr = bufnr, _uninitialized = true })
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)
end
end