Skip to content

Add a command to kill the server behind a workspace #2763

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nbfalcon
Copy link
Member

@nbfalcon nbfalcon commented Apr 4, 2021

lsp-workspace-kill will kill the server behind a given workspace using
kill-process, and optionally restart it. The naming was chosen to be
consistent with lsp-workspace-restart/shutdown.

@nbfalcon
Copy link
Member Author

nbfalcon commented Apr 4, 2021

This feature was asked by LunarForce on Discord: "Is there a way to list and kill language server processes in the current buffer [...]"

(lsp--warn "Killing %s" (lsp--workspace-print workspace))
(setf (lsp--workspace-shutdown-action workspace)
(if restart 'restart 'shutdown))
(kill-process (lsp--workspace-proc workspace)))
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be lsp--workspace-cmd-proc for the server process to be killed, else you will just kill the connection in the case of tcp server.
The lsp-workspace-shutdown/restart is already killing (and restarting) the server process already. Can you elaborate more on why we need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

lsp-workspace-shutdown is more graceful, so won't work if a server hangs. lsp-workspace-kill just kills the server, which will bring it down immediately most of the time (and as such should only be used for debugging).

Copy link
Member

Choose a reason for hiding this comment

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

lsp-workspace-shutdown is more graceful, so won't work if a server hangs.

IMHO we should make sure that lsp-workspace-shutdown works even with a hanging server.

Copy link
Member

Choose a reason for hiding this comment

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

Looking at lsp--shutdown-workspace, if the server hangs, after the time out we will call lsp--uninitialize-workspace, which kills the server process too.

Copy link
Member Author

@nbfalcon nbfalcon Apr 5, 2021

Choose a reason for hiding this comment

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

Perhaps lsp-workspace-shutdown should be async? I don't really have much justification for lsp-workspace-kill other than "it might be useful as a debugging tool sometime", so feel free to close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants