-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
LSP: Validate responses against client capabilities #144
Comments
Sounds good. I just wanted to throw it out there. |
When we do care about this, I think we can implement this in our |
I don't think its as simple as supporting the latest version of the LSP. According to the official LSP spec if you don't support the capabilities then you are de-facto not supporting the latest version of the LSP. The LSP specification is designed to be backwards compatible and supporting client capabilities is part of all 3.0 versions of the specification. This is also problematic for text editors with a slower release cycle than VSCode. Since VSCode defines the specification they will always have the latest features implemented. For other editors (such as VS) they will always be behind in the spec. Edit: its also worth noting that some features cannot be implemented by some clients. And by not supporting capabilities you are unable to run on those clients ever. |
That's true indeed! To elaborate a bit, we are in the explicitly experimental phase, so protocol conformance is a non-goal (at the moment). Instead, we want to try as may things as fast as possible, so we are cutting corners, and we do use custom extensions to the protocol. For example, our syntax highgliting works only in VS Code (and is a horrible hack), assists are supported only in VS Code and Emacs (b/c we extended the protocol to position the cursor), and the same goes for extend selection (which we've up streamed to the protocol) |
Fair enough :) I only noticed this because I was attempting to get this working in Visual Studio and it doesn't have all the capabilities of VSCode. |
Curious, what exactly is missing? Perhaps its easy enough to add? |
Well so the VS implementation of LSP is closed source and tied to the VS release cycle, which is quite slow compared to VSCode. Here are the list of things missing in VS I've noticed so far:
|
I meant easy to fix on our side :) Neither of those is trivial, but removing snippets should be easy enough (iirc vim doesn’t like snippets as well). Code actions are tricky, they are implemented with client-side commad. Workspace symbols should probably just work? We don’t do anything special there, and I think the protocol there hasn’t changed for a while? For document symbols, we use new hierarchical format, which I think won’t work as well? Changing it to a flat one shouldn’t be too difficult, although less important than completions. |
Originally my idea for solving this was be to hold onto the client capabilities sent during |
There are some code actions that get sent over when the client requests it. It shouldn't be too hard to fix this if we can get the client capabilities since the code action literals that are sent contain the command. |
The InitializeParams come through here as From From there you would need to maybe teach |
For the record, ycmd doesn't handle snippets and actually asserts so completion in ycmd with rust-analyzer is completely broken. |
As an initial step, would it make sense to look at the client capabilities provided during initial connection, and error out if the capabilities don't include things that we assume the client supports? We can then incrementally reduce that set of "required capabilities" as rust-analyzer starts to take them into account (for instance, not providing snippets if the client doesn't advertise support for them). |
We could send a log or trace message back to the user so they know
functionality may be broken (hopefully they would file an issue).
Some of the client capabilities are used more as hints (semantic token
types are an example of this) to the server and probably wouldn't require
any additional checking.
…On Wed, Apr 22, 2020, 8:56 PM Josh Triplett ***@***.***> wrote:
As an initial step, would it make sense to look at the client capabilities
provided during initial connection, and error out if the capabilities don't
include things that we assume the client supports?
We can then incrementally reduce that set of "required capabilities" as
rust-analyzer starts to take them into account (for instance, not providing
snippets if the client doesn't advertise support for them).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#144 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBACREPNVR6BNZVBKAJQQ3RN6G2RANCNFSM4F54CSWA>
.
|
I strongly believe that "erroring out" is wrong behavior for an IDE most of the times. It should function on best-effort basis and never die I don't think we need any incremental steps here -- we just (and here I think the word just is actually justtified) need to go through all methods in handlers.rs and make sure to simplify our responses according to client's capabilities. The good start would be the completion snippets issue. |
If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites then it does not support the `DocumentSymbol[]` return type from the `textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`. This is one of the few requests that use the client capabilities to differentiate between return types and could cause problems for clients. See microsoft/language-server-protocol#538 (comment) for more context. Found while looking at rust-lang#144
If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites then it does not support the `DocumentSymbol[]` return type from the `textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`. This is one of the few requests that use the client capabilities to differentiate between return types and could cause problems for clients. See microsoft/language-server-protocol#538 (comment) for more context. Found while looking at rust-lang#144
If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites then it does not support the `DocumentSymbol[]` return type from the `textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`. This is one of the few requests that use the client capabilities to differentiate between return types and could cause problems for clients. See microsoft/language-server-protocol#538 (comment) for more context. Found while looking at rust-lang#144
4113: Support returning non-hierarchical symbols r=matklad a=kjeremy If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites then it does not support the `DocumentSymbol[]` return type from the `textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`. This is one of the few requests that use the client capabilities to differentiate between return types and could cause problems for clients. See microsoft/language-server-protocol#538 (comment) for more context. Found while looking at #144 4136: add support for cfg feature attributes on expression #4063 r=matklad a=bnjjj close issue #4063 4141: Fix typo r=matklad a=Veetaha 4142: Remove unnecessary async from vscode language client creation r=matklad a=Veetaha 4145: Remove dead code r=matklad a=matklad bors r+ 🤖 Co-authored-by: kjeremy <[email protected]> Co-authored-by: Benjamin Coenen <[email protected]> Co-authored-by: veetaha <[email protected]> Co-authored-by: Aleksey Kladov <[email protected]>
4113: Support returning non-hierarchical symbols r=matklad a=kjeremy If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites then it does not support the `DocumentSymbol[]` return type from the `textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`. This is one of the few requests that use the client capabilities to differentiate between return types and could cause problems for clients. See microsoft/language-server-protocol#538 (comment) for more context. Found while looking at #144 4136: add support for cfg feature attributes on expression #4063 r=matklad a=bnjjj close issue #4063 4141: Fix typo r=matklad a=Veetaha 4142: Remove unnecessary async from vscode language client creation r=matklad a=Veetaha Co-authored-by: kjeremy <[email protected]> Co-authored-by: Benjamin Coenen <[email protected]> Co-authored-by: veetaha <[email protected]>
4167: Filter out code actions if unsupported by the client and advertise our capabilities r=matklad a=kjeremy This PR does three things: 1. If the client does not support `CodeActionKind` this will filter the results and only send `Command[]` back. 2. Correctly advertises to the client that the server supports `CodeActionKind`. This may cause clients to not request code actions if they are checking for the provider to be `true` (or implement LSP < 3.8) in the caps but I will fix that in a followup PR. 3. Marks most CodeActions as <strike>"refactor" so that they show up in the menu in vscode.</strike>`""`. Part of #144 #4147 #2833 Co-authored-by: kjeremy <[email protected]>
4516: LSP: Two stage initialization r=kjeremy a=kjeremy Fills in server information. Derives CodeAction capabilities from the client. If code action literals are unsupported we fall back to the "simple support" which just sends back commands (this is already supported in our config). The difference being that we did not adjust our server capabilities so that if the client was checking for `CodeActionProvider: "true"` in the response that would have failed. Part of #144 Fixes #4130 (the specific case called out in that issue) Co-authored-by: kjeremy <[email protected]>
It appears that this also affect Emacs' Eglot LSP client: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63433 |
There are a number of places where responses from the LSP should be altered based on client and server support. Responses for things like
textDocument/rename
that return aWorkspaceEdit
are a good example of this:The text was updated successfully, but these errors were encountered: