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