diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index 846f151304..2e131eeac9 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs @@ -255,7 +255,7 @@ impl InlayHintKind { #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct InlayHint { - pub label: String, + pub label: InlayHintLabel, pub position: Position, pub kind: Option, pub tooltip: Option, @@ -263,6 +263,24 @@ pub struct InlayHint { pub padding_right: Option, } +#[derive(Debug, Deserialize, Serialize)] +#[serde(untagged)] +pub enum InlayHintLabel { + String(String), + Parts(Vec), +} + +#[derive(Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct InlayHintLabelPart { + pub value: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub tooltip: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub location: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub command: Option, +} pub enum Ssr {} impl Request for Ssr { diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 6db47cdb1f..fd6602624f 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -419,11 +419,11 @@ pub(crate) fn inlay_hint( inlay_hint: InlayHint, ) -> lsp_ext::InlayHint { lsp_ext::InlayHint { - label: match inlay_hint.kind { + label: lsp_ext::InlayHintLabel::String(match inlay_hint.kind { InlayKind::ParameterHint if render_colons => format!("{}:", inlay_hint.label), InlayKind::TypeHint if render_colons => format!(": {}", inlay_hint.label), _ => inlay_hint.label.to_string(), - }, + }), position: match inlay_hint.kind { InlayKind::ParameterHint => position(line_index, inlay_hint.range.start()), InlayKind::TypeHint | InlayKind::ChainingHint => { diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 9f1c7fe0a3..3091bdcbf0 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@