diff options
Diffstat (limited to 'crates/rust-analyzer/src/config.rs')
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 3aeca8839..de70959a5 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -32,6 +32,9 @@ use crate::{ | |||
32 | // | 32 | // |
33 | // However, editor specific config, which the server doesn't know about, should | 33 | // However, editor specific config, which the server doesn't know about, should |
34 | // be specified directly in `package.json`. | 34 | // be specified directly in `package.json`. |
35 | // | ||
36 | // To deprecate an option by replacing it with another name use `new_name | `old_name` so that we keep | ||
37 | // parsing the old name. | ||
35 | config_data! { | 38 | config_data! { |
36 | struct ConfigData { | 39 | struct ConfigData { |
37 | /// How imports should be grouped into use statements. | 40 | /// How imports should be grouped into use statements. |
@@ -309,6 +312,37 @@ impl LensConfig { | |||
309 | } | 312 | } |
310 | } | 313 | } |
311 | 314 | ||
315 | #[derive(Clone, Debug, PartialEq, Eq)] | ||
316 | pub struct HoverActionsConfig { | ||
317 | pub implementations: bool, | ||
318 | pub references: bool, | ||
319 | pub run: bool, | ||
320 | pub debug: bool, | ||
321 | pub goto_type_def: bool, | ||
322 | } | ||
323 | |||
324 | impl HoverActionsConfig { | ||
325 | pub const NO_ACTIONS: Self = Self { | ||
326 | implementations: false, | ||
327 | references: false, | ||
328 | run: false, | ||
329 | debug: false, | ||
330 | goto_type_def: false, | ||
331 | }; | ||
332 | |||
333 | pub fn any(&self) -> bool { | ||
334 | self.implementations || self.references || self.runnable() || self.goto_type_def | ||
335 | } | ||
336 | |||
337 | pub fn none(&self) -> bool { | ||
338 | !self.any() | ||
339 | } | ||
340 | |||
341 | pub fn runnable(&self) -> bool { | ||
342 | self.run || self.debug | ||
343 | } | ||
344 | } | ||
345 | |||
312 | #[derive(Debug, Clone)] | 346 | #[derive(Debug, Clone)] |
313 | pub struct FilesConfig { | 347 | pub struct FilesConfig { |
314 | pub watcher: FilesWatcher, | 348 | pub watcher: FilesWatcher, |
@@ -527,7 +561,7 @@ impl Config { | |||
527 | pub fn code_action_group(&self) -> bool { | 561 | pub fn code_action_group(&self) -> bool { |
528 | self.experimental("codeActionGroup") | 562 | self.experimental("codeActionGroup") |
529 | } | 563 | } |
530 | pub fn hover_actions(&self) -> bool { | 564 | pub fn experimental_hover_actions(&self) -> bool { |
531 | self.experimental("hoverActions") | 565 | self.experimental("hoverActions") |
532 | } | 566 | } |
533 | pub fn server_status_notification(&self) -> bool { | 567 | pub fn server_status_notification(&self) -> bool { |
@@ -727,17 +761,21 @@ impl Config { | |||
727 | refs: self.data.lens_enable && self.data.lens_references, | 761 | refs: self.data.lens_enable && self.data.lens_references, |
728 | } | 762 | } |
729 | } | 763 | } |
730 | pub fn highlighting_strings(&self) -> bool { | 764 | pub fn hover_actions(&self) -> HoverActionsConfig { |
731 | self.data.highlighting_strings | 765 | HoverActionsConfig { |
732 | } | ||
733 | pub fn hover(&self) -> HoverConfig { | ||
734 | HoverConfig { | ||
735 | implementations: self.data.hoverActions_enable | 766 | implementations: self.data.hoverActions_enable |
736 | && self.data.hoverActions_implementations, | 767 | && self.data.hoverActions_implementations, |
737 | references: self.data.hoverActions_enable && self.data.hoverActions_references, | 768 | references: self.data.hoverActions_enable && self.data.hoverActions_references, |
738 | run: self.data.hoverActions_enable && self.data.hoverActions_run, | 769 | run: self.data.hoverActions_enable && self.data.hoverActions_run, |
739 | debug: self.data.hoverActions_enable && self.data.hoverActions_debug, | 770 | debug: self.data.hoverActions_enable && self.data.hoverActions_debug, |
740 | goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef, | 771 | goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef, |
772 | } | ||
773 | } | ||
774 | pub fn highlighting_strings(&self) -> bool { | ||
775 | self.data.highlighting_strings | ||
776 | } | ||
777 | pub fn hover(&self) -> HoverConfig { | ||
778 | HoverConfig { | ||
741 | links_in_hover: self.data.hover_linksInHover, | 779 | links_in_hover: self.data.hover_linksInHover, |
742 | markdown: try_or!( | 780 | markdown: try_or!( |
743 | self.caps | 781 | self.caps |