aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rust-analyzer/src/config.rs')
-rw-r--r--crates/rust-analyzer/src/config.rs29
1 files changed, 19 insertions, 10 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 23168c3ae..8d6efdbe8 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -11,7 +11,7 @@ use std::{ffi::OsString, path::PathBuf};
11 11
12use lsp_types::ClientCapabilities; 12use lsp_types::ClientCapabilities;
13use ra_flycheck::FlycheckConfig; 13use ra_flycheck::FlycheckConfig;
14use ra_ide::{AssistConfig, CompletionConfig, InlayHintsConfig}; 14use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig};
15use ra_project_model::{CargoConfig, JsonProject, ProjectManifest}; 15use ra_project_model::{CargoConfig, JsonProject, ProjectManifest};
16use serde::Deserialize; 16use serde::Deserialize;
17 17
@@ -34,6 +34,7 @@ pub struct Config {
34 pub assist: AssistConfig, 34 pub assist: AssistConfig,
35 pub call_info_full: bool, 35 pub call_info_full: bool,
36 pub lens: LensConfig, 36 pub lens: LensConfig,
37 pub hover: HoverConfig,
37 38
38 pub with_sysroot: bool, 39 pub with_sysroot: bool,
39 pub linked_projects: Vec<LinkedProject>, 40 pub linked_projects: Vec<LinkedProject>,
@@ -124,6 +125,7 @@ pub struct ClientCapsConfig {
124 pub work_done_progress: bool, 125 pub work_done_progress: bool,
125 pub code_action_group: bool, 126 pub code_action_group: bool,
126 pub resolve_code_action: bool, 127 pub resolve_code_action: bool,
128 pub hover_actions: bool,
127} 129}
128 130
129impl Default for Config { 131impl Default for Config {
@@ -162,6 +164,7 @@ impl Default for Config {
162 assist: AssistConfig::default(), 164 assist: AssistConfig::default(),
163 call_info_full: true, 165 call_info_full: true,
164 lens: LensConfig::default(), 166 lens: LensConfig::default(),
167 hover: HoverConfig::default(),
165 linked_projects: Vec::new(), 168 linked_projects: Vec::new(),
166 } 169 }
167 } 170 }
@@ -278,6 +281,14 @@ impl Config {
278 } 281 }
279 } 282 }
280 283
284 let mut use_hover_actions = false;
285 set(value, "/hoverActions/enable", &mut use_hover_actions);
286 if use_hover_actions {
287 set(value, "/hoverActions/implementations", &mut self.hover.implementations);
288 } else {
289 self.hover = HoverConfig::NO_ACTIONS;
290 }
291
281 log::info!("Config::update() = {:#?}", self); 292 log::info!("Config::update() = {:#?}", self);
282 293
283 fn get<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str) -> Option<T> { 294 fn get<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str) -> Option<T> {
@@ -331,17 +342,15 @@ impl Config {
331 342
332 self.assist.allow_snippets(false); 343 self.assist.allow_snippets(false);
333 if let Some(experimental) = &caps.experimental { 344 if let Some(experimental) = &caps.experimental {
334 let snippet_text_edit = 345 let get_bool =
335 experimental.get("snippetTextEdit").and_then(|it| it.as_bool()) == Some(true); 346 |index: &str| experimental.get(index).and_then(|it| it.as_bool()) == Some(true);
336 self.assist.allow_snippets(snippet_text_edit);
337 347
338 let code_action_group = 348 let snippet_text_edit = get_bool("snippetTextEdit");
339 experimental.get("codeActionGroup").and_then(|it| it.as_bool()) == Some(true); 349 self.assist.allow_snippets(snippet_text_edit);
340 self.client_caps.code_action_group = code_action_group;
341 350
342 let resolve_code_action = 351 self.client_caps.code_action_group = get_bool("codeActionGroup");
343 experimental.get("resolveCodeAction").and_then(|it| it.as_bool()) == Some(true); 352 self.client_caps.resolve_code_action = get_bool("resolveCodeAction");
344 self.client_caps.resolve_code_action = resolve_code_action; 353 self.client_caps.hover_actions = get_bool("hoverActions");
345 } 354 }
346 } 355 }
347} 356}