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