From 70e5fb98a007c49e2f2a1d2f58c31008385c9754 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Thu, 20 Dec 2018 12:16:44 +0000 Subject: Disable highlighting if disabled This isn't working properly because we don't dynamically disable or enable it TODO: work out why highlighting can be enabled mid session. TODO: Improve settings handling --- crates/ra_lsp_server/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 4497980e5..4877e4827 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -27,7 +27,7 @@ fn main() -> Result<()> { #[derive(Deserialize)] #[serde(rename_all = "camelCase")] struct InitializationOptions { - publish_decorations: bool, + highlighting_on: bool, } fn main_inner() -> Result<()> { @@ -45,7 +45,7 @@ fn main_inner() -> Result<()> { let publish_decorations = params .initialization_options .and_then(|v| InitializationOptions::deserialize(v).ok()) - .map(|it| it.publish_decorations) + .map(|it| it.highlighting_on) == Some(true); ra_lsp_server::main_loop(false, root, publish_decorations, r, s) }, -- cgit v1.2.3 From 380733d6d0361271620ece87ed970c994fb8b226 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Fri, 21 Dec 2018 17:00:31 +0000 Subject: Undo the previous mistaken change and make publish_decorations optional See https://github.com/Microsoft/language-server-protocol/issues/567 for motivations to not require `InitializationOptions` TODO: Check if there are any other protocol extensions which should be disabled if not implemented on the client --- crates/ra_lsp_server/src/main.rs | 11 +++++++---- crates/ra_lsp_server/src/main_loop.rs | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 4877e4827..038912de0 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -27,7 +27,10 @@ fn main() -> Result<()> { #[derive(Deserialize)] #[serde(rename_all = "camelCase")] struct InitializationOptions { - highlighting_on: bool, + // Whether the client supports our custom highlighting publishing decorations. + // This is different to the highlightingOn setting, which is whether the client + // wants highlighting to be used or sent. + publish_decorations: Option, } fn main_inner() -> Result<()> { @@ -42,12 +45,12 @@ fn main_inner() -> Result<()> { .root_uri .and_then(|it| it.to_file_path().ok()) .unwrap_or(cwd); - let publish_decorations = params + let supports_decorations = params .initialization_options .and_then(|v| InitializationOptions::deserialize(v).ok()) - .map(|it| it.highlighting_on) + .and_then(|it| it.publish_decorations) == Some(true); - ra_lsp_server::main_loop(false, root, publish_decorations, r, s) + ra_lsp_server::main_loop(false, root, supports_decorations, r, s) }, )?; log::info!("shutting down IO..."); diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 1d6e3e5d6..8b787c329 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -53,7 +53,7 @@ enum Task { pub fn main_loop( internal_mode: bool, ws_root: PathBuf, - publish_decorations: bool, + supports_decorations: bool, msg_receiver: &Receiver, msg_sender: &Sender, ) -> Result<()> { @@ -82,7 +82,7 @@ pub fn main_loop( let mut subs = Subscriptions::new(); let main_res = main_loop_inner( internal_mode, - publish_decorations, + supports_decorations, &pool, msg_sender, msg_receiver, @@ -111,7 +111,7 @@ pub fn main_loop( fn main_loop_inner( internal_mode: bool, - publish_decorations: bool, + supports_decorations: bool, pool: &ThreadPool, msg_sender: &Sender, msg_receiver: &Receiver, @@ -201,7 +201,7 @@ fn main_loop_inner( update_file_notifications_on_threadpool( pool, state.snapshot(), - publish_decorations, + supports_decorations, task_sender.clone(), subs.subscriptions(), ) -- cgit v1.2.3 From a0e8538129131b5c7cb770f5e07f9723b4194ca6 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sun, 23 Dec 2018 11:10:12 +0000 Subject: Improve comment --- crates/ra_lsp_server/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 038912de0..721665eed 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -28,8 +28,8 @@ fn main() -> Result<()> { #[serde(rename_all = "camelCase")] struct InitializationOptions { // Whether the client supports our custom highlighting publishing decorations. - // This is different to the highlightingOn setting, which is whether the client - // wants highlighting to be used or sent. + // This is different to the highlightingOn setting, which is whether the user + // wants our custom highlighting to be used. publish_decorations: Option, } -- cgit v1.2.3