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 #[serde(default)]
258 pub create_new_window: bool,
259}
260
261impl_actions!(projects, [OpenRecent, OpenRemote]);
262
263/// Where to spawn the task in the UI.
264#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
265#[serde(rename_all = "snake_case")]
266pub enum RevealTarget {
267 /// In the central pane group, "main" editor area.
268 Center,
269 /// In the terminal dock, "regular" terminal items' place.
270 #[default]
271 Dock,
272}
273
274/// Spawn a task with name or open tasks modal.
275#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema)]
276#[serde(untagged)]
277pub enum Spawn {
278 /// Spawns a task by the name given.
279 ByName {
280 task_name: String,
281 #[serde(default)]
282 reveal_target: Option<RevealTarget>,
283 },
284 /// Spawns a task by the name given.
285 ByTag {
286 task_tag: String,
287 #[serde(default)]
288 reveal_target: Option<RevealTarget>,
289 },
290 /// Spawns a task via modal's selection.
291 ViaModal {
292 /// Selected task's `reveal_target` property override.
293 #[serde(default)]
294 reveal_target: Option<RevealTarget>,
295 },
296}
297
298impl Spawn {
299 pub fn modal() -> Self {
300 Self::ViaModal {
301 reveal_target: None,
302 }
303 }
304}
305
306/// Rerun the last task.
307#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
308#[serde(deny_unknown_fields)]
309pub struct Rerun {
310 /// Controls whether the task context is reevaluated prior to execution of a task.
311 /// 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
312 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
313 /// default: false
314 #[serde(default)]
315 pub reevaluate_context: bool,
316 /// Overrides `allow_concurrent_runs` property of the task being reran.
317 /// Default: null
318 #[serde(default)]
319 pub allow_concurrent_runs: Option<bool>,
320 /// Overrides `use_new_terminal` property of the task being reran.
321 /// Default: null
322 #[serde(default)]
323 pub use_new_terminal: Option<bool>,
324
325 /// If present, rerun the task with this ID, otherwise rerun the last task.
326 #[serde(skip)]
327 pub task_id: Option<String>,
328}
329
330impl_actions!(task, [Spawn, Rerun]);
331
332pub mod outline {
333 use std::sync::OnceLock;
334
335 use gpui::{AnyView, App, Window, action_as};
336
337 action_as!(outline, ToggleOutline as Toggle);
338 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
339 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
340}
341
342actions!(zed_predict_onboarding, [OpenZedPredictOnboarding]);
343actions!(git_onboarding, [OpenGitIntegrationOnboarding]);
344
345actions!(debugger, [ToggleEnableBreakpoint, UnsetBreakpoint]);