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!(agent, [OpenConfiguration]);
190}
191
192pub mod assistant {
193 use gpui::{actions, impl_action_with_deprecated_aliases, impl_actions};
194 use schemars::JsonSchema;
195 use serde::Deserialize;
196 use uuid::Uuid;
197
198 actions!(assistant, [ToggleFocus, ShowConfiguration]);
199
200 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
201 #[serde(deny_unknown_fields)]
202 pub struct OpenRulesLibrary {
203 #[serde(skip)]
204 pub prompt_to_select: Option<Uuid>,
205 }
206
207 impl_action_with_deprecated_aliases!(
208 assistant,
209 OpenRulesLibrary,
210 ["assistant::DeployPromptLibrary"]
211 );
212
213 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema)]
214 #[serde(deny_unknown_fields)]
215 pub struct InlineAssist {
216 pub prompt: Option<String>,
217 }
218
219 impl_actions!(assistant, [InlineAssist]);
220}
221
222#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
223#[serde(deny_unknown_fields)]
224pub struct OpenRecent {
225 #[serde(default)]
226 pub create_new_window: bool,
227}
228
229impl_actions!(projects, [OpenRecent]);
230actions!(projects, [OpenRemote]);
231
232/// Where to spawn the task in the UI.
233#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
234#[serde(rename_all = "snake_case")]
235pub enum RevealTarget {
236 /// In the central pane group, "main" editor area.
237 Center,
238 /// In the terminal dock, "regular" terminal items' place.
239 #[default]
240 Dock,
241}
242
243/// Spawn a task with name or open tasks modal.
244#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema)]
245#[serde(untagged)]
246pub enum Spawn {
247 /// Spawns a task by the name given.
248 ByName {
249 task_name: String,
250 #[serde(default)]
251 reveal_target: Option<RevealTarget>,
252 },
253 /// Spawns a task by the name given.
254 ByTag {
255 task_tag: String,
256 #[serde(default)]
257 reveal_target: Option<RevealTarget>,
258 },
259 /// Spawns a task via modal's selection.
260 ViaModal {
261 /// Selected task's `reveal_target` property override.
262 #[serde(default)]
263 reveal_target: Option<RevealTarget>,
264 },
265}
266
267impl Spawn {
268 pub fn modal() -> Self {
269 Self::ViaModal {
270 reveal_target: None,
271 }
272 }
273}
274
275/// Rerun the last task.
276#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
277#[serde(deny_unknown_fields)]
278pub struct Rerun {
279 /// Controls whether the task context is reevaluated prior to execution of a task.
280 /// 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
281 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
282 /// default: false
283 #[serde(default)]
284 pub reevaluate_context: bool,
285 /// Overrides `allow_concurrent_runs` property of the task being reran.
286 /// Default: null
287 #[serde(default)]
288 pub allow_concurrent_runs: Option<bool>,
289 /// Overrides `use_new_terminal` property of the task being reran.
290 /// Default: null
291 #[serde(default)]
292 pub use_new_terminal: Option<bool>,
293
294 /// If present, rerun the task with this ID, otherwise rerun the last task.
295 #[serde(skip)]
296 pub task_id: Option<String>,
297}
298
299impl_actions!(task, [Spawn, Rerun]);
300
301pub mod outline {
302 use std::sync::OnceLock;
303
304 use gpui::{AnyView, App, Window, action_as};
305
306 action_as!(outline, ToggleOutline as Toggle);
307 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
308 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
309}
310
311actions!(zed_predict_onboarding, [OpenZedPredictOnboarding]);
312actions!(git_onboarding, [OpenGitIntegrationOnboarding]);