From d1d8b8a0180aafb5cf8f0454b52adb6d1e9522cb Mon Sep 17 00:00:00 2001 From: brook hong Date: Mon, 29 Jan 2024 11:58:34 +0800 Subject: fix: disable autostart after :LspStop #2987 Problem: The `BufReadPost` handler may autostart LSP, even after `:LspStop`. Solution: Remove the `BufReadPost` handler if there are no clients (assuming that `:LspStop` stopped them). Note: The `BufReadPost` handler will be recreated if user runs `:LspStart`. --- lua/lspconfig/configs.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lua') diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua index 5056c49c..669e32bf 100644 --- a/lua/lspconfig/configs.lua +++ b/lua/lspconfig/configs.lua @@ -139,6 +139,9 @@ function configs.__newindex(t, config_name, config_def) api.nvim_create_autocmd('BufReadPost', { pattern = fn.fnameescape(root_dir) .. '/*', callback = function(arg) + if #M.manager:clients() == 0 then + return true + end M.manager:try_add_wrapper(arg.buf, root_dir) end, group = lsp_group, -- cgit v1.2.3-70-g09d2