file_finder_settings.rs

 1use anyhow::Result;
 2use schemars::JsonSchema;
 3use serde::{Deserialize, Serialize};
 4use settings::{Settings, SettingsKey, SettingsSources, SettingsUi};
 5
 6#[derive(Deserialize, Debug, Clone, Copy, PartialEq)]
 7pub struct FileFinderSettings {
 8    pub file_icons: bool,
 9    pub modal_max_width: Option<FileFinderWidth>,
10    pub skip_focus_for_active_in_search: bool,
11    pub include_ignored: Option<bool>,
12}
13
14#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUi, SettingsKey)]
15#[settings_key(key = "file_finder")]
16pub struct FileFinderSettingsContent {
17    /// Whether to show file icons in the file finder.
18    ///
19    /// Default: true
20    pub file_icons: Option<bool>,
21    /// Determines how much space the file finder can take up in relation to the available window width.
22    ///
23    /// Default: small
24    pub modal_max_width: Option<FileFinderWidth>,
25    /// Determines whether the file finder should skip focus for the active file in search results.
26    ///
27    /// Default: true
28    pub skip_focus_for_active_in_search: Option<bool>,
29    /// Determines whether to show the git status in the file finder
30    ///
31    /// Default: true
32    pub git_status: Option<bool>,
33    /// Whether to use gitignored files when searching.
34    /// Only the file Zed had indexed will be used, not necessary all the gitignored files.
35    ///
36    /// Can accept 3 values:
37    /// * `Some(true)`: Use all gitignored files
38    /// * `Some(false)`: Use only the files Zed had indexed
39    /// * `None`: Be smart and search for ignored when called from a gitignored worktree
40    ///
41    /// Default: None
42    pub include_ignored: Option<Option<bool>>,
43}
44
45impl Settings for FileFinderSettings {
46    type FileContent = FileFinderSettingsContent;
47
48    fn load(sources: SettingsSources<Self::FileContent>, _: &mut gpui::App) -> Result<Self> {
49        sources.json_merge()
50    }
51
52    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
53}
54
55#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, Serialize, Deserialize, JsonSchema)]
56#[serde(rename_all = "lowercase")]
57pub enum FileFinderWidth {
58    #[default]
59    Small,
60    Medium,
61    Large,
62    XLarge,
63    Full,
64}