Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable autostart after :LspStop #2987

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

@justinmk justinmk Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping there is a way to checking that the clients were force-stopped. Could there be an edge case where the client dies because of an error, which would then (unintentionally) remove this autocmd?

I guess we can try this. LspStart will recreate this autocmd again.

M.manager:try_add_wrapper(arg.buf, root_dir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the callback check if the client was force stopped? Then it can return true, which will automatically remove the autocmd.

Suggested change
M.manager:try_add_wrapper(arg.buf, root_dir)
if client.is_stopped -- psuedocode
return true
end
M.manager:try_add_wrapper(arg.buf, root_dir)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, with this addressed, other two comments should be also good.

Thanks, updated.

end,
group = lsp_group,
Expand Down
Loading