mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
honor content_format clientcap
This removes all markdown when the client does not support the markdown MarkupKind Otherwise the output on the editor will have some markdown boilerplate, making it less readable
This commit is contained in:
parent
e5f252ade7
commit
c3cc361294
5 changed files with 74 additions and 9 deletions
|
@ -14,7 +14,7 @@ use ide::{
|
|||
AssistConfig, CompletionConfig, DiagnosticsConfig, HoverConfig, InlayHintsConfig,
|
||||
MergeBehaviour,
|
||||
};
|
||||
use lsp_types::ClientCapabilities;
|
||||
use lsp_types::{ClientCapabilities, MarkupKind};
|
||||
use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest};
|
||||
use rustc_hash::FxHashSet;
|
||||
use serde::Deserialize;
|
||||
|
@ -327,6 +327,7 @@ impl Config {
|
|||
debug: data.hoverActions_enable && data.hoverActions_debug,
|
||||
goto_type_def: data.hoverActions_enable && data.hoverActions_gotoTypeDef,
|
||||
links_in_hover: data.hoverActions_linksInHover,
|
||||
markdown: true,
|
||||
};
|
||||
|
||||
log::info!("Config::update() = {:#?}", self);
|
||||
|
@ -334,6 +335,9 @@ impl Config {
|
|||
|
||||
pub fn update_caps(&mut self, caps: &ClientCapabilities) {
|
||||
if let Some(doc_caps) = caps.text_document.as_ref() {
|
||||
if let Some(value) = doc_caps.hover.as_ref().and_then(|it| it.content_format.as_ref()) {
|
||||
self.hover.markdown = value.contains(&MarkupKind::Markdown)
|
||||
}
|
||||
if let Some(value) = doc_caps.definition.as_ref().and_then(|it| it.link_support) {
|
||||
self.client_caps.location_link = value;
|
||||
}
|
||||
|
|
|
@ -618,7 +618,11 @@ pub(crate) fn handle_hover(
|
|||
) -> Result<Option<lsp_ext::Hover>> {
|
||||
let _p = profile::span("handle_hover");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position_params)?;
|
||||
let info = match snap.analysis.hover(position, snap.config.hover.links_in_hover)? {
|
||||
let info = match snap.analysis.hover(
|
||||
position,
|
||||
snap.config.hover.links_in_hover,
|
||||
snap.config.hover.markdown,
|
||||
)? {
|
||||
None => return Ok(None),
|
||||
Some(info) => info,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue