Automate settings registration (#42238)

Release Notes:

- N/A

---------

Co-authored-by: Nia <nia@zed.dev>
This commit is contained in:
Mikayla Maki
2025-11-07 22:27:14 +00:00
committed by GitHub
co-authored by Nia
parent 309947aa53
commit 5f8226457e
161 changed files with 196 additions and 599 deletions
+4 -1
View File
@@ -17,7 +17,8 @@ use gpui::{
};
use project::{Project, ProjectEntryId, ProjectPath};
pub use settings::{
ActivateOnClose, ClosePosition, Settings, SettingsLocation, ShowCloseButton, ShowDiagnostics,
ActivateOnClose, ClosePosition, RegisterSetting, Settings, SettingsLocation, ShowCloseButton,
ShowDiagnostics,
};
use smallvec::SmallVec;
use std::{
@@ -50,6 +51,7 @@ impl Default for SaveOptions {
}
}
#[derive(RegisterSetting)]
pub struct ItemSettings {
pub git_status: bool,
pub close_position: ClosePosition,
@@ -59,6 +61,7 @@ pub struct ItemSettings {
pub show_close_button: ShowCloseButton,
}
#[derive(RegisterSetting)]
pub struct PreviewTabsSettings {
pub enabled: bool,
pub enable_preview_from_file_finder: bool,
-2
View File
@@ -6873,8 +6873,6 @@ mod tests {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
theme::init(LoadThemes::JustBase, cx);
crate::init_settings(cx);
Project::init_settings(cx);
});
}
-13
View File
@@ -527,14 +527,6 @@ impl From<WorkspaceId> for i64 {
}
}
pub fn init_settings(cx: &mut App) {
WorkspaceSettings::register(cx);
ItemSettings::register(cx);
PreviewTabsSettings::register(cx);
TabBarSettings::register(cx);
StatusBarSettings::register(cx);
}
fn prompt_and_open_paths(app_state: Arc<AppState>, options: PathPromptOptions, cx: &mut App) {
let paths = cx.prompt_for_paths(options);
cx.spawn(
@@ -568,7 +560,6 @@ fn prompt_and_open_paths(app_state: Arc<AppState>, options: PathPromptOptions, c
}
pub fn init(app_state: Arc<AppState>, cx: &mut App) {
init_settings(cx);
component::init();
theme_preview::init(cx);
toast_layer::init(cx);
@@ -987,7 +978,6 @@ impl AppState {
theme::init(theme::LoadThemes::JustBase, cx);
client::init(&client, cx);
crate::init_settings(cx);
Arc::new(Self {
client,
@@ -11341,9 +11331,6 @@ mod tests {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
theme::init(theme::LoadThemes::JustBase, cx);
language::init(cx);
crate::init_settings(cx);
Project::init_settings(cx);
});
}
+5 -6
View File
@@ -3,13 +3,12 @@ use std::num::NonZeroUsize;
use crate::DockPosition;
use collections::HashMap;
use serde::Deserialize;
pub use settings::AutosaveSetting;
pub use settings::{
BottomDockLayout, PaneSplitDirectionHorizontal, PaneSplitDirectionVertical,
RestoreOnStartupBehavior,
AutosaveSetting, BottomDockLayout, InactiveOpacity, PaneSplitDirectionHorizontal,
PaneSplitDirectionVertical, RegisterSetting, RestoreOnStartupBehavior, Settings,
};
use settings::{InactiveOpacity, Settings};
#[derive(RegisterSetting)]
pub struct WorkspaceSettings {
pub active_pane_modifiers: ActivePanelModifiers,
pub bottom_dock_layout: settings::BottomDockLayout,
@@ -53,7 +52,7 @@ pub struct ActivePanelModifiers {
pub inactive_opacity: Option<InactiveOpacity>,
}
#[derive(Deserialize)]
#[derive(Deserialize, RegisterSetting)]
pub struct TabBarSettings {
pub show: bool,
pub show_nav_history_buttons: bool,
@@ -121,7 +120,7 @@ impl Settings for TabBarSettings {
}
}
#[derive(Deserialize)]
#[derive(Deserialize, RegisterSetting)]
pub struct StatusBarSettings {
pub show: bool,
pub active_language_button: bool,