Skip to content

Commit

Permalink
fix: disable autostart after :LspStop #2987
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
brookhong authored Jan 29, 2024
1 parent 5787aee commit d1d8b8a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/lspconfig/configs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d1d8b8a

Please sign in to comment.