From 47686a1454354b643ed6d5773fe2b246a9edbf9a Mon Sep 17 00:00:00 2001 From: glepnir Date: Sun, 4 May 2025 21:07:11 +0800 Subject: [PATCH] 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 91e116f3a6719e9dc7652f4e0a4b1760dfbf1af0) --- runtime/lua/vim/lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index b17dd692cd..0424d79f31 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -529,7 +529,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