Add support for insert_text_mode of a completion (#28171)

I wanted this for CONL (https://conl.dev )'s nascent langauge server,
and it seems like most of the support was already wired up on the LSP
side, so this surfaces it into the editor.

Release Notes:

- Added support for the `insert_text_mode` field of completions from the
language server protocol.
This commit is contained in:
Conrad Irwin 2025-04-07 10:35:11 -06:00 committed by GitHub
parent 5a7222edc5
commit a577a72f69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 91 additions and 4 deletions

View file

@ -8053,6 +8053,7 @@ impl LspStore {
runs: Default::default(),
filter_range: Default::default(),
},
insert_text_mode: None,
icon_path: None,
confirm: None,
}]))),
@ -9342,6 +9343,7 @@ async fn populate_labels_for_completions(
documentation,
old_range: completion.old_range,
new_text: completion.new_text,
insert_text_mode: lsp_completion.insert_text_mode,
source: completion.source,
icon_path: None,
confirm: None,
@ -9356,6 +9358,7 @@ async fn populate_labels_for_completions(
old_range: completion.old_range,
new_text: completion.new_text,
source: completion.source,
insert_text_mode: None,
icon_path: None,
confirm: None,
});

View file

@ -68,8 +68,8 @@ use language::{
language_settings::InlayHintKind, proto::split_operations,
};
use lsp::{
CodeActionKind, CompletionContext, CompletionItemKind, DocumentHighlightKind, LanguageServerId,
LanguageServerName, MessageActionItem,
CodeActionKind, CompletionContext, CompletionItemKind, DocumentHighlightKind, InsertTextMode,
LanguageServerId, LanguageServerName, MessageActionItem,
};
use lsp_command::*;
use lsp_store::{CompletionDocumentation, LspFormatTarget, OpenLspBufferHandle};
@ -392,6 +392,8 @@ pub struct Completion {
pub source: CompletionSource,
/// A path to an icon for this completion that is shown in the menu.
pub icon_path: Option<SharedString>,
/// Whether to adjust indentation (the default) or not.
pub insert_text_mode: Option<InsertTextMode>,
/// An optional callback to invoke when this completion is confirmed.
/// Returns, whether new completions should be retriggered after the current one.
/// If `true` is returned, the editor will show a new completion menu after this completion is confirmed.