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