zed_extension_api: Return structured slash command completions (#13879)
This PR updates the extension API to use structured slash command completions instead of plain strings. This allows slash commands defined in extensions to take advantage of the improvements made in #13876. Release Notes: - N/A
This commit is contained in:
parent
950e7e5414
commit
61e4b6413a
6 changed files with 39 additions and 15 deletions
|
@ -4,7 +4,7 @@ use std::fs;
|
|||
use zed::lsp::CompletionKind;
|
||||
use zed::{
|
||||
CodeLabel, CodeLabelSpan, HttpRequest, KeyValueStore, LanguageServerId, SlashCommand,
|
||||
SlashCommandOutput, SlashCommandOutputSection,
|
||||
SlashCommandArgumentCompletion, SlashCommandOutput, SlashCommandOutputSection,
|
||||
};
|
||||
use zed_extension_api::{self as zed, Result};
|
||||
|
||||
|
@ -154,12 +154,24 @@ impl zed::Extension for GleamExtension {
|
|||
&self,
|
||||
command: SlashCommand,
|
||||
_query: String,
|
||||
) -> Result<Vec<String>, String> {
|
||||
) -> Result<Vec<SlashCommandArgumentCompletion>, String> {
|
||||
match command.name.as_str() {
|
||||
"gleam-project" => Ok(vec![
|
||||
"apple".to_string(),
|
||||
"banana".to_string(),
|
||||
"cherry".to_string(),
|
||||
SlashCommandArgumentCompletion {
|
||||
label: "apple".to_string(),
|
||||
new_text: "Apple".to_string(),
|
||||
run_command: false,
|
||||
},
|
||||
SlashCommandArgumentCompletion {
|
||||
label: "banana".to_string(),
|
||||
new_text: "Banana".to_string(),
|
||||
run_command: false,
|
||||
},
|
||||
SlashCommandArgumentCompletion {
|
||||
label: "cherry".to_string(),
|
||||
new_text: "Cherry".to_string(),
|
||||
run_command: true,
|
||||
},
|
||||
]),
|
||||
_ => Ok(Vec::new()),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue