1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema)]
5pub struct WorkspaceSettingsContent {
6 /// Active pane styling settings.
7 pub active_pane_modifiers: Option<ActivePanelModifiers>,
8 /// Layout mode for the bottom dock
9 ///
10 /// Default: contained
11 pub bottom_dock_layout: Option<BottomDockLayout>,
12 /// Direction to split horizontally.
13 ///
14 /// Default: "up"
15 pub pane_split_direction_horizontal: Option<PaneSplitDirectionHorizontal>,
16 /// Direction to split vertically.
17 ///
18 /// Default: "left"
19 pub pane_split_direction_vertical: Option<PaneSplitDirectionVertical>,
20 /// Centered layout related settings.
21 pub centered_layout: Option<CenteredLayoutSettings>,
22 /// Whether or not to prompt the user to confirm before closing the application.
23 ///
24 /// Default: false
25 pub confirm_quit: Option<bool>,
26 /// Whether or not to show the call status icon in the status bar.
27 ///
28 /// Default: true
29 pub show_call_status_icon: Option<bool>,
30 /// When to automatically save edited buffers.
31 ///
32 /// Default: off
33 pub autosave: Option<AutosaveSetting>,
34 /// Controls previous session restoration in freshly launched Zed instance.
35 /// Values: none, last_workspace, last_session
36 /// Default: last_session
37 pub restore_on_startup: Option<RestoreOnStartupBehavior>,
38 /// Whether to attempt to restore previous file's state when opening it again.
39 /// The state is stored per pane.
40 /// When disabled, defaults are applied instead of the state restoration.
41 ///
42 /// E.g. for editors, selections, folds and scroll positions are restored, if the same file is closed and, later, opened again in the same pane.
43 /// When disabled, a single selection in the very beginning of the file, zero scroll position and no folds state is used as a default.
44 ///
45 /// Default: true
46 pub restore_on_file_reopen: Option<bool>,
47 /// The size of the workspace split drop targets on the outer edges.
48 /// Given as a fraction that will be multiplied by the smaller dimension of the workspace.
49 ///
50 /// Default: `0.2` (20% of the smaller dimension of the workspace)
51 pub drop_target_size: Option<f32>,
52 /// Whether to close the window when using 'close active item' on a workspace with no tabs
53 ///
54 /// Default: auto ("on" on macOS, "off" otherwise)
55 pub when_closing_with_no_tabs: Option<CloseWindowWhenNoItems>,
56 /// Whether to use the system provided dialogs for Open and Save As.
57 /// When set to false, Zed will use the built-in keyboard-first pickers.
58 ///
59 /// Default: true
60 pub use_system_path_prompts: Option<bool>,
61 /// Whether to use the system provided prompts.
62 /// When set to false, Zed will use the built-in prompts.
63 /// Note that this setting has no effect on Linux, where Zed will always
64 /// use the built-in prompts.
65 ///
66 /// Default: true
67 pub use_system_prompts: Option<bool>,
68 /// Aliases for the command palette. When you type a key in this map,
69 /// it will be assumed to equal the value.
70 ///
71 /// Default: true
72 pub command_aliases: Option<HashMap<String, String>>,
73 /// Maximum open tabs in a pane. Will not close an unsaved
74 /// tab. Set to `None` for unlimited tabs.
75 ///
76 /// Default: none
77 pub max_tabs: Option<NonZeroUsize>,
78 /// What to do when the last window is closed
79 ///
80 /// Default: auto (nothing on macOS, "app quit" otherwise)
81 pub on_last_window_closed: Option<OnLastWindowClosed>,
82 /// Whether to resize all the panels in a dock when resizing the dock.
83 ///
84 /// Default: ["left"]
85 pub resize_all_panels_in_dock: Option<Vec<DockPosition>>,
86 /// Whether to automatically close files that have been deleted on disk.
87 ///
88 /// Default: false
89 pub close_on_file_delete: Option<bool>,
90 /// Whether to allow windows to tab together based on the user’s tabbing preference (macOS only).
91 ///
92 /// Default: false
93 pub use_system_window_tabs: Option<bool>,
94 /// Whether to show padding for zoomed panels.
95 /// When enabled, zoomed bottom panels will have some top padding,
96 /// while zoomed left/right panels will have padding to the right/left (respectively).
97 ///
98 /// Default: true
99 pub zoomed_padding: Option<bool>,
100}
101
102#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
103pub struct ItemSettingsContent {
104 /// Whether to show the Git file status on a tab item.
105 ///
106 /// Default: false
107 pub git_status: Option<bool>,
108 /// Position of the close button in a tab.
109 ///
110 /// Default: right
111 pub close_position: Option<ClosePosition>,
112 /// Whether to show the file icon for a tab.
113 ///
114 /// Default: false
115 pub file_icons: Option<bool>,
116 /// What to do after closing the current tab.
117 ///
118 /// Default: history
119 pub activate_on_close: Option<ActivateOnClose>,
120 /// Which files containing diagnostic errors/warnings to mark in the tabs.
121 /// This setting can take the following three values:
122 ///
123 /// Default: off
124 pub show_diagnostics: Option<ShowDiagnostics>,
125 /// Whether to always show the close button on tabs.
126 ///
127 /// Default: false
128 pub show_close_button: Option<ShowCloseButton>,
129}
130
131#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
132pub struct PreviewTabsSettingsContent {
133 /// Whether to show opened editors as preview tabs.
134 /// Preview tabs do not stay open, are reused until explicitly set to be kept open opened (via double-click or editing) and show file names in italic.
135 ///
136 /// Default: true
137 pub enabled: Option<bool>,
138 /// Whether to open tabs in preview mode when selected from the file finder.
139 ///
140 /// Default: false
141 pub enable_preview_from_file_finder: Option<bool>,
142 /// Whether a preview tab gets replaced when code navigation is used to navigate away from the tab.
143 ///
144 /// Default: false
145 pub enable_preview_from_code_navigation: Option<bool>,
146}
147
148#[derive(Copy, Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema)]
149#[serde(rename_all = "lowercase")]
150pub enum ClosePosition {
151 Left,
152 #[default]
153 Right,
154}
155
156#[derive(Copy, Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema)]
157#[serde(rename_all = "lowercase")]
158pub enum ShowCloseButton {
159 Always,
160 #[default]
161 Hover,
162 Hidden,
163}
164
165#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
166#[serde(rename_all = "snake_case")]
167pub enum ShowDiagnostics {
168 #[default]
169 Off,
170 Errors,
171 All,
172}
173
174#[derive(Copy, Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema)]
175#[serde(rename_all = "snake_case")]
176pub enum ActivateOnClose {
177 #[default]
178 History,
179 Neighbour,
180 LeftNeighbour,
181}
182
183#[derive(Copy, Clone, PartialEq, Debug, Default, Serialize, Deserialize, JsonSchema)]
184#[serde(rename_all = "snake_case")]
185pub struct ActivePanelModifiers {
186 /// Size of the border surrounding the active pane.
187 /// When set to 0, the active pane doesn't have any border.
188 /// The border is drawn inset.
189 ///
190 /// Default: `0.0`
191 pub border_size: Option<f32>,
192 /// Opacity of inactive panels.
193 /// When set to 1.0, the inactive panes have the same opacity as the active one.
194 /// If set to 0, the inactive panes content will not be visible at all.
195 /// Values are clamped to the [0.0, 1.0] range.
196 ///
197 /// Default: `1.0`
198 pub inactive_opacity: Option<f32>,
199}
200
201#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema)]
202#[serde(rename_all = "snake_case")]
203pub enum BottomDockLayout {
204 /// Contained between the left and right docks
205 #[default]
206 Contained,
207 /// Takes up the full width of the window
208 Full,
209 /// Extends under the left dock while snapping to the right dock
210 LeftAligned,
211 /// Extends under the right dock while snapping to the left dock
212 RightAligned,
213}
214
215#[derive(Copy, Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema)]
216#[serde(rename_all = "snake_case")]
217pub enum CloseWindowWhenNoItems {
218 /// Match platform conventions by default, so "on" on macOS and "off" everywhere else
219 #[default]
220 PlatformDefault,
221 /// Close the window when there are no tabs
222 CloseWindow,
223 /// Leave the window open when there are no tabs
224 KeepWindowOpen,
225}
226
227impl CloseWindowWhenNoItems {
228 pub fn should_close(&self) -> bool {
229 match self {
230 CloseWindowWhenNoItems::PlatformDefault => cfg!(target_os = "macos"),
231 CloseWindowWhenNoItems::CloseWindow => true,
232 CloseWindowWhenNoItems::KeepWindowOpen => false,
233 }
234 }
235}
236
237#[derive(Copy, Clone, PartialEq, Eq, Default, Serialize, Deserialize, JsonSchema)]
238#[serde(rename_all = "snake_case")]
239pub enum RestoreOnStartupBehavior {
240 /// Always start with an empty editor
241 None,
242 /// Restore the workspace that was closed last.
243 LastWorkspace,
244 /// Restore all workspaces that were open when quitting Zed.
245 #[default]
246 LastSession,
247}
248
249#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
250pub struct TabBarSettingsContent {
251 /// Whether or not to show the tab bar in the editor.
252 ///
253 /// Default: true
254 pub show: Option<bool>,
255 /// Whether or not to show the navigation history buttons in the tab bar.
256 ///
257 /// Default: true
258 pub show_nav_history_buttons: Option<bool>,
259 /// Whether or not to show the tab bar buttons.
260 ///
261 /// Default: true
262 pub show_tab_bar_buttons: Option<bool>,
263}
264
265#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
266#[serde(rename_all = "snake_case")]
267pub enum AutosaveSetting {
268 /// Disable autosave.
269 Off,
270 /// Save after inactivity period of `milliseconds`.
271 AfterDelay { milliseconds: u64 },
272 /// Autosave when focus changes.
273 OnFocusChange,
274 /// Autosave when the active window changes.
275 OnWindowChange,
276}
277
278#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
279#[serde(rename_all = "snake_case")]
280pub enum PaneSplitDirectionHorizontal {
281 Up,
282 Down,
283}
284
285#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
286#[serde(rename_all = "snake_case")]
287pub enum PaneSplitDirectionVertical {
288 Left,
289 Right,
290}
291
292#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, SettingsUi)]
293#[serde(rename_all = "snake_case")]
294pub struct CenteredLayoutSettings {
295 /// The relative width of the left padding of the central pane from the
296 /// workspace when the centered layout is used.
297 ///
298 /// Default: 0.2
299 pub left_padding: Option<f32>,
300 // The relative width of the right padding of the central pane from the
301 // workspace when the centered layout is used.
302 ///
303 /// Default: 0.2
304 pub right_padding: Option<f32>,
305}