Allow defining slash commands in extensions (#12255)
This PR adds initial support for defining slash commands for the
Assistant from extensions.
Slash commands are defined in an extension's `extension.toml`:
```toml
[slash_commands.gleam-project]
description = "Returns information about the current Gleam project."
requires_argument = false
```
and then executed via the `run_slash_command` method on the `Extension`
trait:
```rs
impl Extension for GleamExtension {
// ...
fn run_slash_command(
&self,
command: SlashCommand,
_argument: Option<String>,
worktree: &zed::Worktree,
) -> Result<Option<String>, String> {
match command.name.as_str() {
"gleam-project" => Ok(Some("Yayyy".to_string())),
command => Err(format!("unknown slash command: \"{command}\"")),
}
}
}
```
Release Notes:
- N/A
This commit is contained in:
@@ -11175,7 +11175,7 @@ impl<P: AsRef<Path>> From<(WorktreeId, P)> for ProjectPath {
|
||||
}
|
||||
}
|
||||
|
||||
struct ProjectLspAdapterDelegate {
|
||||
pub struct ProjectLspAdapterDelegate {
|
||||
project: WeakModel<Project>,
|
||||
worktree: worktree::Snapshot,
|
||||
fs: Arc<dyn Fs>,
|
||||
@@ -11185,7 +11185,11 @@ struct ProjectLspAdapterDelegate {
|
||||
}
|
||||
|
||||
impl ProjectLspAdapterDelegate {
|
||||
fn new(project: &Project, worktree: &Model<Worktree>, cx: &ModelContext<Project>) -> Arc<Self> {
|
||||
pub fn new(
|
||||
project: &Project,
|
||||
worktree: &Model<Worktree>,
|
||||
cx: &ModelContext<Project>,
|
||||
) -> Arc<Self> {
|
||||
Arc::new(Self {
|
||||
project: cx.weak_model(),
|
||||
worktree: worktree.read(cx).snapshot(),
|
||||
|
||||
Reference in New Issue
Block a user