aboutsummaryrefslogtreecommitdiff
path: root/crates/gen_lsp_server/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/gen_lsp_server/src/lib.rs')
-rw-r--r--crates/gen_lsp_server/src/lib.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/gen_lsp_server/src/lib.rs b/crates/gen_lsp_server/src/lib.rs
index 476c12cc1..0dc24ffc1 100644
--- a/crates/gen_lsp_server/src/lib.rs
+++ b/crates/gen_lsp_server/src/lib.rs
@@ -15,7 +15,7 @@ mod stdio;
15use crossbeam_channel::{Sender, Receiver}; 15use crossbeam_channel::{Sender, Receiver};
16use languageserver_types::{ 16use languageserver_types::{
17 ServerCapabilities, InitializeResult, 17 ServerCapabilities, InitializeResult,
18 request::{Initialize}, 18 request::{Initialize, Shutdown},
19 notification::{Initialized, Exit}, 19 notification::{Initialized, Exit},
20}; 20};
21 21
@@ -48,6 +48,17 @@ pub fn run_server(
48 Ok(()) 48 Ok(())
49} 49}
50 50
51pub fn handle_shutdown(req: RawRequest, sender: &Sender<RawMessage>) -> Option<RawRequest> {
52 match req.cast::<Shutdown>() {
53 Ok((id, ())) => {
54 let resp = RawResponse::ok::<Shutdown>(id, ());
55 sender.send(RawMessage::Response(resp));
56 None
57 }
58 Err(req) => Some(req),
59 }
60}
61
51fn initialize( 62fn initialize(
52 receiver: &mut Receiver<RawMessage>, 63 receiver: &mut Receiver<RawMessage>,
53 sender: &mut Sender<RawMessage>, 64 sender: &mut Sender<RawMessage>,
@@ -61,7 +72,7 @@ fn initialize(
61 msg => 72 msg =>
62 bail!("expected initialize request, got {:?}", msg), 73 bail!("expected initialize request, got {:?}", msg),
63 }; 74 };
64 let resp = RawResponse::ok(id, InitializeResult { capabilities: caps }); 75 let resp = RawResponse::ok::<Initialize>(id, InitializeResult { capabilities: caps });
65 sender.send(RawMessage::Response(resp)); 76 sender.send(RawMessage::Response(resp));
66 match receiver.recv() { 77 match receiver.recv() {
67 Some(RawMessage::Notification(n)) => { 78 Some(RawMessage::Notification(n)) => {