-
Notifications
You must be signed in to change notification settings - Fork 59
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
custom methods for notification without params not called #409
Comments
It has been long enough since I implemented custom methods in my lsp, that I forget most of the implementation details. Sorry if I can't be more helpful at the moment. |
It's weird, I don't see what is different in my code. However I'm wondering if it could be related to the params. In my case it is a notification, without params or return value. And from what I see tower-lsp is stopping the propagation on the build of the parameters, so it is maybe related. I will try later (I'm not on my computer) to add a fake parameter to test it. |
Unfortunately, I tested everything, but can't manage to make it work. |
If I change my method in Rust to: #[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct ReadyParams {
value1: u32,
}
pub async fn client_ready(&self, params: ReadyParams) {
self.client.log_message(MessageType::INFO, format!("Client ready !")).await
} To add a custom parameter, and edit the typescript to send this parameter: client.sendNotification(
"Odoo/clientReady",
{
"value1": 5
}
); my custom method is called. I think tower-lsp doesn't accept notification (and maybe requests) without parameters. tower-lsp/src/jsonrpc/router.rs Line 210 in 49e1ce5
Where let Some(p) = params is valid because params is not empty but contains a null value, so it is raising an error |
custom_method is to define custom method, not custom notification handler. I don't think Simply speaking, how about just work with custom methods for now, and ignore the response? it will just do the work for now. |
As a notification is a method without parameter, custom_method should handle them too, and the documentation of tower-lsp states it clearly: "Defines a custom JSON-RPC request or notification with the given method But I managed to solve my issue, and I think it is coming from vscode, and not really tower-lsp. It results in a call of the method "custom_name" with the parameter 'null' in tower-lsp, which doesn't exist. |
Hello,
I'm working on a language server that is using custom notifications.
I can't manage to make them work, and I think it could be coming from tower-lsp.
Here is my code:
In this example,
client_ready
is never called, but if I put breakpoints in tower-lsp, it seems that the event is catched, the related method is registered the Router and should be called, but failed to do it. I'm quite new to Rust and I can't understand why my function isn't called.Is it something from my code?
From what I see, the call is stopped here:
C:\Users\XX.cargo\registry\src\index.crates.io-6f17d22bba15001f\tower-lsp-0.20.0\src\jsonrpc\router.rs
Thank you for your help !
EDIT: To give more information, the notification is sent from vscode, from a custom extension that is calling
in typescript. This extension is used with another language server in Python that is working. Moreover I can see tower-lsp catching the message, so I don't think that the issue could come from the client.
The text was updated successfully, but these errors were encountered: