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