# Allow defining slash commands in extensions \(\#12255\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/82f5f364224f06d5802dd3bd204d9e75f9cebf69)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 82f5f364224f06d5802dd3bd204d9e75f9cebf69

Requested commit: 82f5f364224f06d5802dd3bd204d9e75f9cebf69

Commit: 82f5f364224f06d5802dd3bd204d9e75f9cebf69

Tree: 601b507f0e696973ca451f32eef56422a6c2a7ca

Author: Marshall Bowers

Committer: GitHub

## Message

````
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
````

## Parents

- [055a13a9b6b2575dac36cfbee1cd71d039ac1a2e](https://git.cafe/gitcafe/zed/commit/055a13a9b6b2575dac36cfbee1cd71d039ac1a2e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/82f5f364224f06d5802dd3bd204d9e75f9cebf69?format=markdown)
