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 OpenLicenses,
39 OpenTelemetryLog,
40 ]
41);
42
43#[derive(PartialEq, Clone, Copy, Debug, Deserialize, JsonSchema)]
44#[serde(rename_all = "snake_case")]
45pub enum ExtensionCategoryFilter {
46 Themes,
47 IconThemes,
48 Languages,
49 Grammars,
50 LanguageServers,
51 ContextServers,
52 SlashCommands,
53 IndexedDocsProviders,
54 Snippets,
55}
56
57#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
58pub struct Extensions {
59 /// Filters the extensions page down to extensions that are in the specified category.
60 #[serde(default)]
61 pub category_filter: Option<ExtensionCategoryFilter>,
62}
63
64#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
65pub struct DecreaseBufferFontSize {
66 #[serde(default)]
67 pub persist: bool,
68}
69
70#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
71pub struct IncreaseBufferFontSize {
72 #[serde(default)]
73 pub persist: bool,
74}
75
76#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
77pub struct ResetBufferFontSize {
78 #[serde(default)]
79 pub persist: bool,
80}
81
82#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
83pub struct DecreaseUiFontSize {
84 #[serde(default)]
85 pub persist: bool,
86}
87
88#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
89pub struct IncreaseUiFontSize {
90 #[serde(default)]
91 pub persist: bool,
92}
93
94#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
95pub struct ResetUiFontSize {
96 #[serde(default)]
97 pub persist: bool,
98}
99
100impl_actions!(
101 zed,
102 [
103 Extensions,
104 DecreaseBufferFontSize,
105 IncreaseBufferFontSize,
106 ResetBufferFontSize,
107 DecreaseUiFontSize,
108 IncreaseUiFontSize,
109 ResetUiFontSize,
110 ]
111);
112
113pub mod workspace {
114 use gpui::action_with_deprecated_aliases;
115
116 action_with_deprecated_aliases!(
117 workspace,
118 CopyPath,
119 [
120 "editor::CopyPath",
121 "outline_panel::CopyPath",
122 "project_panel::CopyPath"
123 ]
124 );
125
126 action_with_deprecated_aliases!(
127 workspace,
128 CopyRelativePath,
129 [
130 "editor::CopyRelativePath",
131 "outline_panel::CopyRelativePath",
132 "project_panel::CopyRelativePath"
133 ]
134 );
135}
136
137pub mod git {
138 use gpui::{action_with_deprecated_aliases, actions};
139
140 actions!(git, [CheckoutBranch, Switch, SelectRepo]);
141 action_with_deprecated_aliases!(git, Branch, ["branches::OpenRecent"]);
142}
143
144pub mod command_palette {
145 use gpui::actions;
146
147 actions!(command_palette, [Toggle]);
148}
149
150pub mod feedback {
151 use gpui::actions;
152
153 actions!(feedback, [FileBugReport, GiveFeedback]);
154}
155
156pub mod theme_selector {
157 use gpui::impl_actions;
158 use schemars::JsonSchema;
159 use serde::Deserialize;
160
161 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
162 #[serde(deny_unknown_fields)]
163 pub struct Toggle {
164 /// A list of theme names to filter the theme selector down to.
165 pub themes_filter: Option<Vec<String>>,
166 }
167
168 impl_actions!(theme_selector, [Toggle]);
169}
170
171pub mod icon_theme_selector {
172 use gpui::impl_actions;
173 use schemars::JsonSchema;
174 use serde::Deserialize;
175
176 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
177 #[serde(deny_unknown_fields)]
178 pub struct Toggle {
179 /// A list of icon theme names to filter the theme selector down to.
180 pub themes_filter: Option<Vec<String>>,
181 }
182
183 impl_actions!(icon_theme_selector, [Toggle]);
184}
185
186pub mod agent {
187 use gpui::actions;
188
189 actions!(
190 agent,
191 [OpenConfiguration, OpenOnboardingModal, ResetOnboarding]
192 );
193}
194
195pub mod assistant {
196 use gpui::{
197 action_with_deprecated_aliases, actions, impl_action_with_deprecated_aliases, impl_actions,
198 };
199 use schemars::JsonSchema;
200 use serde::Deserialize;
201 use uuid::Uuid;
202
203 action_with_deprecated_aliases!(agent, ToggleFocus, ["assistant::ToggleFocus"]);
204
205 actions!(assistant, [ShowConfiguration]);
206
207 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
208 #[serde(deny_unknown_fields)]
209 pub struct OpenRulesLibrary {
210 #[serde(skip)]
211 pub prompt_to_select: Option<Uuid>,
212 }
213
214 impl_action_with_deprecated_aliases!(
215 agent,
216 OpenRulesLibrary,
217 [
218 "assistant::OpenRulesLibrary",
219 "assistant::DeployPromptLibrary"
220 ]
221 );
222
223 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema)]
224 #[serde(deny_unknown_fields)]
225 pub struct InlineAssist {
226 pub prompt: Option<String>,
227 }
228
229 impl_actions!(assistant, [InlineAssist]);
230}
231
232#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
233#[serde(deny_unknown_fields)]
234pub struct OpenRecent {
235 #[serde(default)]
236 pub create_new_window: bool,
237}
238
239impl_actions!(projects, [OpenRecent]);
240actions!(projects, [OpenRemote]);
241
242/// Where to spawn the task in the UI.
243#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
244#[serde(rename_all = "snake_case")]
245pub enum RevealTarget {
246 /// In the central pane group, "main" editor area.
247 Center,
248 /// In the terminal dock, "regular" terminal items' place.
249 #[default]
250 Dock,
251}
252
253/// Spawn a task with name or open tasks modal.
254#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema)]
255#[serde(untagged)]
256pub enum Spawn {
257 /// Spawns a task by the name given.
258 ByName {
259 task_name: String,
260 #[serde(default)]
261 reveal_target: Option<RevealTarget>,
262 },
263 /// Spawns a task by the name given.
264 ByTag {
265 task_tag: String,
266 #[serde(default)]
267 reveal_target: Option<RevealTarget>,
268 },
269 /// Spawns a task via modal's selection.
270 ViaModal {
271 /// Selected task's `reveal_target` property override.
272 #[serde(default)]
273 reveal_target: Option<RevealTarget>,
274 },
275}
276
277impl Spawn {
278 pub fn modal() -> Self {
279 Self::ViaModal {
280 reveal_target: None,
281 }
282 }
283}
284
285/// Rerun the last task.
286#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
287#[serde(deny_unknown_fields)]
288pub struct Rerun {
289 /// Controls whether the task context is reevaluated prior to execution of a task.
290 /// 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
291 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
292 /// default: false
293 #[serde(default)]
294 pub reevaluate_context: bool,
295 /// Overrides `allow_concurrent_runs` property of the task being reran.
296 /// Default: null
297 #[serde(default)]
298 pub allow_concurrent_runs: Option<bool>,
299 /// Overrides `use_new_terminal` property of the task being reran.
300 /// Default: null
301 #[serde(default)]
302 pub use_new_terminal: Option<bool>,
303
304 /// If present, rerun the task with this ID, otherwise rerun the last task.
305 #[serde(skip)]
306 pub task_id: Option<String>,
307}
308
309impl_actions!(task, [Spawn, Rerun]);
310
311pub mod outline {
312 use std::sync::OnceLock;
313
314 use gpui::{AnyView, App, Window, action_as};
315
316 action_as!(outline, ToggleOutline as Toggle);
317 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
318 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
319}
320
321actions!(zed_predict_onboarding, [OpenZedPredictOnboarding]);
322actions!(git_onboarding, [OpenGitIntegrationOnboarding]);