Can anyone explain to me what dynamicRegistration really is, and how it could be used? I'm using clojure-lsp with Calva, and I've added a setting to enable/disable references code lens. I'd like to refresh all visible codeLens when this setting is changed, so that if it's disabled they'll disappear, enabled they'll appear, without the user needing to close and reopen the file, edit the file, etc.
Some guidance was given to me here, but I don't really understand. https://github.com/microsoft/vscode-languageserver-node/issues/705#issuecomment-743042037 > better would be to dynamically register code lenses. When you then disabled code lenses simple de-register the code lens provider I see that in the initialize request sent to the server from client, codeLens is dynamically registered (I think)
"codeLens": {
"dynamicRegistration": true
}
But, I really don't know what this means, and how to "turn off / turn on" the codeLens capability from the client. It seems the client/registerCapability
request is sent from server to client, so I don't see how a change in a setting in VS Code can cause something to come from the server.
My current solution is very hacky. I noticed that a file edit will cause codeLenses to be refreshed, so I am actually adding a line to the top of all visible editors, then removing it.
I'm not sure but shouldn't these things be sent via https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeConfiguration where you can send this anytime without the need to restart the server?
Hmm I hadn't considered that before, will look into it. I don't yet know what settings
in that request is really referring to or how it should be structured, but I'll investigate. Thanks!
Unfortunately I do not see what settings
should be here:
interface DidChangeConfigurationParams {
/**
* The actual changed settings
*/
settings: any;
}
Also, it appears clojure-lsp does nothing with the workspace/didChangeConfiguration
notification, besides log, unless I'm missing something: https://github.com/snoe/clojure-lsp/blob/ddf34340bc268a35f49c470a82b833128abc2f8c/src/clojure_lsp/main.clj#L345yeah, it seems we would need to implement that 😕
Guess I will stick to my hacky solution for now, or just not try to do anything immediately when the code lens setting is changed, and let the code lenses refresh when the user changes the document or closes/reopens it
> the upcoming 3.16 release has a mechanism to retrigger all code lenses in all files for a given provider (https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#codeLens_refresh) This will be nice when released. It seems it requires implementation in the server.
Either that, or unregister the codeLens capability, which is also something that would need to be implemented in clojure-lsp: > When you then disabled code lenses simple de-register the code lens provider (see https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#client_registerCapability) (Still a bit fuzzy on it)
Yeah, I was reading about client/registerCapability
and client/unregisterCapability
`, it should fix your problme if implemented on server, right?
So I guess currently there is no way in clojure-lsp to "disable" a capability from the client, aside from implementing middleware and modifying the requests.
Yeah, I think so, though still fuzzy on what that means (does it mean no more codeLens requests will be made, but the current lenses in files will persist? Or will they all be refreshed/removed if the capability is unregistered?)