Skip to content
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

Function to send notification to client editor #8

Open
MinusGix opened this issue Sep 13, 2022 · 0 comments
Open

Function to send notification to client editor #8

MinusGix opened this issue Sep 13, 2022 · 0 comments

Comments

@MinusGix
Copy link
Member

There should be a function to easily send a notification to the client from a plugin. This can currently be achieved via object_to_stdout, but in a somewhat unpleasant manner and makes the plugin authors have to figure out the details of the LSP/PSP api for sending information. (I think that function should also be hidden, and plugin authors using the library should just deal with functions for sending notifications/requests)
We can use lsp-types/psp-types Notification trait to make things more type-safe, like:

pub fn send_notification<T: Notification>(params: T::Params) {
    // Having them give the `T` ensures that they can't give us the wrong method name or the wrong params
    // They can still do custom notifications (like editor-specific notifs) via making a custom structure and implementing Notification on it
    let method: &'static str = T::METHOD;
    // We could just have send_host_notification take `impl Serialize`?
    send_host_notification(method, json!(params));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant