From a93d166f0fecb748d8cb04aab7f5406bf6308c2d Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 14 Jun 2021 15:25:10 +0200 Subject: Make documentation on hover configurable --- crates/rust-analyzer/src/config.rs | 10 +++++++--- crates/rust-analyzer/src/handlers.rs | 16 ++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'crates/rust-analyzer') 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! { /// their contents. highlighting_strings: bool = "true", + /// Whether to show documentation on hover. + hover_documentation: bool = "true", + /// Use markdown syntax for links in hover. + hover_linksInHover: bool = "true", + /// Whether to show `Debug` action. Only applies when /// `#rust-analyzer.hoverActions.enable#` is set. hoverActions_debug: bool = "true", @@ -158,8 +163,6 @@ config_data! { /// Whether to show `Run` action. Only applies when /// `#rust-analyzer.hoverActions.enable#` is set. hoverActions_run: bool = "true", - /// Use markdown syntax for links in hover. - hoverActions_linksInHover: bool = "true", /// Whether to show inlay type hints for method chains. inlayHints_chainingHints: bool = "true", @@ -726,7 +729,7 @@ impl Config { run: self.data.hoverActions_enable && self.data.hoverActions_run, debug: self.data.hoverActions_enable && self.data.hoverActions_debug, goto_type_def: self.data.hoverActions_enable && self.data.hoverActions_gotoTypeDef, - links_in_hover: self.data.hoverActions_linksInHover, + links_in_hover: self.data.hover_linksInHover, markdown: try_or!( self.caps .text_document @@ -739,6 +742,7 @@ impl Config { &[] ) .contains(&MarkupKind::Markdown), + documentation: self.data.hover_documentation, } } 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( let _p = profile::span("handle_hover"); let position = from_proto::file_position(&snap, params.text_document_position_params)?; let hover_config = snap.config.hover(); - let info = - match snap.analysis.hover(position, hover_config.links_in_hover, hover_config.markdown)? { - None => return Ok(None), - Some(info) => info, - }; + let info = match snap.analysis.hover( + position, + hover_config.links_in_hover, + hover_config.documentation, + hover_config.markdown, + )? { + None => return Ok(None), + Some(info) => info, + }; let line_index = snap.file_line_index(position.file_id)?; let range = to_proto::range(&line_index, info.range); let hover = lsp_ext::Hover { @@ -1587,7 +1591,7 @@ fn prepare_hover_actions( snap: &GlobalStateSnapshot, actions: &[HoverAction], ) -> Vec { - if snap.config.hover().none() || !snap.config.hover_actions() { + if snap.config.hover().no_actions() || !snap.config.hover_actions() { return Vec::new(); } -- cgit v1.2.3