lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
bringe 2020-12-11T20:20:26.050800Z

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.

bringe 2020-12-11T20:23:11.052400Z

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
            }

bringe 2020-12-11T20:25:37.053900Z

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.

bringe 2020-12-11T20:27:00.054800Z

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.

ericdallo 2020-12-11T20:38:05.056800Z

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?

bringe 2020-12-11T20:45:08.057800Z

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!

😉 1
bringe 2020-12-11T21:54:07.059500Z

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#L345

ericdallo 2020-12-11T21:54:56.060200Z

yeah, it seems we would need to implement that 😕

bringe 2020-12-11T21:57:06.061200Z

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

bringe 2020-12-11T21:58:27.061900Z

> 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.

bringe 2020-12-11T22:02:02.063Z

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)

ericdallo 2020-12-11T22:05:01.065700Z

Yeah, I was reading about client/registerCapability and client/unregisterCapability`, it should fix your problme if implemented on server, right?

bringe 2020-12-11T22:05:30.066200Z

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.

bringe 2020-12-11T22:06:41.067300Z

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?)