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