Move git gutter settings out of editor settings

Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
Julia 2022-10-03 14:53:33 -04:00
parent 8f4b3c3493
commit a5c2f22bf7
5 changed files with 38 additions and 29 deletions

View file

@ -75,17 +75,19 @@
// How many columns a tab should occupy. // How many columns a tab should occupy.
"tab_size": 4, "tab_size": 4,
// Git gutter behavior configuration. // Git gutter behavior configuration.
"git_gutter": { "git": {
// Which files to show the git gutter on. This setting can take "git_gutter": {
// three values: // Which files to show the git gutter on. This setting can take
// 1. All files, files not tracked in git will be diffed against // three values:
// their contents when the file was last opened in Zed: // 1. All files, files not tracked in git will be diffed against
// "files_included": "all", // their contents when the file was last opened in Zed:
// 2. Only show for files tracked in git: // "files_included": "all",
// "files_included": "only_tracked", // 2. Only show for files tracked in git:
// 3. Disable git gutters entirely: // "files_included": "only_tracked",
// "files_included": "none", // 3. Disable git gutters entirely:
"files_included": "all" // "files_included": "none",
"files_included": "all"
}
}, },
// Settings specific to the terminal // Settings specific to the terminal
"terminal": { "terminal": {

View file

@ -1744,7 +1744,7 @@ impl Server {
Ok(()) Ok(())
} }
async fn get_private_user_info( async fn get_private_user_info(
self: Arc<Self>, self: Arc<Self>,
request: TypedEnvelope<proto::GetPrivateUserInfo>, request: TypedEnvelope<proto::GetPrivateUserInfo>,
response: Response<proto::GetPrivateUserInfo>, response: Response<proto::GetPrivateUserInfo>,

View file

@ -665,9 +665,9 @@ impl LocalWorktree {
let files_included = cx let files_included = cx
.global::<Settings>() .global::<Settings>()
.editor_overrides .git
.git_gutter .git_gutter
.unwrap_or_default() .expect("This should be Some by setting setup")
.files_included; .files_included;
cx.spawn(|this, mut cx| async move { cx.spawn(|this, mut cx| async move {

View file

@ -32,6 +32,7 @@ pub struct Settings {
pub default_dock_anchor: DockAnchor, pub default_dock_anchor: DockAnchor,
pub editor_defaults: EditorSettings, pub editor_defaults: EditorSettings,
pub editor_overrides: EditorSettings, pub editor_overrides: EditorSettings,
pub git: GitSettings,
pub terminal_defaults: TerminalSettings, pub terminal_defaults: TerminalSettings,
pub terminal_overrides: TerminalSettings, pub terminal_overrides: TerminalSettings,
pub language_defaults: HashMap<Arc<str>, EditorSettings>, pub language_defaults: HashMap<Arc<str>, EditorSettings>,
@ -52,20 +53,13 @@ impl FeatureFlags {
} }
} }
#[derive(Clone, Debug, Default, Deserialize, JsonSchema)] #[derive(Copy, Clone, Debug, Default, Deserialize, JsonSchema)]
pub struct EditorSettings { pub struct GitSettings {
pub tab_size: Option<NonZeroU32>, pub git_gutter: Option<GitGutterSettings>,
pub hard_tabs: Option<bool>,
pub soft_wrap: Option<SoftWrap>,
pub preferred_line_length: Option<u32>,
pub format_on_save: Option<FormatOnSave>,
pub formatter: Option<Formatter>,
pub enable_language_server: Option<bool>,
pub git_gutter: Option<GitGutterConfig>,
} }
#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)] #[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)]
pub struct GitGutterConfig { pub struct GitGutterSettings {
pub files_included: GitFilesIncluded, pub files_included: GitFilesIncluded,
pub debounce_delay_millis: Option<u64>, pub debounce_delay_millis: Option<u64>,
} }
@ -79,6 +73,17 @@ pub enum GitFilesIncluded {
None, None,
} }
#[derive(Clone, Debug, Default, Deserialize, JsonSchema)]
pub struct EditorSettings {
pub tab_size: Option<NonZeroU32>,
pub hard_tabs: Option<bool>,
pub soft_wrap: Option<SoftWrap>,
pub preferred_line_length: Option<u32>,
pub format_on_save: Option<FormatOnSave>,
pub formatter: Option<Formatter>,
pub enable_language_server: Option<bool>,
}
#[derive(Copy, Clone, Debug, Deserialize, PartialEq, Eq, JsonSchema)] #[derive(Copy, Clone, Debug, Deserialize, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum SoftWrap { pub enum SoftWrap {
@ -212,6 +217,8 @@ pub struct SettingsFileContent {
#[serde(default)] #[serde(default)]
pub terminal: TerminalSettings, pub terminal: TerminalSettings,
#[serde(default)] #[serde(default)]
pub git: Option<GitSettings>,
#[serde(default)]
#[serde(alias = "language_overrides")] #[serde(alias = "language_overrides")]
pub languages: HashMap<Arc<str>, EditorSettings>, pub languages: HashMap<Arc<str>, EditorSettings>,
#[serde(default)] #[serde(default)]
@ -266,9 +273,9 @@ impl Settings {
format_on_save: required(defaults.editor.format_on_save), format_on_save: required(defaults.editor.format_on_save),
formatter: required(defaults.editor.formatter), formatter: required(defaults.editor.formatter),
enable_language_server: required(defaults.editor.enable_language_server), enable_language_server: required(defaults.editor.enable_language_server),
git_gutter: defaults.editor.git_gutter,
}, },
editor_overrides: Default::default(), editor_overrides: Default::default(),
git: defaults.git.unwrap(),
terminal_defaults: Default::default(), terminal_defaults: Default::default(),
terminal_overrides: Default::default(), terminal_overrides: Default::default(),
language_defaults: defaults.languages, language_defaults: defaults.languages,
@ -395,11 +402,11 @@ impl Settings {
format_on_save: Some(FormatOnSave::On), format_on_save: Some(FormatOnSave::On),
formatter: Some(Formatter::LanguageServer), formatter: Some(Formatter::LanguageServer),
enable_language_server: Some(true), enable_language_server: Some(true),
git_gutter: Default::default(),
}, },
editor_overrides: Default::default(), editor_overrides: Default::default(),
terminal_defaults: Default::default(), terminal_defaults: Default::default(),
terminal_overrides: Default::default(), terminal_overrides: Default::default(),
git: Default::default(),
language_defaults: Default::default(), language_defaults: Default::default(),
language_overrides: Default::default(), language_overrides: Default::default(),
lsp: Default::default(), lsp: Default::default(),

View file

@ -736,9 +736,9 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
let debounce_delay = cx let debounce_delay = cx
.global::<Settings>() .global::<Settings>()
.editor_overrides .git
.git_gutter .git_gutter
.unwrap_or_default() .expect("This should be Some by setting setup")
.debounce_delay_millis; .debounce_delay_millis;
let item = item.clone(); let item = item.clone();