-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:anilsenay/zed into go-runnables
- Loading branch information
Showing
36 changed files
with
1,748 additions
and
889 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "assistant_slash_command" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
license = "GPL-3.0-or-later" | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[lib] | ||
path = "src/assistant_slash_command.rs" | ||
|
||
[dependencies] | ||
anyhow.workspace = true | ||
collections.workspace = true | ||
derive_more.workspace = true | ||
futures.workspace = true | ||
gpui.workspace = true | ||
parking_lot.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../LICENSE-GPL |
50 changes: 50 additions & 0 deletions
50
crates/assistant_slash_command/src/assistant_slash_command.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
mod slash_command_registry; | ||
|
||
use std::sync::atomic::AtomicBool; | ||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
use futures::channel::oneshot; | ||
use gpui::{AppContext, Task}; | ||
|
||
pub use slash_command_registry::*; | ||
|
||
pub fn init(cx: &mut AppContext) { | ||
SlashCommandRegistry::default_global(cx); | ||
} | ||
|
||
pub trait SlashCommand: 'static + Send + Sync { | ||
fn name(&self) -> String; | ||
fn description(&self) -> String; | ||
fn complete_argument( | ||
&self, | ||
query: String, | ||
cancel: Arc<AtomicBool>, | ||
cx: &mut AppContext, | ||
) -> Task<Result<Vec<String>>>; | ||
fn requires_argument(&self) -> bool; | ||
fn run(&self, argument: Option<&str>, cx: &mut AppContext) -> SlashCommandInvocation; | ||
} | ||
|
||
pub struct SlashCommandInvocation { | ||
pub output: Task<Result<String>>, | ||
pub invalidated: oneshot::Receiver<()>, | ||
pub cleanup: SlashCommandCleanup, | ||
} | ||
|
||
#[derive(Default)] | ||
pub struct SlashCommandCleanup(Option<Box<dyn FnOnce()>>); | ||
|
||
impl SlashCommandCleanup { | ||
pub fn new(cleanup: impl FnOnce() + 'static) -> Self { | ||
Self(Some(Box::new(cleanup))) | ||
} | ||
} | ||
|
||
impl Drop for SlashCommandCleanup { | ||
fn drop(&mut self) { | ||
if let Some(cleanup) = self.0.take() { | ||
cleanup(); | ||
} | ||
} | ||
} |
Oops, something went wrong.