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 workspace {
115 use gpui::action_with_deprecated_aliases;
116
117 action_with_deprecated_aliases!(
118 workspace,
119 CopyPath,
120 [
121 "editor::CopyPath",
122 "outline_panel::CopyPath",
123 "project_panel::CopyPath"
124 ]
125 );
126
127 action_with_deprecated_aliases!(
128 workspace,
129 CopyRelativePath,
130 [
131 "editor::CopyRelativePath",
132 "outline_panel::CopyRelativePath",
133 "project_panel::CopyRelativePath"
134 ]
135 );
136}
137
138pub mod git {
139 use gpui::{action_with_deprecated_aliases, actions};
140
141 actions!(git, [CheckoutBranch, Switch, SelectRepo]);
142 action_with_deprecated_aliases!(git, Branch, ["branches::OpenRecent"]);
143}
144
145pub mod jj {
146 use gpui::actions;
147
148 actions!(jj, [BookmarkList]);
149}
150
151pub mod command_palette {
152 use gpui::actions;
153
154 actions!(command_palette, [Toggle]);
155}
156
157pub mod feedback {
158 use gpui::actions;
159
160 actions!(feedback, [FileBugReport, GiveFeedback]);
161}
162
163pub mod theme_selector {
164 use gpui::impl_actions;
165 use schemars::JsonSchema;
166 use serde::Deserialize;
167
168 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
169 #[serde(deny_unknown_fields)]
170 pub struct Toggle {
171 /// A list of theme names to filter the theme selector down to.
172 pub themes_filter: Option<Vec<String>>,
173 }
174
175 impl_actions!(theme_selector, [Toggle]);
176}
177
178pub mod icon_theme_selector {
179 use gpui::impl_actions;
180 use schemars::JsonSchema;
181 use serde::Deserialize;
182
183 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
184 #[serde(deny_unknown_fields)]
185 pub struct Toggle {
186 /// A list of icon theme names to filter the theme selector down to.
187 pub themes_filter: Option<Vec<String>>,
188 }
189
190 impl_actions!(icon_theme_selector, [Toggle]);
191}
192
193pub mod agent {
194 use gpui::actions;
195
196 actions!(
197 agent,
198 [OpenConfiguration, OpenOnboardingModal, ResetOnboarding]
199 );
200}
201
202pub mod assistant {
203 use gpui::{
204 action_with_deprecated_aliases, actions, impl_action_with_deprecated_aliases, impl_actions,
205 };
206 use schemars::JsonSchema;
207 use serde::Deserialize;
208 use uuid::Uuid;
209
210 action_with_deprecated_aliases!(agent, ToggleFocus, ["assistant::ToggleFocus"]);
211
212 actions!(assistant, [ShowConfiguration]);
213
214 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
215 #[serde(deny_unknown_fields)]
216 pub struct OpenRulesLibrary {
217 #[serde(skip)]
218 pub prompt_to_select: Option<Uuid>,
219 }
220
221 impl_action_with_deprecated_aliases!(
222 agent,
223 OpenRulesLibrary,
224 [
225 "assistant::OpenRulesLibrary",
226 "assistant::DeployPromptLibrary"
227 ]
228 );
229
230 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema)]
231 #[serde(deny_unknown_fields)]
232 pub struct InlineAssist {
233 pub prompt: Option<String>,
234 }
235
236 impl_actions!(assistant, [InlineAssist]);
237}
238
239#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
240#[serde(deny_unknown_fields)]
241pub struct OpenRecent {
242 #[serde(default)]
243 pub create_new_window: bool,
244}
245
246#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
247#[serde(deny_unknown_fields)]
248pub struct OpenRemote {
249 #[serde(default)]
250 pub from_existing_connection: bool,
251}
252
253impl_actions!(projects, [OpenRecent, OpenRemote]);
254
255/// Where to spawn the task in the UI.
256#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
257#[serde(rename_all = "snake_case")]
258pub enum RevealTarget {
259 /// In the central pane group, "main" editor area.
260 Center,
261 /// In the terminal dock, "regular" terminal items' place.
262 #[default]
263 Dock,
264}
265
266/// Spawn a task with name or open tasks modal.
267#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema)]
268#[serde(untagged)]
269pub enum Spawn {
270 /// Spawns a task by the name given.
271 ByName {
272 task_name: String,
273 #[serde(default)]
274 reveal_target: Option<RevealTarget>,
275 },
276 /// Spawns a task by the name given.
277 ByTag {
278 task_tag: String,
279 #[serde(default)]
280 reveal_target: Option<RevealTarget>,
281 },
282 /// Spawns a task via modal's selection.
283 ViaModal {
284 /// Selected task's `reveal_target` property override.
285 #[serde(default)]
286 reveal_target: Option<RevealTarget>,
287 },
288}
289
290impl Spawn {
291 pub fn modal() -> Self {
292 Self::ViaModal {
293 reveal_target: None,
294 }
295 }
296}
297
298/// Rerun the last task.
299#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
300#[serde(deny_unknown_fields)]
301pub struct Rerun {
302 /// Controls whether the task context is reevaluated prior to execution of a task.
303 /// 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
304 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
305 /// default: false
306 #[serde(default)]
307 pub reevaluate_context: bool,
308 /// Overrides `allow_concurrent_runs` property of the task being reran.
309 /// Default: null
310 #[serde(default)]
311 pub allow_concurrent_runs: Option<bool>,
312 /// Overrides `use_new_terminal` property of the task being reran.
313 /// Default: null
314 #[serde(default)]
315 pub use_new_terminal: Option<bool>,
316
317 /// If present, rerun the task with this ID, otherwise rerun the last task.
318 #[serde(skip)]
319 pub task_id: Option<String>,
320}
321
322impl_actions!(task, [Spawn, Rerun]);
323
324pub mod outline {
325 use std::sync::OnceLock;
326
327 use gpui::{AnyView, App, Window, action_as};
328
329 action_as!(outline, ToggleOutline as Toggle);
330 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
331 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
332}
333
334actions!(zed_predict_onboarding, [OpenZedPredictOnboarding]);
335actions!(git_onboarding, [OpenGitIntegrationOnboarding]);