settings_content.rs

   1mod agent;
   2mod editor;
   3mod extension;
   4mod fallible_options;
   5mod language;
   6mod language_model;
   7pub mod merge_from;
   8mod project;
   9mod serde_helper;
  10mod terminal;
  11mod theme;
  12mod title_bar;
  13mod workspace;
  14
  15pub use agent::*;
  16pub use editor::*;
  17pub use extension::*;
  18pub use fallible_options::*;
  19pub use language::*;
  20pub use language_model::*;
  21pub use merge_from::MergeFrom as MergeFromTrait;
  22pub use project::*;
  23use serde::de::DeserializeOwned;
  24pub use serde_helper::{
  25    serialize_f32_with_two_decimal_places, serialize_optional_f32_with_two_decimal_places,
  26};
  27use settings_json::parse_json_with_comments;
  28pub use terminal::*;
  29pub use theme::*;
  30pub use title_bar::*;
  31pub use workspace::*;
  32
  33use collections::{HashMap, IndexMap};
  34use schemars::JsonSchema;
  35use serde::{Deserialize, Serialize};
  36use settings_macros::{MergeFrom, with_fallible_options};
  37
  38/// Defines a settings override struct where each field is
  39/// `Option<Box<SettingsContent>>`, along with:
  40/// - `OVERRIDE_KEYS`: a `&[&str]` of the field names (the JSON keys)
  41/// - `get_by_key(&self, key) -> Option<&SettingsContent>`: accessor by key
  42///
  43/// The field list is the single source of truth for the override key strings.
  44macro_rules! settings_overrides {
  45    (
  46        $(#[$attr:meta])*
  47        pub struct $name:ident { $($field:ident),* $(,)? }
  48    ) => {
  49        $(#[$attr])*
  50        pub struct $name {
  51            $(pub $field: Option<Box<SettingsContent>>,)*
  52        }
  53
  54        impl $name {
  55            /// The JSON override keys, derived from the field names on this struct.
  56            pub const OVERRIDE_KEYS: &[&str] = &[$(stringify!($field)),*];
  57
  58            /// Look up an override by its JSON key name.
  59            pub fn get_by_key(&self, key: &str) -> Option<&SettingsContent> {
  60                match key {
  61                    $(stringify!($field) => self.$field.as_deref(),)*
  62                    _ => None,
  63                }
  64            }
  65        }
  66    }
  67}
  68use std::collections::{BTreeMap, BTreeSet};
  69use std::hash::Hash;
  70use std::sync::Arc;
  71pub use util::serde::default_true;
  72
  73#[derive(Debug, Clone, PartialEq, Eq)]
  74pub enum ParseStatus {
  75    /// Settings were parsed successfully
  76    Success,
  77    /// Settings failed to parse
  78    Failed { error: String },
  79}
  80
  81#[with_fallible_options]
  82#[derive(Debug, PartialEq, Default, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
  83pub struct SettingsContent {
  84    #[serde(flatten)]
  85    pub project: ProjectSettingsContent,
  86
  87    #[serde(flatten)]
  88    pub theme: Box<ThemeSettingsContent>,
  89
  90    #[serde(flatten)]
  91    pub extension: ExtensionSettingsContent,
  92
  93    #[serde(flatten)]
  94    pub workspace: WorkspaceSettingsContent,
  95
  96    #[serde(flatten)]
  97    pub editor: EditorSettingsContent,
  98
  99    #[serde(flatten)]
 100    pub remote: RemoteSettingsContent,
 101
 102    /// Settings related to the file finder.
 103    pub file_finder: Option<FileFinderSettingsContent>,
 104
 105    pub git_panel: Option<GitPanelSettingsContent>,
 106
 107    pub tabs: Option<ItemSettingsContent>,
 108    pub tab_bar: Option<TabBarSettingsContent>,
 109    pub status_bar: Option<StatusBarSettingsContent>,
 110
 111    pub preview_tabs: Option<PreviewTabsSettingsContent>,
 112
 113    pub agent: Option<AgentSettingsContent>,
 114    pub agent_servers: Option<AllAgentServersSettings>,
 115
 116    /// Configuration of audio in Zed.
 117    pub audio: Option<AudioSettingsContent>,
 118
 119    /// Whether or not to automatically check for updates.
 120    ///
 121    /// Default: true
 122    pub auto_update: Option<bool>,
 123
 124    /// This base keymap settings adjusts the default keybindings in Zed to be similar
 125    /// to other common code editors. By default, Zed's keymap closely follows VSCode's
 126    /// keymap, with minor adjustments, this corresponds to the "VSCode" setting.
 127    ///
 128    /// Default: VSCode
 129    pub base_keymap: Option<BaseKeymapContent>,
 130
 131    /// Configuration for the collab panel visual settings.
 132    pub collaboration_panel: Option<PanelSettingsContent>,
 133
 134    pub debugger: Option<DebuggerSettingsContent>,
 135
 136    /// Configuration for Diagnostics-related features.
 137    pub diagnostics: Option<DiagnosticsSettingsContent>,
 138
 139    /// Configuration for Git-related features
 140    pub git: Option<GitSettings>,
 141
 142    /// Common language server settings.
 143    pub global_lsp_settings: Option<GlobalLspSettingsContent>,
 144
 145    /// The settings for the image viewer.
 146    pub image_viewer: Option<ImageViewerSettingsContent>,
 147
 148    pub repl: Option<ReplSettingsContent>,
 149
 150    /// Whether or not to enable Helix mode.
 151    ///
 152    /// Default: false
 153    pub helix_mode: Option<bool>,
 154
 155    pub journal: Option<JournalSettingsContent>,
 156
 157    /// A map of log scopes to the desired log level.
 158    /// Useful for filtering out noisy logs or enabling more verbose logging.
 159    ///
 160    /// Example: {"log": {"client": "warn"}}
 161    pub log: Option<HashMap<String, String>>,
 162
 163    pub line_indicator_format: Option<LineIndicatorFormat>,
 164
 165    pub language_models: Option<AllLanguageModelSettingsContent>,
 166
 167    pub outline_panel: Option<OutlinePanelSettingsContent>,
 168
 169    pub project_panel: Option<ProjectPanelSettingsContent>,
 170
 171    /// Configuration for the Message Editor
 172    pub message_editor: Option<MessageEditorSettings>,
 173
 174    /// Configuration for Node-related features
 175    pub node: Option<NodeBinarySettings>,
 176
 177    /// Configuration for the Notification Panel
 178    pub notification_panel: Option<NotificationPanelSettingsContent>,
 179
 180    pub proxy: Option<String>,
 181
 182    /// The URL of the Zed server to connect to.
 183    pub server_url: Option<String>,
 184
 185    /// Configuration for session-related features
 186    pub session: Option<SessionSettingsContent>,
 187    /// Control what info is collected by Zed.
 188    pub telemetry: Option<TelemetrySettingsContent>,
 189
 190    /// Configuration of the terminal in Zed.
 191    pub terminal: Option<TerminalSettingsContent>,
 192
 193    pub title_bar: Option<TitleBarSettingsContent>,
 194
 195    /// Whether or not to enable Vim mode.
 196    ///
 197    /// Default: false
 198    pub vim_mode: Option<bool>,
 199
 200    // Settings related to calls in Zed
 201    pub calls: Option<CallSettingsContent>,
 202
 203    /// Settings for the which-key popup.
 204    pub which_key: Option<WhichKeySettingsContent>,
 205
 206    /// Settings related to Vim mode in Zed.
 207    pub vim: Option<VimSettingsContent>,
 208
 209    /// Number of lines to search for modelines at the beginning and end of files.
 210    /// Modelines contain editor directives (e.g., vim/emacs settings) that configure
 211    /// the editor behavior for specific files.
 212    ///
 213    /// Default: 5
 214    pub modeline_lines: Option<usize>,
 215}
 216
 217impl SettingsContent {
 218    pub fn languages_mut(&mut self) -> &mut HashMap<String, LanguageSettingsContent> {
 219        &mut self.project.all_languages.languages.0
 220    }
 221}
 222
 223// These impls are there to optimize builds by avoiding monomorphization downstream. Yes, they're repetitive, but using default impls
 224// break the optimization, for whatever reason.
 225pub trait RootUserSettings: Sized + DeserializeOwned {
 226    fn parse_json(json: &str) -> (Option<Self>, ParseStatus);
 227    fn parse_json_with_comments(json: &str) -> anyhow::Result<Self>;
 228}
 229
 230impl RootUserSettings for SettingsContent {
 231    fn parse_json(json: &str) -> (Option<Self>, ParseStatus) {
 232        fallible_options::parse_json(json)
 233    }
 234    fn parse_json_with_comments(json: &str) -> anyhow::Result<Self> {
 235        parse_json_with_comments(json)
 236    }
 237}
 238// Explicit opt-in instead of blanket impl to avoid monomorphizing downstream. Just a hunch though.
 239impl RootUserSettings for Option<SettingsContent> {
 240    fn parse_json(json: &str) -> (Option<Self>, ParseStatus) {
 241        fallible_options::parse_json(json)
 242    }
 243    fn parse_json_with_comments(json: &str) -> anyhow::Result<Self> {
 244        parse_json_with_comments(json)
 245    }
 246}
 247impl RootUserSettings for UserSettingsContent {
 248    fn parse_json(json: &str) -> (Option<Self>, ParseStatus) {
 249        fallible_options::parse_json(json)
 250    }
 251    fn parse_json_with_comments(json: &str) -> anyhow::Result<Self> {
 252        parse_json_with_comments(json)
 253    }
 254}
 255
 256settings_overrides! {
 257    #[with_fallible_options]
 258    #[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
 259    pub struct ReleaseChannelOverrides { dev, nightly, preview, stable }
 260}
 261
 262settings_overrides! {
 263    #[with_fallible_options]
 264    #[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
 265    pub struct PlatformOverrides { macos, linux, windows }
 266}
 267
 268/// Determines what settings a profile starts from before applying its overrides.
 269#[derive(
 270    Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom,
 271)]
 272#[serde(rename_all = "snake_case")]
 273pub enum ProfileBase {
 274    /// Apply profile settings on top of the user's current settings.
 275    #[default]
 276    User,
 277    /// Apply profile settings on top of Zed's default settings, ignoring user customizations.
 278    Default,
 279}
 280
 281/// A named settings profile that can temporarily override settings.
 282#[with_fallible_options]
 283#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
 284pub struct SettingsProfile {
 285    /// What base settings to start from before applying this profile's overrides.
 286    ///
 287    /// - `user`: Apply on top of user's settings (default)
 288    /// - `default`: Apply on top of Zed's default settings, ignoring user customizations
 289    #[serde(default)]
 290    pub base: ProfileBase,
 291
 292    /// The settings overrides for this profile.
 293    #[serde(default)]
 294    pub settings: Box<SettingsContent>,
 295}
 296
 297#[with_fallible_options]
 298#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)]
 299pub struct UserSettingsContent {
 300    #[serde(flatten)]
 301    pub content: Box<SettingsContent>,
 302
 303    #[serde(flatten)]
 304    pub release_channel_overrides: ReleaseChannelOverrides,
 305
 306    #[serde(flatten)]
 307    pub platform_overrides: PlatformOverrides,
 308
 309    #[serde(default)]
 310    pub profiles: IndexMap<String, SettingsProfile>,
 311}
 312
 313pub struct ExtensionsSettingsContent {
 314    pub all_languages: AllLanguageSettingsContent,
 315}
 316
 317/// Base key bindings scheme. Base keymaps can be overridden with user keymaps.
 318///
 319/// Default: VSCode
 320#[derive(
 321    Copy,
 322    Clone,
 323    Debug,
 324    Serialize,
 325    Deserialize,
 326    JsonSchema,
 327    MergeFrom,
 328    PartialEq,
 329    Eq,
 330    Default,
 331    strum::VariantArray,
 332)]
 333pub enum BaseKeymapContent {
 334    #[default]
 335    VSCode,
 336    JetBrains,
 337    SublimeText,
 338    Atom,
 339    TextMate,
 340    Emacs,
 341    Cursor,
 342    None,
 343}
 344
 345impl strum::VariantNames for BaseKeymapContent {
 346    const VARIANTS: &'static [&'static str] = &[
 347        "VSCode",
 348        "JetBrains",
 349        "Sublime Text",
 350        "Atom",
 351        "TextMate",
 352        "Emacs",
 353        "Cursor",
 354        "None",
 355    ];
 356}
 357
 358/// Configuration of audio in Zed.
 359#[with_fallible_options]
 360#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
 361pub struct AudioSettingsContent {
 362    /// Automatically increase or decrease you microphone's volume. This affects how
 363    /// loud you sound to others.
 364    ///
 365    /// Recommended: off (default)
 366    /// Microphones are too quite in zed, until everyone is on experimental
 367    /// audio and has auto speaker volume on this will make you very loud
 368    /// compared to other speakers.
 369    #[serde(rename = "experimental.auto_microphone_volume")]
 370    pub auto_microphone_volume: Option<bool>,
 371    /// Remove background noises. Works great for typing, cars, dogs, AC. Does
 372    /// not work well on music.
 373    /// Select specific output audio device.
 374    #[serde(rename = "experimental.output_audio_device")]
 375    pub output_audio_device: Option<AudioOutputDeviceName>,
 376    /// Select specific input audio device.
 377    #[serde(rename = "experimental.input_audio_device")]
 378    pub input_audio_device: Option<AudioInputDeviceName>,
 379}
 380
 381#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
 382#[serde(transparent)]
 383pub struct AudioOutputDeviceName(pub Option<String>);
 384
 385impl AsRef<Option<String>> for AudioInputDeviceName {
 386    fn as_ref(&self) -> &Option<String> {
 387        &self.0
 388    }
 389}
 390
 391impl From<Option<String>> for AudioInputDeviceName {
 392    fn from(value: Option<String>) -> Self {
 393        Self(value)
 394    }
 395}
 396
 397#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
 398#[serde(transparent)]
 399pub struct AudioInputDeviceName(pub Option<String>);
 400
 401impl AsRef<Option<String>> for AudioOutputDeviceName {
 402    fn as_ref(&self) -> &Option<String> {
 403        &self.0
 404    }
 405}
 406
 407impl From<Option<String>> for AudioOutputDeviceName {
 408    fn from(value: Option<String>) -> Self {
 409        Self(value)
 410    }
 411}
 412
 413/// Control what info is collected by Zed.
 414#[with_fallible_options]
 415#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Debug, MergeFrom)]
 416pub struct TelemetrySettingsContent {
 417    /// Send debug info like crash reports.
 418    ///
 419    /// Default: true
 420    pub diagnostics: Option<bool>,
 421    /// Send anonymized usage data like what languages you're using Zed with.
 422    ///
 423    /// Default: true
 424    pub metrics: Option<bool>,
 425}
 426
 427impl Default for TelemetrySettingsContent {
 428    fn default() -> Self {
 429        Self {
 430            diagnostics: Some(true),
 431            metrics: Some(true),
 432        }
 433    }
 434}
 435
 436#[with_fallible_options]
 437#[derive(Default, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Clone, MergeFrom)]
 438pub struct DebuggerSettingsContent {
 439    /// Determines the stepping granularity.
 440    ///
 441    /// Default: line
 442    pub stepping_granularity: Option<SteppingGranularity>,
 443    /// Whether the breakpoints should be reused across Zed sessions.
 444    ///
 445    /// Default: true
 446    pub save_breakpoints: Option<bool>,
 447    /// Whether to show the debug button in the status bar.
 448    ///
 449    /// Default: true
 450    pub button: Option<bool>,
 451    /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
 452    ///
 453    /// Default: 2000ms
 454    pub timeout: Option<u64>,
 455    /// Whether to log messages between active debug adapters and Zed
 456    ///
 457    /// Default: true
 458    pub log_dap_communications: Option<bool>,
 459    /// Whether to format dap messages in when adding them to debug adapter logger
 460    ///
 461    /// Default: true
 462    pub format_dap_log_messages: Option<bool>,
 463    /// The dock position of the debug panel
 464    ///
 465    /// Default: Bottom
 466    pub dock: Option<DockPosition>,
 467}
 468
 469/// The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.
 470#[derive(
 471    PartialEq,
 472    Eq,
 473    Debug,
 474    Hash,
 475    Clone,
 476    Copy,
 477    Deserialize,
 478    Serialize,
 479    JsonSchema,
 480    MergeFrom,
 481    strum::VariantArray,
 482    strum::VariantNames,
 483)]
 484#[serde(rename_all = "snake_case")]
 485pub enum SteppingGranularity {
 486    /// The step should allow the program to run until the current statement has finished executing.
 487    /// The meaning of a statement is determined by the adapter and it may be considered equivalent to a line.
 488    /// For example 'for(int i = 0; i < 10; i++)' could be considered to have 3 statements 'int i = 0', 'i < 10', and 'i++'.
 489    Statement,
 490    /// The step should allow the program to run until the current source line has executed.
 491    Line,
 492    /// The step should allow one instruction to execute (e.g. one x86 instruction).
 493    Instruction,
 494}
 495
 496#[derive(
 497    Copy,
 498    Clone,
 499    Debug,
 500    Serialize,
 501    Deserialize,
 502    JsonSchema,
 503    MergeFrom,
 504    PartialEq,
 505    Eq,
 506    strum::VariantArray,
 507    strum::VariantNames,
 508)]
 509#[serde(rename_all = "snake_case")]
 510pub enum DockPosition {
 511    Left,
 512    Bottom,
 513    Right,
 514}
 515
 516/// Configuration of voice calls in Zed.
 517#[with_fallible_options]
 518#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
 519pub struct CallSettingsContent {
 520    /// Whether the microphone should be muted when joining a channel or a call.
 521    ///
 522    /// Default: false
 523    pub mute_on_join: Option<bool>,
 524
 525    /// Whether your current project should be shared when joining an empty channel.
 526    ///
 527    /// Default: false
 528    pub share_on_join: Option<bool>,
 529}
 530
 531#[with_fallible_options]
 532#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
 533pub struct GitPanelSettingsContent {
 534    /// Whether to show the panel button in the status bar.
 535    ///
 536    /// Default: true
 537    pub button: Option<bool>,
 538    /// Where to dock the panel.
 539    ///
 540    /// Default: left
 541    pub dock: Option<DockPosition>,
 542    /// Default width of the panel in pixels.
 543    ///
 544    /// Default: 360
 545    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
 546    pub default_width: Option<f32>,
 547    /// How entry statuses are displayed.
 548    ///
 549    /// Default: icon
 550    pub status_style: Option<StatusStyle>,
 551
 552    /// Whether to show file icons in the git panel.
 553    ///
 554    /// Default: false
 555    pub file_icons: Option<bool>,
 556
 557    /// Whether to show folder icons or chevrons for directories in the git panel.
 558    ///
 559    /// Default: true
 560    pub folder_icons: Option<bool>,
 561
 562    /// How and when the scrollbar should be displayed.
 563    ///
 564    /// Default: inherits editor scrollbar settings
 565    pub scrollbar: Option<ScrollbarSettings>,
 566
 567    /// What the default branch name should be when
 568    /// `init.defaultBranch` is not set in git
 569    ///
 570    /// Default: main
 571    pub fallback_branch_name: Option<String>,
 572
 573    /// Whether to sort entries in the panel by path
 574    /// or by status (the default).
 575    ///
 576    /// Default: false
 577    pub sort_by_path: Option<bool>,
 578
 579    /// Whether to collapse untracked files in the diff panel.
 580    ///
 581    /// Default: false
 582    pub collapse_untracked_diff: Option<bool>,
 583
 584    /// Whether to show entries with tree or flat view in the panel
 585    ///
 586    /// Default: false
 587    pub tree_view: Option<bool>,
 588
 589    /// Whether to show the addition/deletion change count next to each file in the Git panel.
 590    ///
 591    /// Default: true
 592    pub diff_stats: Option<bool>,
 593
 594    /// Whether to show a badge on the git panel icon with the count of uncommitted changes.
 595    ///
 596    /// Default: false
 597    pub show_count_badge: Option<bool>,
 598
 599    /// Whether the git panel should open on startup.
 600    ///
 601    /// Default: false
 602    pub starts_open: Option<bool>,
 603}
 604
 605#[derive(
 606    Default,
 607    Copy,
 608    Clone,
 609    Debug,
 610    Serialize,
 611    Deserialize,
 612    JsonSchema,
 613    MergeFrom,
 614    PartialEq,
 615    Eq,
 616    strum::VariantArray,
 617    strum::VariantNames,
 618)]
 619#[serde(rename_all = "snake_case")]
 620pub enum StatusStyle {
 621    #[default]
 622    Icon,
 623    LabelColor,
 624}
 625
 626#[with_fallible_options]
 627#[derive(
 628    Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq,
 629)]
 630pub struct ScrollbarSettings {
 631    pub show: Option<ShowScrollbar>,
 632}
 633
 634#[with_fallible_options]
 635#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
 636pub struct NotificationPanelSettingsContent {
 637    /// Whether to show the panel button in the status bar.
 638    ///
 639    /// Default: true
 640    pub button: Option<bool>,
 641    /// Where to dock the panel.
 642    ///
 643    /// Default: right
 644    pub dock: Option<DockPosition>,
 645    /// Default width of the panel in pixels.
 646    ///
 647    /// Default: 300
 648    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
 649    pub default_width: Option<f32>,
 650    /// Whether to show a badge on the notification panel icon with the count of unread notifications.
 651    ///
 652    /// Default: false
 653    pub show_count_badge: Option<bool>,
 654}
 655
 656#[with_fallible_options]
 657#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
 658pub struct PanelSettingsContent {
 659    /// Whether to show the panel button in the status bar.
 660    ///
 661    /// Default: true
 662    pub button: Option<bool>,
 663    /// Where to dock the panel.
 664    ///
 665    /// Default: left
 666    pub dock: Option<DockPosition>,
 667    /// Default width of the panel in pixels.
 668    ///
 669    /// Default: 240
 670    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
 671    pub default_width: Option<f32>,
 672}
 673
 674#[with_fallible_options]
 675#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
 676pub struct MessageEditorSettings {
 677    /// Whether to automatically replace emoji shortcodes with emoji characters.
 678    /// For example: typing `:wave:` gets replaced with `👋`.
 679    ///
 680    /// Default: false
 681    pub auto_replace_emoji_shortcode: Option<bool>,
 682}
 683
 684#[with_fallible_options]
 685#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
 686pub struct FileFinderSettingsContent {
 687    /// Whether to show file icons in the file finder.
 688    ///
 689    /// Default: true
 690    pub file_icons: Option<bool>,
 691    /// Determines how much space the file finder can take up in relation to the available window width.
 692    ///
 693    /// Default: small
 694    pub modal_max_width: Option<FileFinderWidthContent>,
 695    /// Determines whether the file finder should skip focus for the active file in search results.
 696    ///
 697    /// Default: true
 698    pub skip_focus_for_active_in_search: Option<bool>,
 699    /// Whether to use gitignored files when searching.
 700    /// Only the file Zed had indexed will be used, not necessary all the gitignored files.
 701    ///
 702    /// Default: Smart
 703    pub include_ignored: Option<IncludeIgnoredContent>,
 704    /// Whether to include text channels in file finder results.
 705    ///
 706    /// Default: false
 707    pub include_channels: Option<bool>,
 708}
 709
 710#[derive(
 711    Debug,
 712    PartialEq,
 713    Eq,
 714    Clone,
 715    Copy,
 716    Default,
 717    Serialize,
 718    Deserialize,
 719    JsonSchema,
 720    MergeFrom,
 721    strum::VariantArray,
 722    strum::VariantNames,
 723)]
 724#[serde(rename_all = "snake_case")]
 725pub enum IncludeIgnoredContent {
 726    /// Use all gitignored files
 727    All,
 728    /// Use only the files Zed had indexed
 729    Indexed,
 730    /// Be smart and search for ignored when called from a gitignored worktree
 731    #[default]
 732    Smart,
 733}
 734
 735#[derive(
 736    Debug,
 737    PartialEq,
 738    Eq,
 739    Clone,
 740    Copy,
 741    Default,
 742    Serialize,
 743    Deserialize,
 744    JsonSchema,
 745    MergeFrom,
 746    strum::VariantArray,
 747    strum::VariantNames,
 748)]
 749#[serde(rename_all = "lowercase")]
 750pub enum FileFinderWidthContent {
 751    #[default]
 752    Small,
 753    Medium,
 754    Large,
 755    XLarge,
 756    Full,
 757}
 758
 759#[with_fallible_options]
 760#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Debug, JsonSchema, MergeFrom)]
 761pub struct VimSettingsContent {
 762    pub default_mode: Option<ModeContent>,
 763    pub toggle_relative_line_numbers: Option<bool>,
 764    pub use_system_clipboard: Option<UseSystemClipboard>,
 765    pub use_smartcase_find: Option<bool>,
 766    /// When enabled, the `:substitute` command replaces all matches in a line
 767    /// by default. The 'g' flag then toggles this behavior.,
 768    pub gdefault: Option<bool>,
 769    pub custom_digraphs: Option<HashMap<String, Arc<str>>>,
 770    pub highlight_on_yank_duration: Option<u64>,
 771    pub cursor_shape: Option<CursorShapeSettings>,
 772}
 773
 774#[derive(
 775    Copy,
 776    Clone,
 777    Default,
 778    Serialize,
 779    Deserialize,
 780    JsonSchema,
 781    MergeFrom,
 782    PartialEq,
 783    Debug,
 784    strum::VariantArray,
 785    strum::VariantNames,
 786)]
 787#[serde(rename_all = "snake_case")]
 788pub enum ModeContent {
 789    #[default]
 790    Normal,
 791    Insert,
 792}
 793
 794/// Controls when to use system clipboard.
 795#[derive(
 796    Copy,
 797    Clone,
 798    Debug,
 799    Serialize,
 800    Deserialize,
 801    PartialEq,
 802    Eq,
 803    JsonSchema,
 804    MergeFrom,
 805    strum::VariantArray,
 806    strum::VariantNames,
 807)]
 808#[serde(rename_all = "snake_case")]
 809pub enum UseSystemClipboard {
 810    /// Don't use system clipboard.
 811    Never,
 812    /// Use system clipboard.
 813    Always,
 814    /// Use system clipboard for yank operations.
 815    OnYank,
 816}
 817
 818/// Cursor shape configuration for insert mode in Vim.
 819#[derive(
 820    Copy,
 821    Clone,
 822    Debug,
 823    Serialize,
 824    Deserialize,
 825    PartialEq,
 826    Eq,
 827    JsonSchema,
 828    MergeFrom,
 829    strum::VariantArray,
 830    strum::VariantNames,
 831)]
 832#[serde(rename_all = "snake_case")]
 833pub enum VimInsertModeCursorShape {
 834    /// Inherit cursor shape from the editor's base cursor_shape setting.
 835    Inherit,
 836    /// Vertical bar cursor.
 837    Bar,
 838    /// Block cursor that surrounds the character.
 839    Block,
 840    /// Underline cursor.
 841    Underline,
 842    /// Hollow box cursor.
 843    Hollow,
 844}
 845
 846/// The settings for cursor shape.
 847#[with_fallible_options]
 848#[derive(
 849    Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom,
 850)]
 851pub struct CursorShapeSettings {
 852    /// Cursor shape for the normal mode.
 853    ///
 854    /// Default: block
 855    pub normal: Option<CursorShape>,
 856    /// Cursor shape for the replace mode.
 857    ///
 858    /// Default: underline
 859    pub replace: Option<CursorShape>,
 860    /// Cursor shape for the visual mode.
 861    ///
 862    /// Default: block
 863    pub visual: Option<CursorShape>,
 864    /// Cursor shape for the insert mode.
 865    ///
 866    /// The default value follows the primary cursor_shape.
 867    pub insert: Option<VimInsertModeCursorShape>,
 868}
 869
 870/// Settings specific to journaling
 871#[with_fallible_options]
 872#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 873pub struct JournalSettingsContent {
 874    /// The path of the directory where journal entries are stored.
 875    ///
 876    /// Default: `~`
 877    pub path: Option<String>,
 878    /// What format to display the hours in.
 879    ///
 880    /// Default: hour12
 881    pub hour_format: Option<HourFormat>,
 882}
 883
 884#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 885#[serde(rename_all = "snake_case")]
 886pub enum HourFormat {
 887    #[default]
 888    Hour12,
 889    Hour24,
 890}
 891
 892#[with_fallible_options]
 893#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq)]
 894pub struct OutlinePanelSettingsContent {
 895    /// Whether to show the outline panel button in the status bar.
 896    ///
 897    /// Default: true
 898    pub button: Option<bool>,
 899    /// Customize default width (in pixels) taken by outline panel
 900    ///
 901    /// Default: 240
 902    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
 903    pub default_width: Option<f32>,
 904    /// The position of outline panel
 905    ///
 906    /// Default: left
 907    pub dock: Option<DockSide>,
 908    /// Whether to show file icons in the outline panel.
 909    ///
 910    /// Default: true
 911    pub file_icons: Option<bool>,
 912    /// Whether to show folder icons or chevrons for directories in the outline panel.
 913    ///
 914    /// Default: true
 915    pub folder_icons: Option<bool>,
 916    /// Whether to show the git status in the outline panel.
 917    ///
 918    /// Default: true
 919    pub git_status: Option<bool>,
 920    /// Amount of indentation (in pixels) for nested items.
 921    ///
 922    /// Default: 20
 923    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
 924    pub indent_size: Option<f32>,
 925    /// Whether to reveal it in the outline panel automatically,
 926    /// when a corresponding project entry becomes active.
 927    /// Gitignored entries are never auto revealed.
 928    ///
 929    /// Default: true
 930    pub auto_reveal_entries: Option<bool>,
 931    /// Whether to fold directories automatically
 932    /// when directory has only one directory inside.
 933    ///
 934    /// Default: true
 935    pub auto_fold_dirs: Option<bool>,
 936    /// Settings related to indent guides in the outline panel.
 937    pub indent_guides: Option<IndentGuidesSettingsContent>,
 938    /// Scrollbar-related settings
 939    pub scrollbar: Option<ScrollbarSettingsContent>,
 940    /// Default depth to expand outline items in the current file.
 941    /// The default depth to which outline entries are expanded on reveal.
 942    /// - Set to 0 to collapse all items that have children
 943    /// - Set to 1 or higher to collapse items at that depth or deeper
 944    ///
 945    /// Default: 100
 946    pub expand_outlines_with_depth: Option<usize>,
 947}
 948
 949#[derive(
 950    Clone,
 951    Copy,
 952    Debug,
 953    PartialEq,
 954    Eq,
 955    Serialize,
 956    Deserialize,
 957    JsonSchema,
 958    MergeFrom,
 959    strum::VariantArray,
 960    strum::VariantNames,
 961)]
 962#[serde(rename_all = "snake_case")]
 963pub enum DockSide {
 964    Left,
 965    Right,
 966}
 967
 968#[derive(
 969    Copy,
 970    Clone,
 971    Debug,
 972    PartialEq,
 973    Eq,
 974    Deserialize,
 975    Serialize,
 976    JsonSchema,
 977    MergeFrom,
 978    strum::VariantArray,
 979    strum::VariantNames,
 980)]
 981#[serde(rename_all = "snake_case")]
 982pub enum ShowIndentGuides {
 983    Always,
 984    Never,
 985}
 986
 987#[with_fallible_options]
 988#[derive(
 989    Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq, Default,
 990)]
 991pub struct IndentGuidesSettingsContent {
 992    /// When to show the scrollbar in the outline panel.
 993    pub show: Option<ShowIndentGuides>,
 994}
 995
 996#[derive(Clone, Copy, Default, PartialEq, Debug, JsonSchema, MergeFrom, Deserialize, Serialize)]
 997#[serde(rename_all = "snake_case")]
 998pub enum LineIndicatorFormat {
 999    Short,
1000    #[default]
1001    Long,
1002}
1003
1004/// The settings for the image viewer.
1005#[with_fallible_options]
1006#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, Default, PartialEq)]
1007pub struct ImageViewerSettingsContent {
1008    /// The unit to use for displaying image file sizes.
1009    ///
1010    /// Default: "binary"
1011    pub unit: Option<ImageFileSizeUnit>,
1012}
1013
1014#[with_fallible_options]
1015#[derive(
1016    Clone,
1017    Copy,
1018    Debug,
1019    Serialize,
1020    Deserialize,
1021    JsonSchema,
1022    MergeFrom,
1023    Default,
1024    PartialEq,
1025    strum::VariantArray,
1026    strum::VariantNames,
1027)]
1028#[serde(rename_all = "snake_case")]
1029pub enum ImageFileSizeUnit {
1030    /// Displays file size in binary units (e.g., KiB, MiB).
1031    #[default]
1032    Binary,
1033    /// Displays file size in decimal units (e.g., KB, MB).
1034    Decimal,
1035}
1036
1037#[with_fallible_options]
1038#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
1039pub struct RemoteSettingsContent {
1040    pub ssh_connections: Option<Vec<SshConnection>>,
1041    pub wsl_connections: Option<Vec<WslConnection>>,
1042    pub dev_container_connections: Option<Vec<DevContainerConnection>>,
1043    pub read_ssh_config: Option<bool>,
1044    pub use_podman: Option<bool>,
1045}
1046
1047#[with_fallible_options]
1048#[derive(
1049    Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom, Hash,
1050)]
1051pub struct DevContainerConnection {
1052    pub name: String,
1053    pub remote_user: String,
1054    pub container_id: String,
1055    pub use_podman: bool,
1056    pub extension_ids: Vec<String>,
1057    pub remote_env: BTreeMap<String, String>,
1058}
1059
1060#[with_fallible_options]
1061#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
1062pub struct SshConnection {
1063    pub host: String,
1064    pub username: Option<String>,
1065    pub port: Option<u16>,
1066    #[serde(default)]
1067    pub args: Vec<String>,
1068    #[serde(default)]
1069    pub projects: collections::BTreeSet<RemoteProject>,
1070    /// Name to use for this server in UI.
1071    pub nickname: Option<String>,
1072    // By default Zed will download the binary to the host directly.
1073    // If this is set to true, Zed will download the binary to your local machine,
1074    // and then upload it over the SSH connection. Useful if your SSH server has
1075    // limited outbound internet access.
1076    pub upload_binary_over_ssh: Option<bool>,
1077
1078    pub port_forwards: Option<Vec<SshPortForwardOption>>,
1079    /// Timeout in seconds for SSH connection and downloading the remote server binary.
1080    /// Defaults to 10 seconds if not specified.
1081    pub connection_timeout: Option<u16>,
1082}
1083
1084#[derive(Clone, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom, Debug)]
1085pub struct WslConnection {
1086    pub distro_name: String,
1087    pub user: Option<String>,
1088    #[serde(default)]
1089    pub projects: BTreeSet<RemoteProject>,
1090}
1091
1092#[with_fallible_options]
1093#[derive(
1094    Clone, Debug, Default, Serialize, PartialEq, Eq, PartialOrd, Ord, Deserialize, JsonSchema,
1095)]
1096pub struct RemoteProject {
1097    pub paths: Vec<String>,
1098}
1099
1100#[with_fallible_options]
1101#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize, JsonSchema, MergeFrom)]
1102pub struct SshPortForwardOption {
1103    pub local_host: Option<String>,
1104    pub local_port: u16,
1105    pub remote_host: Option<String>,
1106    pub remote_port: u16,
1107}
1108
1109/// Settings for configuring REPL display and behavior.
1110#[with_fallible_options]
1111#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
1112pub struct ReplSettingsContent {
1113    /// Maximum number of lines to keep in REPL's scrollback buffer.
1114    /// Clamped with [4, 256] range.
1115    ///
1116    /// Default: 32
1117    pub max_lines: Option<usize>,
1118    /// Maximum number of columns to keep in REPL's scrollback buffer.
1119    /// Clamped with [20, 512] range.
1120    ///
1121    /// Default: 128
1122    pub max_columns: Option<usize>,
1123    /// Whether to show small single-line outputs inline instead of in a block.
1124    ///
1125    /// Default: true
1126    pub inline_output: Option<bool>,
1127    /// Maximum number of characters for an output to be shown inline.
1128    /// Only applies when `inline_output` is true.
1129    ///
1130    /// Default: 50
1131    pub inline_output_max_length: Option<usize>,
1132    /// Maximum number of lines of output to display before scrolling.
1133    /// Set to 0 to disable output height limits.
1134    ///
1135    /// Default: 0
1136    pub output_max_height_lines: Option<usize>,
1137}
1138
1139/// Settings for configuring the which-key popup behaviour.
1140#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
1141pub struct WhichKeySettingsContent {
1142    /// Whether to show the which-key popup when holding down key combinations
1143    ///
1144    /// Default: false
1145    pub enabled: Option<bool>,
1146    /// Delay in milliseconds before showing the which-key popup.
1147    ///
1148    /// Default: 700
1149    pub delay_ms: Option<u64>,
1150}
1151
1152// An ExtendingVec in the settings can only accumulate new values.
1153//
1154// This is useful for things like private files where you only want
1155// to allow new values to be added.
1156//
1157// Consider using a HashMap<String, bool> instead of this type
1158// (like auto_install_extensions) so that user settings files can both add
1159// and remove values from the set.
1160#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1161pub struct ExtendingVec<T>(pub Vec<T>);
1162
1163impl<T> Into<Vec<T>> for ExtendingVec<T> {
1164    fn into(self) -> Vec<T> {
1165        self.0
1166    }
1167}
1168impl<T> From<Vec<T>> for ExtendingVec<T> {
1169    fn from(vec: Vec<T>) -> Self {
1170        ExtendingVec(vec)
1171    }
1172}
1173
1174impl<T: Clone> merge_from::MergeFrom for ExtendingVec<T> {
1175    fn merge_from(&mut self, other: &Self) {
1176        self.0.extend_from_slice(other.0.as_slice());
1177    }
1178}
1179
1180// A SaturatingBool in the settings can only ever be set to true,
1181// later attempts to set it to false will be ignored.
1182//
1183// Used by `disable_ai`.
1184#[derive(Debug, Default, Copy, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1185pub struct SaturatingBool(pub bool);
1186
1187impl From<bool> for SaturatingBool {
1188    fn from(value: bool) -> Self {
1189        SaturatingBool(value)
1190    }
1191}
1192
1193impl From<SaturatingBool> for bool {
1194    fn from(value: SaturatingBool) -> bool {
1195        value.0
1196    }
1197}
1198
1199impl merge_from::MergeFrom for SaturatingBool {
1200    fn merge_from(&mut self, other: &Self) {
1201        self.0 |= other.0
1202    }
1203}
1204
1205#[derive(
1206    Copy,
1207    Clone,
1208    Default,
1209    Debug,
1210    PartialEq,
1211    Eq,
1212    PartialOrd,
1213    Ord,
1214    Serialize,
1215    Deserialize,
1216    MergeFrom,
1217    JsonSchema,
1218    derive_more::FromStr,
1219)]
1220#[serde(transparent)]
1221pub struct DelayMs(pub u64);
1222
1223impl From<u64> for DelayMs {
1224    fn from(n: u64) -> Self {
1225        Self(n)
1226    }
1227}
1228
1229impl std::fmt::Display for DelayMs {
1230    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1231        write!(f, "{}ms", self.0)
1232    }
1233}