lsp: Support deprecated completion item tag and advertise capability (#43000)

xdBronch created

Release Notes:

- N/A

Change summary

crates/editor/src/code_context_menus.rs | 12 +++++++++++-
crates/lsp/src/lsp.rs                   |  4 ++++
2 files changed, 15 insertions(+), 1 deletion(-)

Detailed changes

crates/editor/src/code_context_menus.rs 🔗

@@ -8,6 +8,7 @@ use gpui::{
 use itertools::Itertools;
 use language::CodeLabel;
 use language::{Buffer, LanguageName, LanguageRegistry};
+use lsp::CompletionItemTag;
 use markdown::{Markdown, MarkdownElement};
 use multi_buffer::{Anchor, ExcerptId};
 use ordered_float::OrderedFloat;
@@ -840,7 +841,16 @@ impl CompletionsMenu {
                                     if completion
                                         .source
                                         .lsp_completion(false)
-                                        .and_then(|lsp_completion| lsp_completion.deprecated)
+                                        .and_then(|lsp_completion| {
+                                            match (lsp_completion.deprecated, &lsp_completion.tags)
+                                            {
+                                                (Some(true), _) => Some(true),
+                                                (_, Some(tags)) => Some(
+                                                    tags.contains(&CompletionItemTag::DEPRECATED),
+                                                ),
+                                                _ => None,
+                                            }
+                                        })
                                         .unwrap_or(false)
                                     {
                                         highlight.strikethrough = Some(StrikethroughStyle {

crates/lsp/src/lsp.rs 🔗

@@ -764,6 +764,10 @@ impl LanguageServer {
                                     // "textEdit".to_string(),
                                 ],
                             }),
+                            deprecated_support: Some(true),
+                            tag_support: Some(TagSupport {
+                                value_set: vec![CompletionItemTag::DEPRECATED],
+                            }),
                             insert_replace_support: Some(true),
                             label_details_support: Some(true),
                             insert_text_mode_support: Some(InsertTextModeSupport {