aboutsummaryrefslogtreecommitdiff
path: root/crates/gen_lsp_server/examples/01_gen_lsp_server.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-08-30 15:24:11 +0100
committerAleksey Kladov <[email protected]>2019-08-30 15:24:11 +0100
commit72a3722470e5297c72dcaccaf2f113e7b758606d (patch)
tree3f0e4056ba2e4b3799b72d71d709783aa6dffc49 /crates/gen_lsp_server/examples/01_gen_lsp_server.rs
parent7d72ca80003b7915ed7fc64907b5b6dc5c88dacd (diff)
move lsp-server to a separate repository
Diffstat (limited to 'crates/gen_lsp_server/examples/01_gen_lsp_server.rs')
-rw-r--r--crates/gen_lsp_server/examples/01_gen_lsp_server.rs47
1 files changed, 0 insertions, 47 deletions
diff --git a/crates/gen_lsp_server/examples/01_gen_lsp_server.rs b/crates/gen_lsp_server/examples/01_gen_lsp_server.rs
deleted file mode 100644
index f49965064..000000000
--- a/crates/gen_lsp_server/examples/01_gen_lsp_server.rs
+++ /dev/null
@@ -1,47 +0,0 @@
1use std::error::Error;
2
3use crossbeam_channel::{Receiver, Sender};
4use gen_lsp_server::{handle_shutdown, run_server, stdio_transport, RawMessage, RawResponse};
5use lsp_types::{
6 request::{GotoDefinition, GotoDefinitionResponse},
7 InitializeParams, ServerCapabilities,
8};
9
10fn main() -> Result<(), Box<dyn Error + Sync + Send>> {
11 let (receiver, sender, io_threads) = stdio_transport();
12 run_server(ServerCapabilities::default(), receiver, sender, main_loop)?;
13 io_threads.join()?;
14 Ok(())
15}
16
17fn main_loop(
18 _params: InitializeParams,
19 receiver: &Receiver<RawMessage>,
20 sender: &Sender<RawMessage>,
21) -> Result<(), Box<dyn Error + Sync + Send>> {
22 for msg in receiver {
23 match msg {
24 RawMessage::Request(req) => {
25 let req = match handle_shutdown(req, sender) {
26 None => return Ok(()),
27 Some(req) => req,
28 };
29 match req.cast::<GotoDefinition>() {
30 Ok((id, _params)) => {
31 let resp = RawResponse::ok::<GotoDefinition>(
32 id,
33 &Some(GotoDefinitionResponse::Array(Vec::new())),
34 );
35 sender.send(RawMessage::Response(resp))?;
36 continue;
37 }
38 Err(req) => req,
39 };
40 // ...
41 }
42 RawMessage::Response(_resp) => (),
43 RawMessage::Notification(_not) => (),
44 }
45 }
46 Ok(())
47}