-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add support for client requests #13
Comments
This JSON-RPC WebSocket client looks simple enough. We could maybe replace |
As mentioned in the description, pull request #28 implemented a temporary hack that allows us to send requests but never read the responses, dropping them instead. Basically, we are treating them like JSON-RPC notifications for now. This hack is similar to what RLS does to support client/registerCapability, client/unregisterCapability, and workspace/applyEdit. The first and second methods have empty response bodies, and checking the response body of the third isn't that critical for basic support. Pull request #29 added an atomic request ID counter to |
Pull request #33 added support for the workspace/applyEdit request. As with the previous client requests, we still rely on the same hack to make this possible. |
I think a first step would be to have some data structure in We also need to add a reference to the delegate in The first problem here is that the delegate gets consumed here. handler.extend_with(delegate.to_delegate()); We would probably need multiple references to delegate so I'm not quite sure how to go about it (the first thing would be to investigate the restrictions imposed by the In the worst case I think the server and client part of the internal service and delegate implementation will have to be separated, with For processing the actual responses I think the nicest API would be with callbacks, like this: printer.configuration(params, |response| {
let _ = response;
}); This would require storing the closures in the printer and executing them when a response arrives. I would go with defining an enum |
Unfortunately, it is impossible to avoid consuming the delegate due to how I agree that we could potentially create a router which sits in the I don't believe callbacks would be the ideal ergonomic choice here. I've actually managed to resolve #58 locally and am using |
This commit makes judicious use of `compat()` to convert between `std::future::Future` and the legacy `futures` 0.1 `Future` trait such that we can have native Rust async/await support without waiting for the `jsonrpsee` crate to be ready (see #58 for context). Naturally, this should be considered a breaking change for this library since it directly affects the public API for this crate. It tentatively introduces a reliance on [`async-trait`] for the `LanguageServer` trait and it also relaxes the `'static` requirements for the `stdin` parameter for `Server`. [`async-trait`]: https://github.com/dtolnay/async-trait This does not yet resolve #13, since that would require either switching to `jsonrpsee` or building a custom client solution for the `Printer`, converting it to a `Client` or similar.
This commit makes judicious use of `compat()` to convert between `std::future::Future` and the legacy `futures` 0.1 `Future` trait such that we can have native Rust async/await support without waiting for the `jsonrpsee` crate to be ready (see #58 for context). Naturally, this should be considered a breaking change for this library since it directly affects the public API for this crate, and it also increases the minimum supported Rust version to 1.39.0. It tentatively introduces a reliance on [`async-trait`] for the `LanguageServer` trait and it also relaxes the `'static` requirements for the `stdin` parameter for `Server`. [`async-trait`]: https://github.com/dtolnay/async-trait This does not yet resolve #13, since that would require either switching to `jsonrpsee` or building a custom client solution for the `Printer`, converting it to a `Client` or similar.
This commit makes judicious use of `compat()` to convert between `std::future::Future` and the legacy `futures` 0.1 `Future` trait such that we can have native Rust async/await support without waiting for the `jsonrpsee` crate to be ready (see #58 for context). Naturally, this should be considered a breaking change for this library since it directly affects the public API for this crate, and it also increases the minimum supported Rust version to 1.39.0. It tentatively introduces a reliance on [`async-trait`] for the `LanguageServer` trait and it also relaxes the `'static` requirements for the `stdin` parameter for `Server`. [`async-trait`]: https://github.com/dtolnay/async-trait This does not yet resolve #13, since that would require either switching to `jsonrpsee`, once it's ready, or building a custom client solution for the `Printer`, converting it to a `Client` or similar.
This issue was accidentally closed by d2f5380 due to the "resolves" keyword being picked up in the commit message. |
Since #101 has migrated Since it is common for client requests to be emitted in response to notifications such as |
What do you think about using another I'm not too familiar with async rust so I can't really comment on that part for now, but this project could be a great learning opportunity. |
@icsaszar That is precisely what I was thinking of doing, albeit with an async channel instead. Still, it's important to keep in mind that this bidirectional processing of |
Currently, the
Printer
and associatedMessageStream
only support sending notifications from the server to the client.This is due to both limitations in
jsonrpc-core
and design difficulties in making theServer
andLspService
bidirectional. Implementing this in a satisfactory way would allow the following server-to-client requests to be implemented:window/showMessageRequest
client/registerCapability
client/unregisterCapability
workspace/workspaceFolders
workspace/configuration
workspace/applyEdit
Thankfully, these aren't quite as critical as the rest of the requests in the LSP specification, but it would still be nice to support them eventually for the sake of completeness.
The text was updated successfully, but these errors were encountered: