Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow defining slash commands in extensions #12255

Merged
merged 8 commits into from
May 24, 2024
Merged

Conversation

maxdeviant
Copy link
Member

@maxdeviant maxdeviant commented May 24, 2024

This PR adds initial support for defining slash commands for the Assistant from extensions.

Slash commands are defined in an extension's extension.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:

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

@maxdeviant maxdeviant self-assigned this May 24, 2024
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label May 24, 2024
@maxdeviant maxdeviant merged commit 82f5f36 into main May 24, 2024
9 checks passed
@maxdeviant maxdeviant deleted the extension-slash-commands branch May 24, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant