From 91e116f3a6719e9dc7652f4e0a4b1760dfbf1af0 Mon Sep 17 00:00:00 2001 From: glepnir Date: Sun, 4 May 2025 21:07:11 +0800 Subject: 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. --- runtime/lua/vim/lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/lsp.lua') diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index cb711859da..a641e78510 100644 --- 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 -- cgit