Skip to content

Function to send notification to client editor #8

@MinusGix

Description

@MinusGix

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));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions