1use gpui::{actions, impl_actions};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5// If the zed binary doesn't use anything in this crate, it will be optimized away
6// and the actions won't initialize. So we just provide an empty initialization function
7// to be called from main.
8//
9// These may provide relevant context:
10// https://github.com/rust-lang/rust/issues/47384
11// https://github.com/mmastrac/rust-ctor/issues/280
12pub fn init() {}
13
14#[derive(Clone, PartialEq, Deserialize, JsonSchema)]
15#[serde(deny_unknown_fields)]
16pub struct OpenBrowser {
17 pub url: String,
18}
19
20#[derive(Clone, PartialEq, Deserialize, JsonSchema)]
21#[serde(deny_unknown_fields)]
22pub struct OpenZedUrl {
23 pub url: String,
24}
25
26impl_actions!(zed, [OpenBrowser, OpenZedUrl]);
27
28actions!(
29 zed,
30 [
31 OpenSettings,
32 OpenDefaultKeymap,
33 OpenAccountSettings,
34 OpenServerSettings,
35 Quit,
36 OpenKeymap,
37 About,
38 Extensions,
39 OpenLicenses,
40 OpenTelemetryLog,
41 DecreaseBufferFontSize,
42 IncreaseBufferFontSize,
43 ResetBufferFontSize,
44 DecreaseUiFontSize,
45 IncreaseUiFontSize,
46 ResetUiFontSize,
47 ]
48);
49
50pub mod workspace {
51 use gpui::action_with_deprecated_aliases;
52
53 action_with_deprecated_aliases!(
54 workspace,
55 CopyPath,
56 [
57 "editor::CopyPath",
58 "outline_panel::CopyPath",
59 "project_panel::CopyPath"
60 ]
61 );
62
63 action_with_deprecated_aliases!(
64 workspace,
65 CopyRelativePath,
66 [
67 "editor::CopyRelativePath",
68 "outline_panel::CopyRelativePath",
69 "project_panel::CopyRelativePath"
70 ]
71 );
72}
73
74pub mod git {
75 use gpui::action_with_deprecated_aliases;
76
77 action_with_deprecated_aliases!(git, Branch, ["branches::OpenRecent"]);
78}
79
80pub mod command_palette {
81 use gpui::actions;
82
83 actions!(command_palette, [Toggle]);
84}
85
86pub mod feedback {
87 use gpui::actions;
88
89 actions!(feedback, [GiveFeedback]);
90}
91
92pub mod theme_selector {
93 use gpui::impl_actions;
94 use schemars::JsonSchema;
95 use serde::Deserialize;
96
97 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
98 #[serde(deny_unknown_fields)]
99 pub struct Toggle {
100 /// A list of theme names to filter the theme selector down to.
101 pub themes_filter: Option<Vec<String>>,
102 }
103
104 impl_actions!(theme_selector, [Toggle]);
105}
106
107pub mod icon_theme_selector {
108 use gpui::impl_actions;
109 use schemars::JsonSchema;
110 use serde::Deserialize;
111
112 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
113 #[serde(deny_unknown_fields)]
114 pub struct Toggle {
115 /// A list of icon theme names to filter the theme selector down to.
116 pub themes_filter: Option<Vec<String>>,
117 }
118
119 impl_actions!(icon_theme_selector, [Toggle]);
120}
121
122pub mod assistant {
123 use gpui::{actions, impl_actions};
124 use schemars::JsonSchema;
125 use serde::Deserialize;
126
127 actions!(assistant, [ToggleFocus, DeployPromptLibrary]);
128
129 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema)]
130 #[serde(deny_unknown_fields)]
131 pub struct InlineAssist {
132 pub prompt: Option<String>,
133 }
134
135 impl_actions!(assistant, [InlineAssist]);
136}
137
138#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
139#[serde(deny_unknown_fields)]
140pub struct OpenRecent {
141 #[serde(default)]
142 pub create_new_window: bool,
143}
144
145impl_actions!(projects, [OpenRecent]);
146actions!(projects, [OpenRemote]);
147
148/// Where to spawn the task in the UI.
149#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
150#[serde(rename_all = "snake_case")]
151pub enum RevealTarget {
152 /// In the central pane group, "main" editor area.
153 Center,
154 /// In the terminal dock, "regular" terminal items' place.
155 #[default]
156 Dock,
157}
158
159/// Spawn a task with name or open tasks modal.
160#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema)]
161#[serde(untagged)]
162pub enum Spawn {
163 /// Spawns a task by the name given.
164 ByName {
165 task_name: String,
166 #[serde(default)]
167 reveal_target: Option<RevealTarget>,
168 },
169 /// Spawns a task via modal's selection.
170 ViaModal {
171 /// Selected task's `reveal_target` property override.
172 #[serde(default)]
173 reveal_target: Option<RevealTarget>,
174 },
175}
176
177impl Spawn {
178 pub fn modal() -> Self {
179 Self::ViaModal {
180 reveal_target: None,
181 }
182 }
183}
184
185/// Rerun the last task.
186#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
187#[serde(deny_unknown_fields)]
188pub struct Rerun {
189 /// Controls whether the task context is reevaluated prior to execution of a task.
190 /// If it is not, environment variables such as ZED_COLUMN, ZED_FILE are gonna be the same as in the last execution of a task
191 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
192 /// default: false
193 #[serde(default)]
194 pub reevaluate_context: bool,
195 /// Overrides `allow_concurrent_runs` property of the task being reran.
196 /// Default: null
197 #[serde(default)]
198 pub allow_concurrent_runs: Option<bool>,
199 /// Overrides `use_new_terminal` property of the task being reran.
200 /// Default: null
201 #[serde(default)]
202 pub use_new_terminal: Option<bool>,
203
204 /// If present, rerun the task with this ID, otherwise rerun the last task.
205 #[serde(skip)]
206 pub task_id: Option<String>,
207}
208
209impl_actions!(task, [Spawn, Rerun]);
210
211pub mod outline {
212 use std::sync::OnceLock;
213
214 use gpui::{action_as, AnyView, App, Window};
215
216 action_as!(outline, ToggleOutline as Toggle);
217 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
218 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
219}
220
221actions!(zed_predict_onboarding, [OpenZedPredictOnboarding]);