lib.rs

  1use gpui::{Action, 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/// Opens a URL in the system's default web browser.
 15#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
 16#[action(namespace = zed)]
 17#[serde(deny_unknown_fields)]
 18pub struct OpenBrowser {
 19    pub url: String,
 20}
 21
 22/// Opens a zed:// URL within the application.
 23#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
 24#[action(namespace = zed)]
 25#[serde(deny_unknown_fields)]
 26pub struct OpenZedUrl {
 27    pub url: String,
 28}
 29
 30/// Opens the keymap to either add a keybinding or change an existing one
 31#[derive(PartialEq, Clone, Default, Action, JsonSchema, Serialize, Deserialize)]
 32#[action(namespace = zed, no_json, no_register)]
 33pub struct ChangeKeybinding {
 34    pub action: String,
 35}
 36
 37actions!(
 38    zed,
 39    [
 40        /// Opens the settings editor.
 41        #[action(deprecated_aliases = ["zed_actions::OpenSettingsEditor"])]
 42        OpenSettings,
 43        /// Opens the settings JSON file.
 44        #[action(deprecated_aliases = ["zed_actions::OpenSettings"])]
 45        OpenSettingsFile,
 46        /// Opens project-specific settings.
 47        #[action(deprecated_aliases = ["zed_actions::OpenProjectSettings"])]
 48        OpenProjectSettings,
 49        /// Opens the default keymap file.
 50        OpenDefaultKeymap,
 51        /// Opens the user keymap file.
 52        #[action(deprecated_aliases = ["zed_actions::OpenKeymap"])]
 53        OpenKeymapFile,
 54        /// Opens the keymap editor.
 55        #[action(deprecated_aliases = ["zed_actions::OpenKeymapEditor"])]
 56        OpenKeymap,
 57        /// Opens account settings.
 58        OpenAccountSettings,
 59        /// Opens server settings.
 60        OpenServerSettings,
 61        /// Quits the application.
 62        Quit,
 63        /// Shows information about Zed.
 64        About,
 65        /// Opens the documentation website.
 66        OpenDocs,
 67        /// Views open source licenses.
 68        OpenLicenses,
 69        /// Opens the telemetry log.
 70        OpenTelemetryLog,
 71        /// Opens the performance profiler.
 72        OpenPerformanceProfiler,
 73        /// Opens the onboarding view.
 74        OpenOnboarding,
 75    ]
 76);
 77
 78#[derive(PartialEq, Clone, Copy, Debug, Deserialize, JsonSchema)]
 79#[serde(rename_all = "snake_case")]
 80pub enum ExtensionCategoryFilter {
 81    Themes,
 82    IconThemes,
 83    Languages,
 84    Grammars,
 85    LanguageServers,
 86    ContextServers,
 87    AgentServers,
 88    SlashCommands,
 89    IndexedDocsProviders,
 90    Snippets,
 91    DebugAdapters,
 92}
 93
 94/// Opens the extensions management interface.
 95#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
 96#[action(namespace = zed)]
 97#[serde(deny_unknown_fields)]
 98pub struct Extensions {
 99    /// Filters the extensions page down to extensions that are in the specified category.
100    #[serde(default)]
101    pub category_filter: Option<ExtensionCategoryFilter>,
102    /// Focuses just the extension with the specified ID.
103    #[serde(default)]
104    pub id: Option<String>,
105}
106
107/// Decreases the font size in the editor buffer.
108#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
109#[action(namespace = zed)]
110#[serde(deny_unknown_fields)]
111pub struct DecreaseBufferFontSize {
112    #[serde(default)]
113    pub persist: bool,
114}
115
116/// Increases the font size in the editor buffer.
117#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
118#[action(namespace = zed)]
119#[serde(deny_unknown_fields)]
120pub struct IncreaseBufferFontSize {
121    #[serde(default)]
122    pub persist: bool,
123}
124
125/// Increases the font size in the editor buffer.
126#[derive(PartialEq, Clone, Debug, Deserialize, JsonSchema, Action)]
127#[action(namespace = zed)]
128#[serde(deny_unknown_fields)]
129pub struct OpenSettingsAt {
130    /// A path to a specific setting (e.g. `theme.mode`)
131    pub path: String,
132}
133
134/// Resets the buffer font size to the default value.
135#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
136#[action(namespace = zed)]
137#[serde(deny_unknown_fields)]
138pub struct ResetBufferFontSize {
139    #[serde(default)]
140    pub persist: bool,
141}
142
143/// Decreases the font size of the user interface.
144#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
145#[action(namespace = zed)]
146#[serde(deny_unknown_fields)]
147pub struct DecreaseUiFontSize {
148    #[serde(default)]
149    pub persist: bool,
150}
151
152/// Increases the font size of the user interface.
153#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
154#[action(namespace = zed)]
155#[serde(deny_unknown_fields)]
156pub struct IncreaseUiFontSize {
157    #[serde(default)]
158    pub persist: bool,
159}
160
161/// Resets the UI font size to the default value.
162#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
163#[action(namespace = zed)]
164#[serde(deny_unknown_fields)]
165pub struct ResetUiFontSize {
166    #[serde(default)]
167    pub persist: bool,
168}
169
170/// Resets all zoom levels (UI and buffer font sizes, including in the agent panel) to their default values.
171#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
172#[action(namespace = zed)]
173#[serde(deny_unknown_fields)]
174pub struct ResetAllZoom {
175    #[serde(default)]
176    pub persist: bool,
177}
178
179pub mod dev {
180    use gpui::actions;
181
182    actions!(
183        dev,
184        [
185            /// Toggles the developer inspector for debugging UI elements.
186            ToggleInspector
187        ]
188    );
189}
190
191pub mod workspace {
192    use gpui::actions;
193
194    actions!(
195        workspace,
196        [
197            #[action(deprecated_aliases = ["editor::CopyPath", "outline_panel::CopyPath", "project_panel::CopyPath"])]
198            CopyPath,
199            #[action(deprecated_aliases = ["editor::CopyRelativePath", "outline_panel::CopyRelativePath", "project_panel::CopyRelativePath"])]
200            CopyRelativePath,
201            /// Opens the selected file with the system's default application.
202            #[action(deprecated_aliases = ["project_panel::OpenWithSystem"])]
203            OpenWithSystem,
204        ]
205    );
206}
207
208pub mod git {
209    use gpui::actions;
210
211    actions!(
212        git,
213        [
214            /// Checks out a different git branch.
215            CheckoutBranch,
216            /// Switches to a different git branch.
217            Switch,
218            /// Selects a different repository.
219            SelectRepo,
220            /// Filter remotes.
221            FilterRemotes,
222            /// Create a git remote.
223            CreateRemote,
224            /// Opens the git branch selector.
225            #[action(deprecated_aliases = ["branches::OpenRecent"])]
226            Branch,
227            /// Opens the git stash selector.
228            ViewStash,
229            /// Opens the git worktree selector.
230            Worktree
231        ]
232    );
233}
234
235pub mod toast {
236    use gpui::actions;
237
238    actions!(
239        toast,
240        [
241            /// Runs the action associated with a toast notification.
242            RunAction
243        ]
244    );
245}
246
247pub mod command_palette {
248    use gpui::actions;
249
250    actions!(
251        command_palette,
252        [
253            /// Toggles the command palette.
254            Toggle,
255        ]
256    );
257}
258
259pub mod project_panel {
260    use gpui::actions;
261
262    actions!(
263        project_panel,
264        [
265            /// Toggles focus on the project panel.
266            ToggleFocus
267        ]
268    );
269}
270pub mod feedback {
271    use gpui::actions;
272
273    actions!(
274        feedback,
275        [
276            /// Opens email client to send feedback to Zed support.
277            EmailZed,
278            /// Opens the bug report form.
279            FileBugReport,
280            /// Opens the feature request form.
281            RequestFeature
282        ]
283    );
284}
285
286pub mod theme_selector {
287    use gpui::Action;
288    use schemars::JsonSchema;
289    use serde::Deserialize;
290
291    /// Toggles the theme selector interface.
292    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
293    #[action(namespace = theme_selector)]
294    #[serde(deny_unknown_fields)]
295    pub struct Toggle {
296        /// A list of theme names to filter the theme selector down to.
297        pub themes_filter: Option<Vec<String>>,
298    }
299}
300
301pub mod icon_theme_selector {
302    use gpui::Action;
303    use schemars::JsonSchema;
304    use serde::Deserialize;
305
306    /// Toggles the icon theme selector interface.
307    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
308    #[action(namespace = icon_theme_selector)]
309    #[serde(deny_unknown_fields)]
310    pub struct Toggle {
311        /// A list of icon theme names to filter the theme selector down to.
312        pub themes_filter: Option<Vec<String>>,
313    }
314}
315
316pub mod settings_profile_selector {
317    use gpui::Action;
318    use schemars::JsonSchema;
319    use serde::Deserialize;
320
321    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
322    #[action(namespace = settings_profile_selector)]
323    pub struct Toggle;
324}
325
326pub mod agent {
327    use gpui::actions;
328
329    actions!(
330        agent,
331        [
332            /// Opens the agent settings panel.
333            #[action(deprecated_aliases = ["agent::OpenConfiguration"])]
334            OpenSettings,
335            /// Opens the agent onboarding modal.
336            OpenOnboardingModal,
337            /// Opens the ACP onboarding modal.
338            OpenAcpOnboardingModal,
339            /// Opens the Claude Code onboarding modal.
340            OpenClaudeCodeOnboardingModal,
341            /// Resets the agent onboarding state.
342            ResetOnboarding,
343            /// Starts a chat conversation with the agent.
344            Chat,
345            /// Toggles the language model selector dropdown.
346            #[action(deprecated_aliases = ["assistant::ToggleModelSelector", "assistant2::ToggleModelSelector"])]
347            ToggleModelSelector,
348            /// Triggers re-authentication on Gemini
349            ReauthenticateAgent,
350            /// Add the current selection as context for threads in the agent panel.
351            #[action(deprecated_aliases = ["assistant::QuoteSelection", "agent::QuoteSelection"])]
352            AddSelectionToThread,
353            /// Resets the agent panel zoom levels (agent UI and buffer font sizes).
354            ResetAgentZoom,
355            /// Toggles the utility/agent pane open/closed state.
356            ToggleAgentPane,
357            /// Pastes clipboard content without any formatting.
358            PasteRaw,
359        ]
360    );
361}
362
363pub mod assistant {
364    use gpui::{Action, actions};
365    use schemars::JsonSchema;
366    use serde::Deserialize;
367    use uuid::Uuid;
368
369    actions!(
370        agent,
371        [
372            #[action(deprecated_aliases = ["assistant::ToggleFocus"])]
373            ToggleFocus
374        ]
375    );
376
377    actions!(
378        assistant,
379        [
380            /// Shows the assistant configuration panel.
381            ShowConfiguration
382        ]
383    );
384
385    /// Opens the rules library for managing agent rules and prompts.
386    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
387    #[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
388    #[serde(deny_unknown_fields)]
389    pub struct OpenRulesLibrary {
390        #[serde(skip)]
391        pub prompt_to_select: Option<Uuid>,
392    }
393
394    /// Deploys the assistant interface with the specified configuration.
395    #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
396    #[action(namespace = assistant)]
397    #[serde(deny_unknown_fields)]
398    pub struct InlineAssist {
399        pub prompt: Option<String>,
400    }
401}
402
403pub mod debugger {
404    use gpui::actions;
405
406    actions!(
407        debugger,
408        [
409            /// Opens the debugger onboarding modal.
410            OpenOnboardingModal,
411            /// Resets the debugger onboarding state.
412            ResetOnboarding
413        ]
414    );
415}
416
417/// Opens the recent projects interface.
418#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
419#[action(namespace = projects)]
420#[serde(deny_unknown_fields)]
421pub struct OpenRecent {
422    #[serde(default)]
423    pub create_new_window: bool,
424}
425
426/// Creates a project from a selected template.
427#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
428#[action(namespace = projects)]
429#[serde(deny_unknown_fields)]
430pub struct OpenRemote {
431    #[serde(default)]
432    pub from_existing_connection: bool,
433    #[serde(default)]
434    pub create_new_window: bool,
435}
436
437/// Opens the dev container connection modal.
438#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
439#[action(namespace = projects)]
440#[serde(deny_unknown_fields)]
441pub struct OpenDevContainer;
442
443/// Where to spawn the task in the UI.
444#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
445#[serde(rename_all = "snake_case")]
446pub enum RevealTarget {
447    /// In the central pane group, "main" editor area.
448    Center,
449    /// In the terminal dock, "regular" terminal items' place.
450    #[default]
451    Dock,
452}
453
454/// Spawns a task with name or opens tasks modal.
455#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
456#[action(namespace = task)]
457#[serde(untagged)]
458pub enum Spawn {
459    /// Spawns a task by the name given.
460    ByName {
461        task_name: String,
462        #[serde(default)]
463        reveal_target: Option<RevealTarget>,
464    },
465    /// Spawns a task by the name given.
466    ByTag {
467        task_tag: String,
468        #[serde(default)]
469        reveal_target: Option<RevealTarget>,
470    },
471    /// Spawns a task via modal's selection.
472    ViaModal {
473        /// Selected task's `reveal_target` property override.
474        #[serde(default)]
475        reveal_target: Option<RevealTarget>,
476    },
477}
478
479impl Spawn {
480    pub fn modal() -> Self {
481        Self::ViaModal {
482            reveal_target: None,
483        }
484    }
485}
486
487/// Reruns the last task.
488#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
489#[action(namespace = task)]
490#[serde(deny_unknown_fields)]
491pub struct Rerun {
492    /// Controls whether the task context is reevaluated prior to execution of a task.
493    /// 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
494    /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
495    /// default: false
496    #[serde(default)]
497    pub reevaluate_context: bool,
498    /// Overrides `allow_concurrent_runs` property of the task being reran.
499    /// Default: null
500    #[serde(default)]
501    pub allow_concurrent_runs: Option<bool>,
502    /// Overrides `use_new_terminal` property of the task being reran.
503    /// Default: null
504    #[serde(default)]
505    pub use_new_terminal: Option<bool>,
506
507    /// If present, rerun the task with this ID, otherwise rerun the last task.
508    #[serde(skip)]
509    pub task_id: Option<String>,
510}
511
512pub mod outline {
513    use std::sync::OnceLock;
514
515    use gpui::{AnyView, App, Window, actions};
516
517    actions!(
518        outline,
519        [
520            #[action(name = "Toggle")]
521            ToggleOutline
522        ]
523    );
524    /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
525    pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
526}
527
528actions!(
529    zed_predict_onboarding,
530    [
531        /// Opens the Zed Predict onboarding modal.
532        OpenZedPredictOnboarding
533    ]
534);
535actions!(
536    git_onboarding,
537    [
538        /// Opens the git integration onboarding modal.
539        OpenGitIntegrationOnboarding
540    ]
541);
542
543actions!(
544    debug_panel,
545    [
546        /// Toggles focus on the debug panel.
547        ToggleFocus
548    ]
549);
550actions!(
551    debugger,
552    [
553        /// Toggles the enabled state of a breakpoint.
554        ToggleEnableBreakpoint,
555        /// Removes a breakpoint.
556        UnsetBreakpoint,
557        /// Opens the project debug tasks configuration.
558        OpenProjectDebugTasks,
559    ]
560);
561
562pub mod vim {
563    use gpui::actions;
564
565    actions!(
566        vim,
567        [
568            /// Opens the default keymap file.
569            OpenDefaultKeymap
570        ]
571    );
572}
573
574#[derive(Debug, Clone, PartialEq, Eq, Hash)]
575pub struct WslConnectionOptions {
576    pub distro_name: String,
577    pub user: Option<String>,
578}
579
580#[cfg(target_os = "windows")]
581pub mod wsl_actions {
582    use gpui::Action;
583    use schemars::JsonSchema;
584    use serde::Deserialize;
585
586    /// Opens a folder inside Wsl.
587    #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
588    #[action(namespace = projects)]
589    #[serde(deny_unknown_fields)]
590    pub struct OpenFolderInWsl {
591        #[serde(default)]
592        pub create_new_window: bool,
593    }
594
595    /// Open a wsl distro.
596    #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
597    #[action(namespace = projects)]
598    #[serde(deny_unknown_fields)]
599    pub struct OpenWsl {
600        #[serde(default)]
601        pub create_new_window: bool,
602    }
603}