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

Implement clangd.shutdown to manually deactivate the extension (complement to clangd.activate; first half of clangd.restart). Addresses #512 #524

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

Conversation

dilijev
Copy link

@dilijev dilijev commented Aug 29, 2023

This change is a proof of concept that builds the fix roughly as described in #512 and works to disable and enable clangd language server on command with clangd.shutdown and clangd.activate. clangd.shutdown is implemented with the "dispose" action used for clangd.restart, as proposed in the issue.

Draft notes (TODO remove):

This still needs work to add some state checking of whether the language server is already shutdown, unregistration of commands that won't work if the language server is not running, or early-exit from said commands such that they don't display scary errors.

Certain commands may imply activation of the language server. Depending on the use case, this may or may not make sense versus asking the user to restart the server manually (with command >clangd: Manually activate extension) because it was previously manually shutdown by the user. Reactivating the language server via besign actions like going to another C++ file would defeat the benefit, but running clangd extension commands is enough of a signal that it might be reasonable to "do the right thing" by reactivating the language server.

…ement to clangd.activate; first half of clangd.restart). Addresses clangd#512
@dilijev dilijev marked this pull request as draft August 29, 2023 06:07
@dilijev
Copy link
Author

dilijev commented Aug 29, 2023

Looking for feedback on this PR before I continue with it to add some polish around real-user usage. While this was good enough to serve my purposes in the short term, I'd like to contribute this as a feature that is friendly to use.

Draft notes:

This still needs work to add some state checking of whether the language server is already shutdown, unregistration of commands that won't work if the language server is not running, or early-exit from said commands such that they don't display scary errors.

Certain commands may imply activation of the language server. Depending on the use case, this may or may not make sense versus asking the user to restart the server manually (with command >clangd: Manually activate extension) because it was previously manually shutdown by the user. Reactivating the language server via besign actions like going to another C++ file would defeat the benefit, but running clangd extension commands is enough of a signal that it might be reasonable to "do the right thing" by reactivating the language server.

(FWIW, the scenario that prompted me to work on this for example is the desire to temporarily save some system resources while running an intensive build & link task, for example, without having to close out of VS Code, as I can continue to read code and plan my next change while the build is running.)

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.

1 participant