Merge #9264
9264: feat: Make documentation on hover configurable r=Veykril a=Veykril This also implements deprecation support for config options as this renames `hoverActions_linksInHover` to `hover_linksInHover`. Fixes #9232 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
@@ -146,6 +146,12 @@ 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 |
|
||||
hoverActions_linksInHover: bool = "true",
|
||||
|
||||
/// Whether to show `Debug` action. Only applies when
|
||||
/// `#rust-analyzer.hoverActions.enable#` is set.
|
||||
hoverActions_debug: bool = "true",
|
||||
@@ -163,8 +169,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",
|
||||
@@ -734,7 +738,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
|
||||
@@ -747,6 +751,7 @@ impl Config {
|
||||
&[]
|
||||
)
|
||||
.contains(&MarkupKind::Markdown),
|
||||
documentation: self.data.hover_documentation,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,6 +861,7 @@ macro_rules! _config_data {
|
||||
$({
|
||||
let field = stringify!($field);
|
||||
let ty = stringify!($ty);
|
||||
|
||||
(field, ty, &[$($doc),*], $default)
|
||||
},)*
|
||||
])
|
||||
@@ -867,6 +873,7 @@ macro_rules! _config_data {
|
||||
$({
|
||||
let field = stringify!($field);
|
||||
let ty = stringify!($ty);
|
||||
|
||||
(field, ty, &[$($doc),*], $default)
|
||||
},)*
|
||||
])
|
||||
|
||||
@@ -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<lsp_ext::CommandLinkGroup> {
|
||||
if snap.config.hover().none() || !snap.config.hover_actions() {
|
||||
if snap.config.hover().no_actions() || !snap.config.hover_actions() {
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user