gluon-lang / lsp-types

Types for communicating with a language server
MIT License
322 stars 84 forks source link

Returning partial results #156

Open kjeremy opened 4 years ago

kjeremy commented 4 years ago

While doing #155 I realized that only semantic tokens can handle a partial result in it's Request::Result. Would it make sense to add a new trait for requests that can return partial results instead of making every result an enum?

pub trait PartialRequest : Request {
    type PartialResult: DeserializeOwned + Serialize;
}
Marwes commented 4 years ago

Can any request return a partial result? Not sure how this is supposed to work. Does it make sense to just provide a generic struct to be used if a partial result is accepted

pub struct Partial<T> {
    #[serde(flatten)]
    pub result: T,
    #[serde(flatten)]
    pub work_done_progress_params: WorkDoneProgressParams,
}
kjeremy commented 4 years ago

Not all requests can return partial results and some can report progress without returning partial results.

See https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#workDoneProgress and https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#partialResults

I do like the idea of making things generic though.