diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide/src/hover.rs | 135 | ||||
-rw-r--r-- | crates/ide/src/lib.rs | 8 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 87 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 24 |
4 files changed, 157 insertions, 97 deletions
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 0c1da8774..c6d6bb74a 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use either::Either; | 1 | use either::Either; |
2 | use hir::{AsAssocItem, HasAttrs, HasSource, HirDisplay}; | 2 | use hir::{AsAssocItem, HasAttrs, HasSource, HirDisplay, Semantics}; |
3 | use ide_db::{ | 3 | use ide_db::{ |
4 | base_db::SourceDatabase, | 4 | base_db::SourceDatabase, |
5 | defs::{Definition, NameClass, NameRefClass}, | 5 | defs::{Definition, NameClass, NameRefClass}, |
@@ -30,39 +30,20 @@ use crate::{ | |||
30 | 30 | ||
31 | #[derive(Clone, Debug, PartialEq, Eq)] | 31 | #[derive(Clone, Debug, PartialEq, Eq)] |
32 | pub struct HoverConfig { | 32 | pub struct HoverConfig { |
33 | pub implementations: bool, | ||
34 | pub references: bool, | ||
35 | pub run: bool, | ||
36 | pub debug: bool, | ||
37 | pub goto_type_def: bool, | ||
38 | pub links_in_hover: bool, | 33 | pub links_in_hover: bool, |
39 | pub markdown: bool, | 34 | pub documentation: Option<HoverDocFormat>, |
40 | pub documentation: bool, | ||
41 | } | 35 | } |
42 | 36 | ||
43 | impl HoverConfig { | 37 | impl HoverConfig { |
44 | pub const NO_ACTIONS: Self = Self { | 38 | fn markdown(&self) -> bool { |
45 | implementations: false, | 39 | matches!(self.documentation, Some(HoverDocFormat::Markdown)) |
46 | references: false, | ||
47 | run: false, | ||
48 | debug: false, | ||
49 | goto_type_def: false, | ||
50 | links_in_hover: true, | ||
51 | markdown: true, | ||
52 | documentation: true, | ||
53 | }; | ||
54 | |||
55 | pub fn any_actions(&self) -> bool { | ||
56 | self.implementations || self.references || self.runnable() || self.goto_type_def | ||
57 | } | ||
58 | |||
59 | pub fn no_actions(&self) -> bool { | ||
60 | !self.any_actions() | ||
61 | } | 40 | } |
41 | } | ||
62 | 42 | ||
63 | pub fn runnable(&self) -> bool { | 43 | #[derive(Clone, Debug, PartialEq, Eq)] |
64 | self.run || self.debug | 44 | pub enum HoverDocFormat { |
65 | } | 45 | Markdown, |
46 | PlainText, | ||
66 | } | 47 | } |
67 | 48 | ||
68 | #[derive(Debug, Clone)] | 49 | #[derive(Debug, Clone)] |
@@ -95,9 +76,7 @@ pub struct HoverResult { | |||
95 | pub(crate) fn hover( | 76 | pub(crate) fn hover( |
96 | db: &RootDatabase, | 77 | db: &RootDatabase, |
97 | position: FilePosition, | 78 | position: FilePosition, |
98 | links_in_hover: bool, | 79 | config: &HoverConfig, |
99 | documentation: bool, | ||
100 | markdown: bool, | ||
101 | ) -> Option<RangeInfo<HoverResult>> { | 80 | ) -> Option<RangeInfo<HoverResult>> { |
102 | let sema = hir::Semantics::new(db); | 81 | let sema = hir::Semantics::new(db); |
103 | let file = sema.parse(position.file_id).syntax().clone(); | 82 | let file = sema.parse(position.file_id).syntax().clone(); |
@@ -156,10 +135,8 @@ pub(crate) fn hover( | |||
156 | } | 135 | } |
157 | _ => None, | 136 | _ => None, |
158 | }; | 137 | }; |
159 | if let Some(markup) = | 138 | if let Some(markup) = hover_for_definition(db, definition, famous_defs.as_ref(), config) { |
160 | hover_for_definition(db, definition, famous_defs.as_ref(), documentation) | 139 | res.markup = process_markup(sema.db, definition, &markup, config); |
161 | { | ||
162 | res.markup = process_markup(sema.db, definition, &markup, links_in_hover, markdown); | ||
163 | if let Some(action) = show_implementations_action(db, definition) { | 140 | if let Some(action) = show_implementations_action(db, definition) { |
164 | res.actions.push(action); | 141 | res.actions.push(action); |
165 | } | 142 | } |
@@ -181,8 +158,7 @@ pub(crate) fn hover( | |||
181 | } | 158 | } |
182 | } | 159 | } |
183 | 160 | ||
184 | if let res @ Some(_) = hover_for_keyword(&sema, links_in_hover, markdown, documentation, &token) | 161 | if let res @ Some(_) = hover_for_keyword(&sema, config, &token) { |
185 | { | ||
186 | return res; | 162 | return res; |
187 | } | 163 | } |
188 | 164 | ||
@@ -201,7 +177,7 @@ pub(crate) fn hover( | |||
201 | } | 177 | } |
202 | }; | 178 | }; |
203 | 179 | ||
204 | res.markup = if markdown { | 180 | res.markup = if config.markdown() { |
205 | Markup::fenced_block(&ty.display(db)) | 181 | Markup::fenced_block(&ty.display(db)) |
206 | } else { | 182 | } else { |
207 | ty.display(db).to_string().into() | 183 | ty.display(db).to_string().into() |
@@ -375,13 +351,12 @@ fn process_markup( | |||
375 | db: &RootDatabase, | 351 | db: &RootDatabase, |
376 | def: Definition, | 352 | def: Definition, |
377 | markup: &Markup, | 353 | markup: &Markup, |
378 | links_in_hover: bool, | 354 | config: &HoverConfig, |
379 | markdown: bool, | ||
380 | ) -> Markup { | 355 | ) -> Markup { |
381 | let markup = markup.as_str(); | 356 | let markup = markup.as_str(); |
382 | let markup = if !markdown { | 357 | let markup = if !config.markdown() { |
383 | remove_markdown(markup) | 358 | remove_markdown(markup) |
384 | } else if links_in_hover { | 359 | } else if config.links_in_hover { |
385 | rewrite_links(db, markup, &def) | 360 | rewrite_links(db, markup, &def) |
386 | } else { | 361 | } else { |
387 | remove_links(markup) | 362 | remove_links(markup) |
@@ -428,7 +403,7 @@ fn hover_for_definition( | |||
428 | db: &RootDatabase, | 403 | db: &RootDatabase, |
429 | def: Definition, | 404 | def: Definition, |
430 | famous_defs: Option<&FamousDefs>, | 405 | famous_defs: Option<&FamousDefs>, |
431 | documentation: bool, | 406 | config: &HoverConfig, |
432 | ) -> Option<Markup> { | 407 | ) -> Option<Markup> { |
433 | let mod_path = definition_mod_path(db, &def); | 408 | let mod_path = definition_mod_path(db, &def); |
434 | let (label, docs) = match def { | 409 | let (label, docs) = match def { |
@@ -466,7 +441,11 @@ fn hover_for_definition( | |||
466 | Definition::Label(it) => return Some(Markup::fenced_block(&it.name(db))), | 441 | Definition::Label(it) => return Some(Markup::fenced_block(&it.name(db))), |
467 | }; | 442 | }; |
468 | 443 | ||
469 | return hover_markup(docs.filter(|_| documentation).map(Into::into), label, mod_path); | 444 | return hover_markup( |
445 | docs.filter(|_| config.documentation.is_some()).map(Into::into), | ||
446 | label, | ||
447 | mod_path, | ||
448 | ); | ||
470 | 449 | ||
471 | fn label_and_docs<D>(db: &RootDatabase, def: D) -> (String, Option<hir::Documentation>) | 450 | fn label_and_docs<D>(db: &RootDatabase, def: D) -> (String, Option<hir::Documentation>) |
472 | where | 451 | where |
@@ -502,13 +481,11 @@ fn hover_for_local(it: hir::Local, db: &RootDatabase) -> Option<Markup> { | |||
502 | } | 481 | } |
503 | 482 | ||
504 | fn hover_for_keyword( | 483 | fn hover_for_keyword( |
505 | sema: &hir::Semantics<RootDatabase>, | 484 | sema: &Semantics<RootDatabase>, |
506 | links_in_hover: bool, | 485 | config: &HoverConfig, |
507 | markdown: bool, | ||
508 | documentation: bool, | ||
509 | token: &SyntaxToken, | 486 | token: &SyntaxToken, |
510 | ) -> Option<RangeInfo<HoverResult>> { | 487 | ) -> Option<RangeInfo<HoverResult>> { |
511 | if !token.kind().is_keyword() || !documentation { | 488 | if !token.kind().is_keyword() || !config.documentation.is_some() { |
512 | return None; | 489 | return None; |
513 | } | 490 | } |
514 | let famous_defs = FamousDefs(sema, sema.scope(&token.parent()?).krate()); | 491 | let famous_defs = FamousDefs(sema, sema.scope(&token.parent()?).krate()); |
@@ -520,8 +497,7 @@ fn hover_for_keyword( | |||
520 | sema.db, | 497 | sema.db, |
521 | Definition::ModuleDef(doc_owner.into()), | 498 | Definition::ModuleDef(doc_owner.into()), |
522 | &hover_markup(Some(docs.into()), token.text().into(), None)?, | 499 | &hover_markup(Some(docs.into()), token.text().into(), None)?, |
523 | links_in_hover, | 500 | config, |
524 | markdown, | ||
525 | ); | 501 | ); |
526 | Some(RangeInfo::new(token.text_range(), HoverResult { markup, actions: Default::default() })) | 502 | Some(RangeInfo::new(token.text_range(), HoverResult { markup, actions: Default::default() })) |
527 | } | 503 | } |
@@ -561,16 +537,34 @@ mod tests { | |||
561 | use expect_test::{expect, Expect}; | 537 | use expect_test::{expect, Expect}; |
562 | use ide_db::base_db::FileLoader; | 538 | use ide_db::base_db::FileLoader; |
563 | 539 | ||
564 | use crate::fixture; | 540 | use crate::{fixture, hover::HoverDocFormat, HoverConfig}; |
565 | 541 | ||
566 | fn check_hover_no_result(ra_fixture: &str) { | 542 | fn check_hover_no_result(ra_fixture: &str) { |
567 | let (analysis, position) = fixture::position(ra_fixture); | 543 | let (analysis, position) = fixture::position(ra_fixture); |
568 | assert!(analysis.hover(position, true, true, true).unwrap().is_none()); | 544 | assert!(analysis |
545 | .hover( | ||
546 | position, | ||
547 | &HoverConfig { | ||
548 | links_in_hover: true, | ||
549 | documentation: Some(HoverDocFormat::Markdown) | ||
550 | } | ||
551 | ) | ||
552 | .unwrap() | ||
553 | .is_none()); | ||
569 | } | 554 | } |
570 | 555 | ||
571 | fn check(ra_fixture: &str, expect: Expect) { | 556 | fn check(ra_fixture: &str, expect: Expect) { |
572 | let (analysis, position) = fixture::position(ra_fixture); | 557 | let (analysis, position) = fixture::position(ra_fixture); |
573 | let hover = analysis.hover(position, true, true, true).unwrap().unwrap(); | 558 | let hover = analysis |
559 | .hover( | ||
560 | position, | ||
561 | &HoverConfig { | ||
562 | links_in_hover: true, | ||
563 | documentation: Some(HoverDocFormat::Markdown), | ||
564 | }, | ||
565 | ) | ||
566 | .unwrap() | ||
567 | .unwrap(); | ||
574 | 568 | ||
575 | let content = analysis.db.file_text(position.file_id); | 569 | let content = analysis.db.file_text(position.file_id); |
576 | let hovered_element = &content[hover.range]; | 570 | let hovered_element = &content[hover.range]; |
@@ -581,7 +575,16 @@ mod tests { | |||
581 | 575 | ||
582 | fn check_hover_no_links(ra_fixture: &str, expect: Expect) { | 576 | fn check_hover_no_links(ra_fixture: &str, expect: Expect) { |
583 | let (analysis, position) = fixture::position(ra_fixture); | 577 | let (analysis, position) = fixture::position(ra_fixture); |
584 | let hover = analysis.hover(position, false, true, true).unwrap().unwrap(); | 578 | let hover = analysis |
579 | .hover( | ||
580 | position, | ||
581 | &HoverConfig { | ||
582 | links_in_hover: false, | ||
583 | documentation: Some(HoverDocFormat::Markdown), | ||
584 | }, | ||
585 | ) | ||
586 | .unwrap() | ||
587 | .unwrap(); | ||
585 | 588 | ||
586 | let content = analysis.db.file_text(position.file_id); | 589 | let content = analysis.db.file_text(position.file_id); |
587 | let hovered_element = &content[hover.range]; | 590 | let hovered_element = &content[hover.range]; |
@@ -592,7 +595,16 @@ mod tests { | |||
592 | 595 | ||
593 | fn check_hover_no_markdown(ra_fixture: &str, expect: Expect) { | 596 | fn check_hover_no_markdown(ra_fixture: &str, expect: Expect) { |
594 | let (analysis, position) = fixture::position(ra_fixture); | 597 | let (analysis, position) = fixture::position(ra_fixture); |
595 | let hover = analysis.hover(position, true, true, false).unwrap().unwrap(); | 598 | let hover = analysis |
599 | .hover( | ||
600 | position, | ||
601 | &HoverConfig { | ||
602 | links_in_hover: true, | ||
603 | documentation: Some(HoverDocFormat::PlainText), | ||
604 | }, | ||
605 | ) | ||
606 | .unwrap() | ||
607 | .unwrap(); | ||
596 | 608 | ||
597 | let content = analysis.db.file_text(position.file_id); | 609 | let content = analysis.db.file_text(position.file_id); |
598 | let hovered_element = &content[hover.range]; | 610 | let hovered_element = &content[hover.range]; |
@@ -603,7 +615,16 @@ mod tests { | |||
603 | 615 | ||
604 | fn check_actions(ra_fixture: &str, expect: Expect) { | 616 | fn check_actions(ra_fixture: &str, expect: Expect) { |
605 | let (analysis, position) = fixture::position(ra_fixture); | 617 | let (analysis, position) = fixture::position(ra_fixture); |
606 | let hover = analysis.hover(position, true, true, true).unwrap().unwrap(); | 618 | let hover = analysis |
619 | .hover( | ||
620 | position, | ||
621 | &HoverConfig { | ||
622 | links_in_hover: true, | ||
623 | documentation: Some(HoverDocFormat::Markdown), | ||
624 | }, | ||
625 | ) | ||
626 | .unwrap() | ||
627 | .unwrap(); | ||
607 | expect.assert_debug_eq(&hover.info.actions) | 628 | expect.assert_debug_eq(&hover.info.actions) |
608 | } | 629 | } |
609 | 630 | ||
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index aac084012..b978e36af 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs | |||
@@ -75,7 +75,7 @@ pub use crate::{ | |||
75 | expand_macro::ExpandedMacro, | 75 | expand_macro::ExpandedMacro, |
76 | file_structure::{StructureNode, StructureNodeKind}, | 76 | file_structure::{StructureNode, StructureNodeKind}, |
77 | folding_ranges::{Fold, FoldKind}, | 77 | folding_ranges::{Fold, FoldKind}, |
78 | hover::{HoverAction, HoverConfig, HoverGotoTypeData, HoverResult}, | 78 | hover::{HoverAction, HoverConfig, HoverDocFormat, HoverGotoTypeData, HoverResult}, |
79 | inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, | 79 | inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, |
80 | markup::Markup, | 80 | markup::Markup, |
81 | move_item::Direction, | 81 | move_item::Direction, |
@@ -408,11 +408,9 @@ impl Analysis { | |||
408 | pub fn hover( | 408 | pub fn hover( |
409 | &self, | 409 | &self, |
410 | position: FilePosition, | 410 | position: FilePosition, |
411 | links_in_hover: bool, | 411 | config: &HoverConfig, |
412 | documentation: bool, | ||
413 | markdown: bool, | ||
414 | ) -> Cancellable<Option<RangeInfo<HoverResult>>> { | 412 | ) -> Cancellable<Option<RangeInfo<HoverResult>>> { |
415 | self.with_db(|db| hover::hover(db, position, links_in_hover, documentation, markdown)) | 413 | self.with_db(|db| hover::hover(db, position, config)) |
416 | } | 414 | } |
417 | 415 | ||
418 | /// Return URL(s) for the documentation of the symbol under the cursor. | 416 | /// Return URL(s) for the documentation of the symbol under the cursor. |
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 3aeca8839..b9aa6f0aa 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -10,7 +10,10 @@ | |||
10 | use std::{ffi::OsString, iter, path::PathBuf}; | 10 | use std::{ffi::OsString, iter, path::PathBuf}; |
11 | 11 | ||
12 | use flycheck::FlycheckConfig; | 12 | use flycheck::FlycheckConfig; |
13 | use ide::{AssistConfig, CompletionConfig, DiagnosticsConfig, HoverConfig, InlayHintsConfig}; | 13 | use ide::{ |
14 | AssistConfig, CompletionConfig, DiagnosticsConfig, HoverConfig, HoverDocFormat, | ||
15 | InlayHintsConfig, | ||
16 | }; | ||
14 | use ide_db::helpers::{ | 17 | use ide_db::helpers::{ |
15 | insert_use::{ImportGranularity, InsertUseConfig, PrefixKind}, | 18 | insert_use::{ImportGranularity, InsertUseConfig, PrefixKind}, |
16 | SnippetCap, | 19 | SnippetCap, |
@@ -32,6 +35,9 @@ use crate::{ | |||
32 | // | 35 | // |
33 | // However, editor specific config, which the server doesn't know about, should | 36 | // However, editor specific config, which the server doesn't know about, should |
34 | // be specified directly in `package.json`. | 37 | // be specified directly in `package.json`. |
38 | // | ||
39 | // To deprecate an option by replacing it with another name use `new_name | `old_name` so that we keep | ||
40 | // parsing the old name. | ||
35 | config_data! { | 41 | config_data! { |
36 | struct ConfigData { | 42 | struct ConfigData { |
37 | /// How imports should be grouped into use statements. | 43 | /// How imports should be grouped into use statements. |
@@ -309,6 +315,37 @@ impl LensConfig { | |||
309 | } | 315 | } |
310 | } | 316 | } |
311 | 317 | ||
318 | #[derive(Clone, Debug, PartialEq, Eq)] | ||
319 | pub struct HoverActionsConfig { | ||
320 | pub implementations: bool, | ||
321 | pub references: bool, | ||
322 | pub run: bool, | ||
323 | pub debug: bool, | ||
324 | pub goto_type_def: bool, | ||
325 | } | ||
326 | |||
327 | impl HoverActionsConfig { | ||
328 | pub const NO_ACTIONS: Self = Self { | ||
329 | implementations: false, | ||
330 | references: false, | ||
331 | run: false, | ||
332 | debug: false, | ||
333 | goto_type_def: false, | ||
334 | }; | ||
335 | |||
336 | pub fn any(&self) -> bool { | ||
337 | self.implementations || self.references || self.runnable() || self.goto_type_def | ||
338 | } | ||
339 | |||
340 | pub fn none(&self) -> bool { | ||
341 | !self.any() | ||
342 | } | ||
343 | |||
344 | pub fn runnable(&self) -> bool { | ||
345 | self.run || self.debug | ||
346 | } | ||
347 | } | ||
348 | |||
312 | #[derive(Debug, Clone)] | 349 | #[derive(Debug, Clone)] |
313 | pub struct FilesConfig { | 350 | pub struct FilesConfig { |
314 | pub watcher: FilesWatcher, | 351 | pub watcher: FilesWatcher, |
@@ -527,7 +564,7 @@ impl Config { | |||
527 | pub fn code_action_group(&self) -> bool { | 564 | pub fn code_action_group(&self) -> bool { |
528 | self.experimental("codeActionGroup") | 565 | self.experimental("codeActionGroup") |
529 | } | 566 | } |
530 | pub fn hover_actions(&self) -> bool { | 567 | pub fn experimental_hover_actions(&self) -> bool { |
531 | self.experimental("hoverActions") | 568 | self.experimental("hoverActions") |
532 | } | 569 | } |
533 | pub fn server_status_notification(&self) -> bool { | 570 | pub fn server_status_notification(&self) -> bool { |
@@ -727,31 +764,41 @@ impl Config { | |||
727 | refs: self.data.lens_enable && self.data.lens_references, | 764 | refs: self.data.lens_enable && self.data.lens_references, |
728 | } | 765 | } |
729 | } | 766 | } |
730 | pub fn highlighting_strings(&self) -> bool { | 767 | pub fn hover_actions(&self) -> HoverActionsConfig { |
731 | self.data.highlighting_strings | 768 | HoverActionsConfig { |
732 | } | ||
733 | pub fn hover(&self) -> HoverConfig { | ||
734 | HoverConfig { | ||
735 | implementations: self.data.hoverActions_enable | 769 | implementations: self.data.hoverActions_enable |
736 | && self.data.hoverActions_implementations, | 770 | && self.data.hoverActions_implementations, |
737 | references: self.data.hoverActions_enable && self.data.hoverActions_references, | 771 | references: self.data.hoverActions_enable && self.data.hoverActions_references, |
738 | run: self.data.hoverActions_enable && self.data.hoverActions_run, | 772 | run: self.data.hoverActions_enable && self.data.hoverActions_run, |
739 | debug: self.data.hoverActions_enable && self.data.hoverActions_debug, | 773 | debug: self.data.hoverActions_enable && self.data.hoverActions_debug, |
740 | goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef, | 774 | goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef, |
775 | } | ||
776 | } | ||
777 | pub fn highlighting_strings(&self) -> bool { | ||
778 | self.data.highlighting_strings | ||
779 | } | ||
780 | pub fn hover(&self) -> HoverConfig { | ||
781 | HoverConfig { | ||
741 | links_in_hover: self.data.hover_linksInHover, | 782 | links_in_hover: self.data.hover_linksInHover, |
742 | markdown: try_or!( | 783 | documentation: self.data.hover_documentation.then(|| { |
743 | self.caps | 784 | let is_markdown = try_or!( |
744 | .text_document | 785 | self.caps |
745 | .as_ref()? | 786 | .text_document |
746 | .hover | 787 | .as_ref()? |
747 | .as_ref()? | 788 | .hover |
748 | .content_format | 789 | .as_ref()? |
749 | .as_ref()? | 790 | .content_format |
750 | .as_slice(), | 791 | .as_ref()? |
751 | &[] | 792 | .as_slice(), |
752 | ) | 793 | &[] |
753 | .contains(&MarkupKind::Markdown), | 794 | ) |
754 | documentation: self.data.hover_documentation, | 795 | .contains(&MarkupKind::Markdown); |
796 | if is_markdown { | ||
797 | HoverDocFormat::Markdown | ||
798 | } else { | ||
799 | HoverDocFormat::PlainText | ||
800 | } | ||
801 | }), | ||
755 | } | 802 | } |
756 | } | 803 | } |
757 | 804 | ||
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index eff1e6c93..dcead5f5c 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -861,13 +861,7 @@ pub(crate) fn handle_hover( | |||
861 | ) -> Result<Option<lsp_ext::Hover>> { | 861 | ) -> Result<Option<lsp_ext::Hover>> { |
862 | let _p = profile::span("handle_hover"); | 862 | let _p = profile::span("handle_hover"); |
863 | let position = from_proto::file_position(&snap, params.text_document_position_params)?; | 863 | let position = from_proto::file_position(&snap, params.text_document_position_params)?; |
864 | let hover_config = snap.config.hover(); | 864 | let info = match snap.analysis.hover(position, &snap.config.hover())? { |
865 | let info = match snap.analysis.hover( | ||
866 | position, | ||
867 | hover_config.links_in_hover, | ||
868 | hover_config.documentation, | ||
869 | hover_config.markdown, | ||
870 | )? { | ||
871 | None => return Ok(None), | 865 | None => return Ok(None), |
872 | Some(info) => info, | 866 | Some(info) => info, |
873 | }; | 867 | }; |
@@ -1487,7 +1481,7 @@ fn show_impl_command_link( | |||
1487 | snap: &GlobalStateSnapshot, | 1481 | snap: &GlobalStateSnapshot, |
1488 | position: &FilePosition, | 1482 | position: &FilePosition, |
1489 | ) -> Option<lsp_ext::CommandLinkGroup> { | 1483 | ) -> Option<lsp_ext::CommandLinkGroup> { |
1490 | if snap.config.hover().implementations { | 1484 | if snap.config.hover_actions().implementations { |
1491 | if let Some(nav_data) = snap.analysis.goto_implementation(*position).unwrap_or(None) { | 1485 | if let Some(nav_data) = snap.analysis.goto_implementation(*position).unwrap_or(None) { |
1492 | let uri = to_proto::url(snap, position.file_id); | 1486 | let uri = to_proto::url(snap, position.file_id); |
1493 | let line_index = snap.file_line_index(position.file_id).ok()?; | 1487 | let line_index = snap.file_line_index(position.file_id).ok()?; |
@@ -1513,7 +1507,7 @@ fn show_ref_command_link( | |||
1513 | snap: &GlobalStateSnapshot, | 1507 | snap: &GlobalStateSnapshot, |
1514 | position: &FilePosition, | 1508 | position: &FilePosition, |
1515 | ) -> Option<lsp_ext::CommandLinkGroup> { | 1509 | ) -> Option<lsp_ext::CommandLinkGroup> { |
1516 | if snap.config.hover().references { | 1510 | if snap.config.hover_actions().references { |
1517 | if let Some(ref_search_res) = snap.analysis.find_all_refs(*position, None).unwrap_or(None) { | 1511 | if let Some(ref_search_res) = snap.analysis.find_all_refs(*position, None).unwrap_or(None) { |
1518 | let uri = to_proto::url(snap, position.file_id); | 1512 | let uri = to_proto::url(snap, position.file_id); |
1519 | let line_index = snap.file_line_index(position.file_id).ok()?; | 1513 | let line_index = snap.file_line_index(position.file_id).ok()?; |
@@ -1544,8 +1538,8 @@ fn runnable_action_links( | |||
1544 | runnable: Runnable, | 1538 | runnable: Runnable, |
1545 | ) -> Option<lsp_ext::CommandLinkGroup> { | 1539 | ) -> Option<lsp_ext::CommandLinkGroup> { |
1546 | let cargo_spec = CargoTargetSpec::for_file(snap, runnable.nav.file_id).ok()?; | 1540 | let cargo_spec = CargoTargetSpec::for_file(snap, runnable.nav.file_id).ok()?; |
1547 | let hover_config = snap.config.hover(); | 1541 | let hover_actions_config = snap.config.hover_actions(); |
1548 | if !hover_config.runnable() || should_skip_target(&runnable, cargo_spec.as_ref()) { | 1542 | if !hover_actions_config.runnable() || should_skip_target(&runnable, cargo_spec.as_ref()) { |
1549 | return None; | 1543 | return None; |
1550 | } | 1544 | } |
1551 | 1545 | ||
@@ -1553,12 +1547,12 @@ fn runnable_action_links( | |||
1553 | to_proto::runnable(snap, runnable).ok().map(|r| { | 1547 | to_proto::runnable(snap, runnable).ok().map(|r| { |
1554 | let mut group = lsp_ext::CommandLinkGroup::default(); | 1548 | let mut group = lsp_ext::CommandLinkGroup::default(); |
1555 | 1549 | ||
1556 | if hover_config.run { | 1550 | if hover_actions_config.run { |
1557 | let run_command = to_proto::command::run_single(&r, action.run_title); | 1551 | let run_command = to_proto::command::run_single(&r, action.run_title); |
1558 | group.commands.push(to_command_link(run_command, r.label.clone())); | 1552 | group.commands.push(to_command_link(run_command, r.label.clone())); |
1559 | } | 1553 | } |
1560 | 1554 | ||
1561 | if hover_config.debug { | 1555 | if hover_actions_config.debug { |
1562 | let dbg_command = to_proto::command::debug_single(&r); | 1556 | let dbg_command = to_proto::command::debug_single(&r); |
1563 | group.commands.push(to_command_link(dbg_command, r.label)); | 1557 | group.commands.push(to_command_link(dbg_command, r.label)); |
1564 | } | 1558 | } |
@@ -1571,7 +1565,7 @@ fn goto_type_action_links( | |||
1571 | snap: &GlobalStateSnapshot, | 1565 | snap: &GlobalStateSnapshot, |
1572 | nav_targets: &[HoverGotoTypeData], | 1566 | nav_targets: &[HoverGotoTypeData], |
1573 | ) -> Option<lsp_ext::CommandLinkGroup> { | 1567 | ) -> Option<lsp_ext::CommandLinkGroup> { |
1574 | if !snap.config.hover().goto_type_def || nav_targets.is_empty() { | 1568 | if !snap.config.hover_actions().goto_type_def || nav_targets.is_empty() { |
1575 | return None; | 1569 | return None; |
1576 | } | 1570 | } |
1577 | 1571 | ||
@@ -1591,7 +1585,7 @@ fn prepare_hover_actions( | |||
1591 | snap: &GlobalStateSnapshot, | 1585 | snap: &GlobalStateSnapshot, |
1592 | actions: &[HoverAction], | 1586 | actions: &[HoverAction], |
1593 | ) -> Vec<lsp_ext::CommandLinkGroup> { | 1587 | ) -> Vec<lsp_ext::CommandLinkGroup> { |
1594 | if snap.config.hover().no_actions() || !snap.config.hover_actions() { | 1588 | if snap.config.hover_actions().none() || !snap.config.experimental_hover_actions() { |
1595 | return Vec::new(); | 1589 | return Vec::new(); |
1596 | } | 1590 | } |
1597 | 1591 | ||