diff options
author | Lukas Wirth <[email protected]> | 2021-06-14 14:25:10 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-06-14 14:25:10 +0100 |
commit | a93d166f0fecb748d8cb04aab7f5406bf6308c2d (patch) | |
tree | ceda7b8ea1bf1c2949c75191e4faa41693f8f19e /crates/rust-analyzer | |
parent | 388a91c8a8d542f7a8e0ddff879cce4d4c2b20ae (diff) |
Make documentation on hover configurable
Diffstat (limited to 'crates/rust-analyzer')
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 10 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 16 |
2 files changed, 17 insertions, 9 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 3b20d741a..5d3deb232 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -141,6 +141,11 @@ config_data! { | |||
141 | /// their contents. | 141 | /// their contents. |
142 | highlighting_strings: bool = "true", | 142 | highlighting_strings: bool = "true", |
143 | 143 | ||
144 | /// Whether to show documentation on hover. | ||
145 | hover_documentation: bool = "true", | ||
146 | /// Use markdown syntax for links in hover. | ||
147 | hover_linksInHover: bool = "true", | ||
148 | |||
144 | /// Whether to show `Debug` action. Only applies when | 149 | /// Whether to show `Debug` action. Only applies when |
145 | /// `#rust-analyzer.hoverActions.enable#` is set. | 150 | /// `#rust-analyzer.hoverActions.enable#` is set. |
146 | hoverActions_debug: bool = "true", | 151 | hoverActions_debug: bool = "true", |
@@ -158,8 +163,6 @@ config_data! { | |||
158 | /// Whether to show `Run` action. Only applies when | 163 | /// Whether to show `Run` action. Only applies when |
159 | /// `#rust-analyzer.hoverActions.enable#` is set. | 164 | /// `#rust-analyzer.hoverActions.enable#` is set. |
160 | hoverActions_run: bool = "true", | 165 | hoverActions_run: bool = "true", |
161 | /// Use markdown syntax for links in hover. | ||
162 | hoverActions_linksInHover: bool = "true", | ||
163 | 166 | ||
164 | /// Whether to show inlay type hints for method chains. | 167 | /// Whether to show inlay type hints for method chains. |
165 | inlayHints_chainingHints: bool = "true", | 168 | inlayHints_chainingHints: bool = "true", |
@@ -726,7 +729,7 @@ impl Config { | |||
726 | run: self.data.hoverActions_enable && self.data.hoverActions_run, | 729 | run: self.data.hoverActions_enable && self.data.hoverActions_run, |
727 | debug: self.data.hoverActions_enable && self.data.hoverActions_debug, | 730 | debug: self.data.hoverActions_enable && self.data.hoverActions_debug, |
728 | goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef, | 731 | goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef, |
729 | links_in_hover: self.data.hoverActions_linksInHover, | 732 | links_in_hover: self.data.hover_linksInHover, |
730 | markdown: try_or!( | 733 | markdown: try_or!( |
731 | self.caps | 734 | self.caps |
732 | .text_document | 735 | .text_document |
@@ -739,6 +742,7 @@ impl Config { | |||
739 | &[] | 742 | &[] |
740 | ) | 743 | ) |
741 | .contains(&MarkupKind::Markdown), | 744 | .contains(&MarkupKind::Markdown), |
745 | documentation: self.data.hover_documentation, | ||
742 | } | 746 | } |
743 | } | 747 | } |
744 | 748 | ||
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index ccf66294f..eff1e6c93 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -862,11 +862,15 @@ pub(crate) fn handle_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 hover_config = snap.config.hover(); |
865 | let info = | 865 | let info = match snap.analysis.hover( |
866 | match snap.analysis.hover(position, hover_config.links_in_hover, hover_config.markdown)? { | 866 | position, |
867 | None => return Ok(None), | 867 | hover_config.links_in_hover, |
868 | Some(info) => info, | 868 | hover_config.documentation, |
869 | }; | 869 | hover_config.markdown, |
870 | )? { | ||
871 | None => return Ok(None), | ||
872 | Some(info) => info, | ||
873 | }; | ||
870 | let line_index = snap.file_line_index(position.file_id)?; | 874 | let line_index = snap.file_line_index(position.file_id)?; |
871 | let range = to_proto::range(&line_index, info.range); | 875 | let range = to_proto::range(&line_index, info.range); |
872 | let hover = lsp_ext::Hover { | 876 | let hover = lsp_ext::Hover { |
@@ -1587,7 +1591,7 @@ fn prepare_hover_actions( | |||
1587 | snap: &GlobalStateSnapshot, | 1591 | snap: &GlobalStateSnapshot, |
1588 | actions: &[HoverAction], | 1592 | actions: &[HoverAction], |
1589 | ) -> Vec<lsp_ext::CommandLinkGroup> { | 1593 | ) -> Vec<lsp_ext::CommandLinkGroup> { |
1590 | if snap.config.hover().none() || !snap.config.hover_actions() { | 1594 | if snap.config.hover().no_actions() || !snap.config.hover_actions() { |
1591 | return Vec::new(); | 1595 | return Vec::new(); |
1592 | } | 1596 | } |
1593 | 1597 | ||