diff options
Diffstat (limited to 'crates/rust-analyzer/src/config.rs')
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 53aee833d..b5dc6f0fa 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -33,6 +33,36 @@ pub struct Config { | |||
33 | pub inlay_hints: InlayHintsConfig, | 33 | pub inlay_hints: InlayHintsConfig, |
34 | pub completion: CompletionConfig, | 34 | pub completion: CompletionConfig, |
35 | pub call_info_full: bool, | 35 | pub call_info_full: bool, |
36 | pub lens: LensConfig, | ||
37 | } | ||
38 | |||
39 | #[derive(Clone, Debug, PartialEq, Eq)] | ||
40 | pub struct LensConfig { | ||
41 | pub run: bool, | ||
42 | pub debug: bool, | ||
43 | pub impementations: bool, | ||
44 | } | ||
45 | |||
46 | impl Default for LensConfig { | ||
47 | fn default() -> Self { | ||
48 | Self { run: true, debug: true, impementations: true } | ||
49 | } | ||
50 | } | ||
51 | |||
52 | impl LensConfig { | ||
53 | pub const NO_LENS: LensConfig = Self { run: false, debug: false, impementations: false }; | ||
54 | |||
55 | pub fn any(&self) -> bool { | ||
56 | self.impementations || self.runnable() | ||
57 | } | ||
58 | |||
59 | pub fn none(&self) -> bool { | ||
60 | !self.any() | ||
61 | } | ||
62 | |||
63 | pub fn runnable(&self) -> bool { | ||
64 | self.run || self.debug | ||
65 | } | ||
36 | } | 66 | } |
37 | 67 | ||
38 | #[derive(Debug, Clone)] | 68 | #[derive(Debug, Clone)] |
@@ -107,6 +137,7 @@ impl Default for Config { | |||
107 | ..CompletionConfig::default() | 137 | ..CompletionConfig::default() |
108 | }, | 138 | }, |
109 | call_info_full: true, | 139 | call_info_full: true, |
140 | lens: LensConfig::default(), | ||
110 | } | 141 | } |
111 | } | 142 | } |
112 | } | 143 | } |
@@ -196,6 +227,16 @@ impl Config { | |||
196 | set(value, "/completion/addCallArgumentSnippets", &mut self.completion.add_call_argument_snippets); | 227 | set(value, "/completion/addCallArgumentSnippets", &mut self.completion.add_call_argument_snippets); |
197 | set(value, "/callInfo/full", &mut self.call_info_full); | 228 | set(value, "/callInfo/full", &mut self.call_info_full); |
198 | 229 | ||
230 | let mut lens_enabled = true; | ||
231 | set(value, "/lens/enable", &mut lens_enabled); | ||
232 | if lens_enabled { | ||
233 | set(value, "/lens/run", &mut self.lens.run); | ||
234 | set(value, "/lens/debug", &mut self.lens.debug); | ||
235 | set(value, "/lens/implementations", &mut self.lens.impementations); | ||
236 | } else { | ||
237 | self.lens = LensConfig::NO_LENS; | ||
238 | } | ||
239 | |||
199 | log::info!("Config::update() = {:#?}", self); | 240 | log::info!("Config::update() = {:#?}", self); |
200 | 241 | ||
201 | fn get<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str) -> Option<T> { | 242 | fn get<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str) -> Option<T> { |