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