aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/main.rs22
-rw-r--r--crates/ra_lsp_server/src/main_loop/mod.rs23
2 files changed, 34 insertions, 11 deletions
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index 4d555d488..26bcddd8e 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -2,10 +2,14 @@
2extern crate log; 2extern crate log;
3#[macro_use] 3#[macro_use]
4extern crate failure; 4extern crate failure;
5#[macro_use]
6extern crate serde_derive;
7extern crate serde;
5extern crate flexi_logger; 8extern crate flexi_logger;
6extern crate gen_lsp_server; 9extern crate gen_lsp_server;
7extern crate ra_lsp_server; 10extern crate ra_lsp_server;
8 11
12use serde::Deserialize;
9use flexi_logger::{Duplicate, Logger}; 13use flexi_logger::{Duplicate, Logger};
10use gen_lsp_server::{run_server, stdio_transport}; 14use gen_lsp_server::{run_server, stdio_transport};
11use ra_lsp_server::Result; 15use ra_lsp_server::Result;
@@ -29,6 +33,13 @@ fn main() -> Result<()> {
29 } 33 }
30 } 34 }
31} 35}
36
37#[derive(Deserialize)]
38#[serde(rename_all = "camelCase")]
39struct InitializationOptions {
40 publish_decorations: bool,
41}
42
32fn main_inner() -> Result<()> { 43fn main_inner() -> Result<()> {
33 let (receiver, sender, threads) = stdio_transport(); 44 let (receiver, sender, threads) = stdio_transport();
34 let cwd = ::std::env::current_dir()?; 45 let cwd = ::std::env::current_dir()?;
@@ -41,7 +52,12 @@ fn main_inner() -> Result<()> {
41 .root_uri 52 .root_uri
42 .and_then(|it| it.to_file_path().ok()) 53 .and_then(|it| it.to_file_path().ok())
43 .unwrap_or(cwd); 54 .unwrap_or(cwd);
44 ra_lsp_server::main_loop(false, root, r, s) 55 let publish_decorations = params
56 .initialization_options
57 .and_then(|v| InitializationOptions::deserialize(v).ok())
58 .map(|it| it.publish_decorations)
59 == Some(true);
60 ra_lsp_server::main_loop(false, root, publish_decorations, r, s)
45 }, 61 },
46 )?; 62 )?;
47 info!("shutting down IO..."); 63 info!("shutting down IO...");
@@ -52,14 +68,14 @@ fn main_inner() -> Result<()> {
52 68
53/* 69/*
54 (let ((backend (eglot-xref-backend))) 70 (let ((backend (eglot-xref-backend)))
55 (mapcar 71 (mapcar
56 (lambda (xref) 72 (lambda (xref)
57 (let ((loc (xref-item-location xref))) 73 (let ((loc (xref-item-location xref)))
58 (propertize 74 (propertize
59 (concat 75 (concat
60 (when (xref-file-location-p loc) 76 (when (xref-file-location-p loc)
61 (with-slots (file line column) loc 77 (with-slots (file line column) loc
62 (format "%s:%s:%s:" 78 (format "%s:%s:%s:"
63 (propertize (file-relative-name file) 79 (propertize (file-relative-name file)
64 'face 'compilation-info) 80 'face 'compilation-info)
65 (propertize (format "%s" line) 81 (propertize (format "%s" line)
diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs
index db878e0aa..78d93741a 100644
--- a/crates/ra_lsp_server/src/main_loop/mod.rs
+++ b/crates/ra_lsp_server/src/main_loop/mod.rs
@@ -48,6 +48,7 @@ enum Task {
48pub fn main_loop( 48pub fn main_loop(
49 internal_mode: bool, 49 internal_mode: bool,
50 root: PathBuf, 50 root: PathBuf,
51 publish_decorations: bool,
51 msg_receiver: &Receiver<RawMessage>, 52 msg_receiver: &Receiver<RawMessage>,
52 msg_sender: &Sender<RawMessage>, 53 msg_sender: &Sender<RawMessage>,
53) -> Result<()> { 54) -> Result<()> {
@@ -67,6 +68,7 @@ pub fn main_loop(
67 let mut subs = Subscriptions::new(); 68 let mut subs = Subscriptions::new();
68 let main_res = main_loop_inner( 69 let main_res = main_loop_inner(
69 internal_mode, 70 internal_mode,
71 publish_decorations,
70 root, 72 root,
71 &pool, 73 &pool,
72 msg_sender, 74 msg_sender,
@@ -99,6 +101,7 @@ pub fn main_loop(
99 101
100fn main_loop_inner( 102fn main_loop_inner(
101 internal_mode: bool, 103 internal_mode: bool,
104 publish_decorations: bool,
102 ws_root: PathBuf, 105 ws_root: PathBuf,
103 pool: &ThreadPool, 106 pool: &ThreadPool,
104 msg_sender: &Sender<RawMessage>, 107 msg_sender: &Sender<RawMessage>,
@@ -210,6 +213,7 @@ fn main_loop_inner(
210 update_file_notifications_on_threadpool( 213 update_file_notifications_on_threadpool(
211 pool, 214 pool,
212 state.snapshot(), 215 state.snapshot(),
216 publish_decorations,
213 task_sender.clone(), 217 task_sender.clone(),
214 subs.subscriptions(), 218 subs.subscriptions(),
215 ) 219 )
@@ -416,6 +420,7 @@ impl<'a> PoolDispatcher<'a> {
416fn update_file_notifications_on_threadpool( 420fn update_file_notifications_on_threadpool(
417 pool: &ThreadPool, 421 pool: &ThreadPool,
418 world: ServerWorld, 422 world: ServerWorld,
423 publish_decorations: bool,
419 sender: Sender<Task>, 424 sender: Sender<Task>,
420 subscriptions: Vec<FileId>, 425 subscriptions: Vec<FileId>,
421) { 426) {
@@ -432,15 +437,17 @@ fn update_file_notifications_on_threadpool(
432 sender.send(Task::Notify(not)); 437 sender.send(Task::Notify(not));
433 } 438 }
434 } 439 }
435 match handlers::publish_decorations(&world, file_id) { 440 if publish_decorations {
436 Err(e) => { 441 match handlers::publish_decorations(&world, file_id) {
437 if !is_canceled(&e) { 442 Err(e) => {
438 error!("failed to compute decorations: {:?}", e); 443 if !is_canceled(&e) {
444 error!("failed to compute decorations: {:?}", e);
445 }
446 }
447 Ok(params) => {
448 let not = RawNotification::new::<req::PublishDecorations>(&params);
449 sender.send(Task::Notify(not))
439 } 450 }
440 }
441 Ok(params) => {
442 let not = RawNotification::new::<req::PublishDecorations>(&params);
443 sender.send(Task::Notify(not))
444 } 451 }
445 } 452 }
446 } 453 }