1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crate;
/// An async / worker-capable language server.
///
/// This is the extension point for language servers whose work does *not*
/// complete within the call that receives a message -- for example one that
/// forwards requests to a Web Worker (or a real WASM server running off the
/// main thread) and gets answers back later, or one that emits diagnostics
/// spontaneously after a processing step.
///
/// Where the synchronous [`LspServer`] *returns* its replies, an
/// `LspServerAsync` pushes them: it is handed an [`LspPusher`] once via
/// [`lsp_pusher_set`], then for each message from the editor it does whatever
/// async work it needs and pushes any resulting messages -- replies and
/// unprompted notifications alike -- onto the pusher whenever they are ready.
/// This is what makes **server-pushed diagnostics**
/// (`textDocument/publishDiagnostics`) possible: nothing has to be returned in
/// response to a specific request.
///
/// Implement this for your worker-backed language server, then bridge it to the
/// editor with [`LspBridge::lsp_bridge_from_server_async`].
///
/// [`LspServer`]: crate::lsp::lsp_server::LspServer
/// [`lsp_pusher_set`]: LspServerAsync::lsp_pusher_set
/// [`LspBridge::lsp_bridge_from_server_async`]: crate::lsp::lsp_bridge::LspBridge::lsp_bridge_from_server_async