file_finder_settings.rs

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