-
Notifications
You must be signed in to change notification settings - Fork 809
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
server->client "show location list" request #1148
Comments
Strawman:
(The "multiple location lists" part could be dropped - the idea is to allow a nice rich UI in e.g. VSCode while supporting editors like vim where the native location-list is a singleton) |
I'd be kind of concerned about the server trying to micro-manage the client UI in this regard... Under what circumstances would you expect a server to pop up a location list ? In response to some user action, or something ? |
Yes, only ever in response to a user action. Particularly activating a code action/code lens. (I do think there's a real tradeoff here - maybe doing everything declaratively is better for clients and worse for servers. But I think allowing servers to switch documents but not send references is the worst of both worlds) |
Agree, I actually had the same concern about Anyway in summary, if this is qualified to only be valid between an 'executeCommand' request and the 'executeCommand' response (or as part of a 'codeAction' response), then I have less of a concern, as that boxes it to a "valid" action in response to a user "codeAction" request. I don't really grok what codeLens is, but if that's user-initiated, then sure that too :) so comment on the straw man is that I think you may want to include it in the |
I am not sure I understand this. What should happen with the location list. Should it stay open until a user selects something and the selected element is then returned to the server. I am not a fan of showing a list somewhere which doesn't auto close. I raises IMO lots of problems around who owns this list and how do we update the list. |
This is most likely some specialized find-references action triggered by a codelens/codeaction. E.g. "show tests of this function". I'd expect similar UI choices to find-all-references: typically it opens a panel and it's up to the user to hide it.
Ah, I should have been clearer: when the user selects a location from the list, the editor navigates to that location. Just like the find-references UI. No coordination with the server required. |
IMO this is the wrong approach to this since it is not clear to the client what to do with the list. In LSP data pushed by the server is owned by the server. Data pull by the client is owned by the client. To keep things consistent that list has to come from the server using some sort of pull request and shouldn't be pushed by the server. |
That's a reasonable position. So how should this feature be built in a client-pull world? One option (strictest sense of "pull"), the client needs to be given a hint that it's appropriate to explicitly request a location list in response to an action/lens.
Another option (slightly broader sense) is that a command can be a "pull" of various types of data
And the broadest sense of "pull" is what i'd proposed here: executing a command is a high-level request, and well-behaved servers "push" the response, but the two are not linked by the protocol.
There's some precedent for both options 1 and 3. 3 is more consistent in a "different types of actions work in a similar way" sense. But I think you're more concerned about ownership of the UI, and draw a strong distinction between say the editor pane and other panes. (I think there's some underlying tension: language servers would love to offer contextual, language-specific features without having to fully generalize and standardize them in LSP. Generic features like codeAction/codeLens offer this, and are limited by how the server can present results. On the other hand, the richer and more freeform and "platformy" the facilities LSP provides are, the less you can shape the overall product in a good and consistent direction) |
This seems to have overlap with #1119 For what it's worth: there are already some language servers out in the wild that expect the client to handle some of the provided commands in a codeLens/codeAction. Examples of command identifiers are (I'm not sure if I have these correct, but just from memory): editor.action.signatureSuggest: "please show the signature help widget" Due to the way VSCode works internally, if a command with the given name is registered as a command in the extension, it will run that command via the extension, instead of doing the workspace/executeCommand RPC call. This behavior is not documented in the spec. But many VSCode-focused language servers are already making great use of this behavior. We have started to implement the same behavior: https://github.com/sublimelsp/LSP/blob/270cd2dfa5bf25584a123b9c896a7167888f0d78/plugin/core/sessions.py#L535-L545 This does mean that all clients will have to add more client glue code.
I agree. But this principle does not seem applicable here. In what way is the server supposed to manage this "location list" resource? I consider this fleeting data (unlike diagnostics). |
I see a couple of options:
|
My 2p FWIW.
2/3. that seems doable. I.e. server can request that client makes a particular type of existing LSP request. i think I prefer the way 3 is defined personally, as the whole mechanism of 'commands' isn't truly general and assumes particular type of client implementation, whereas 3 only uses existing high level protocol concepts (admittedly, commands are part of the protocol, though they're kind of nuts-and-bolts requiring a lot of client-side knowledge of servers) |
I am okay with any of the three proposed options. But I do agree with @puremourning that (1) won't really benefit the ecosystem in practice. If we go with (2), then #1119 seems to become redundant. Perhaps @kdvolder and @mickaelistria want to have a say in this as well. |
codeAction and codeLens are valuable generic hooks for the server to provide features.
These features are limited by what actions LSP allows the server to trigger on the client.
Today the most useful are:
applyTextEdits
,showMessage
,showDocument
(new, thanks!).It'd be a nice addition to be able to publish a list of locations, similar to how
textDocument/references
results are displayed.The most obvious use case: "show references" is the stock example of a code lens, but can't be implemented directly in LSP today. (It requires some extension like a known Command name that is handled by an editor plugin).
#788 suggests to standardize some such Commands, but a server->client request would be more composable, easier to document, be guarded by capabilities in a better-understood way, etc.
(clangd is considering implementing this as an extension as part of our codeLens support, in order to clearly document what client support is required)
The text was updated successfully, but these errors were encountered: