-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Dynamically register server capabilities in initialize
#381
Comments
TL;DR: No, (not with current The While it would be interesting to try add some mechanism to support this in the future - it's not going to help you today. I haven't used them yet myself but, Some other notes on dynamic registration
Hope that helps! |
Woops! 🤦 Should be fixed now! I'll leave this open, as I think we should probably enable something along the lines of your original attempt so that it's possible to support clients that don't implement dynamic registration :) |
Hey there 👋
I'm interested in dynamically registering the features that our LSP server supports, based on client configuration. Concretely, while the Ruff LSP has traditionally surfaced lint diagnostics, it can now also support code formatting, and I'd like users to be able to "turn off" the formatting and/or linting behaviors as desired, based on client configuration.
The way we solve this today is via an environment variable. The VS Code extension registers a setting in VS Code, and then the client sets an environment variable prior to starting the server. The server then reads that variable and conditionally registers the text formatting action:
This is fine, but it won't work as well for other LSP clients. It'd be nice if this were instead driven by a configuration option that was passed from client to server...
My thinking was to instead move this into the
@LSP_SERVER.feature(INITIALIZE)
handler: so, look at the provided settings, and register functions conditionally, something like:(IIUC, this would require that the user restart the LSP when changing configuration, but that's fine.)
However, in testing, while the registration is being called when I'd expect it to, VS Code is saying that the capabilities aren't being registered:
Is this something that you would expect to work? Is there a better way to accomplish this client-driven dynamic server registration?
Thank you in advance, grateful for all the work you do on
pygls
!The text was updated successfully, but these errors were encountered: