Detailed changes
@@ -2142,6 +2142,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
Project::init_settings(cx);
language::init(cx);
});
@@ -1002,6 +1002,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -227,6 +227,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
Project::init_settings(cx);
AgentSettings::register(cx);
language_model::init_settings(cx);
@@ -1098,6 +1098,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -5338,6 +5338,8 @@ fn main() {{
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
AgentSettings::register(cx);
@@ -1548,6 +1548,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
Project::init_settings(cx);
agent_settings::init(cx);
language::init(cx);
@@ -437,6 +437,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
Project::init_settings(cx);
language::init(cx);
@@ -1737,6 +1737,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
TelemetrySettings::register(cx);
agent_settings::AgentSettings::register(cx);
@@ -243,6 +243,8 @@ mod test {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -775,6 +775,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -231,6 +231,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -163,6 +163,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -507,6 +507,8 @@ mod test {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -459,6 +459,8 @@ pub async fn init_test(cx: &mut TestAppContext) -> Arc<FakeFs> {
cx.update(|cx| {
let settings_store = settings::SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
Project::init_settings(cx);
language::init(cx);
gpui_tokio::init(cx);
@@ -540,6 +540,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
AgentSettings::register(cx);
@@ -5990,6 +5990,8 @@ pub(crate) mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
AgentSettings::register(cx);
@@ -732,6 +732,8 @@ mod tests {
cx.update(|cx| {
let store = SettingsStore::test(cx);
cx.set_global(store);
+ SettingsStore::load_registered_settings(cx);
+
workspace::init_settings(cx);
Project::init_settings(cx);
theme::init(theme::LoadThemes::JustBase, cx);
@@ -1826,6 +1826,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
AgentSettings::register(cx);
@@ -1978,6 +1980,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
AgentSettings::register(cx);
@@ -1468,6 +1468,8 @@ mod tests {
fn init_test(cx: &mut TestAppContext) {
cx.update(LanguageModelRegistry::test);
cx.set_global(cx.update(SettingsStore::test));
+ SettingsStore::load_registered_settings(cx);
+
cx.update(Project::init_settings);
cx.update(language_settings::init);
}
@@ -1481,6 +1481,8 @@ mod tests {
cx.update(|cx| {
let store = SettingsStore::test(cx);
cx.set_global(store);
+ SettingsStore::load_registered_settings(cx);
+
theme::init(theme::LoadThemes::JustBase, cx);
client::init_settings(cx);
language::init(cx);
@@ -3217,6 +3217,8 @@ mod tests {
prompt_store::init(cx);
LanguageModelRegistry::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
agent_settings::init(cx);
Project::init_settings(cx);
@@ -1385,6 +1385,7 @@ fn init_test(cx: &mut App) {
prompt_store::init(cx);
LanguageModelRegistry::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
language::init(cx);
agent_settings::init(cx);
Project::init_settings(cx);
@@ -592,6 +592,7 @@ mod test {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
// release_channel::init(SemanticVersion::default(), cx);
language::init(cx);
Project::init_settings(cx);
@@ -1436,6 +1436,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
TelemetrySettings::register(cx);
agent_settings::AgentSettings::register(cx);
@@ -1450,6 +1452,8 @@ mod tests {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
TelemetrySettings::register(cx);
agent_settings::AgentSettings::register(cx);
@@ -457,6 +457,8 @@ mod test {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -797,6 +797,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -247,6 +247,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -163,6 +163,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -352,6 +352,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
assistant_tool::init(cx);
@@ -598,6 +598,8 @@ mod test {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -705,6 +705,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
workspace::init_settings(cx);
@@ -236,6 +236,8 @@ fn test_dangling_channel_paths(cx: &mut App) {
fn init_test(cx: &mut App) -> Entity<ChannelStore> {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
release_channel::init(SemanticVersion::default(), cx);
client::init_settings(cx);
@@ -2202,6 +2202,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
init_settings(cx);
});
}
@@ -836,6 +836,7 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
});
}
@@ -172,6 +172,8 @@ impl TestServer {
}
let settings = SettingsStore::test(cx);
cx.set_global(settings);
+ SettingsStore::load_registered_settings(cx);
+
release_channel::init(SemanticVersion::default(), cx);
client::init_settings(cx);
});
@@ -1116,6 +1116,8 @@ mod tests {
cx.update(|cx| {
let store = SettingsStore::test(cx);
cx.set_global(store);
+ SettingsStore::load_registered_settings(cx);
+
theme::init(theme::LoadThemes::JustBase, cx);
client::init_settings(cx);
language::init(cx);
@@ -277,6 +277,8 @@ mod tests {
cx.update(|cx| {
let settings = SettingsStore::test(cx);
cx.set_global(settings);
+ SettingsStore::load_registered_settings(cx);
+
DebuggerSettings::register(cx);
});
}
@@ -40,6 +40,8 @@ pub fn init_test(cx: &mut gpui::TestAppContext) {
cx.update(|cx| {
let settings = SettingsStore::test(cx);
cx.set_global(settings);
+ SettingsStore::load_registered_settings(cx);
+
terminal_view::init(cx);
theme::init(theme::LoadThemes::JustBase, cx);
command_palette_hooks::init(cx);
@@ -2006,6 +2006,8 @@ fn init_test(cx: &mut TestAppContext) {
zlog::init_test();
let settings = SettingsStore::test(cx);
cx.set_global(settings);
+ SettingsStore::load_registered_settings(cx);
+
theme::init(theme::LoadThemes::JustBase, cx);
language::init(cx);
client::init_settings(cx);
@@ -128,6 +128,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -755,6 +755,8 @@ mod tests {
cx.update(|cx| {
let settings_store = SettingsStore::test(cx);
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
language::init(cx);
Project::init_settings(cx);
});
@@ -122,6 +122,8 @@ pub fn benches() {
cx.update(|cx| {
let store = SettingsStore::test(cx);
cx.set_global(store);
+ SettingsStore::load_registered_settings(cx);
+
assets::Assets.load_test_fonts(cx);
theme::init(theme::LoadThemes::JustBase, cx);
// release_channel::init(SemanticVersion::default(), cx);
@@ -2919,6 +2919,8 @@ pub mod tests {
fn init_test(cx: &mut App, f: impl Fn(&mut SettingsContent)) {
let settings = SettingsStore::test(cx);
cx.set_global(settings);
+ SettingsStore::load_registered_settings(cx);
+
workspace::init_settings(cx);
language::init(cx);
crate::init(cx);
@@ -3569,6 +3569,8 @@ mod tests {
fn init_test(cx: &mut gpui::App) {
let settings = SettingsStore::test(cx);
cx.set_global(settings);
+ SettingsStore::load_registered_settings(cx);
+
theme::init(theme::LoadThemes::JustBase, cx);
assets::Assets.load_test_fonts(cx);
}
@@ -2193,6 +2193,7 @@ mod tests {
fn init_test(cx: &mut gpui::App) {
let store = SettingsStore::test(cx);
cx.set_global(store);
+ SettingsStore::load_registered_settings(cx);
}
impl FoldMap {
@@ -2102,6 +2102,8 @@ mod tests {
fn init_test(cx: &mut App) {
let store = SettingsStore::test(cx);
cx.set_global(store);
+ SettingsStore::load_registered_settings(cx);
+
theme::init(theme::LoadThemes::JustBase, cx);
}
@@ -1460,6 +1460,8 @@ mod tests {
cx.update(|cx| {
let settings = SettingsStore::test(cx);
cx.set_global(settings);
+ SettingsStore::load_registered_settings(cx);
+
theme::init(LoadThemes::JustBase, cx);
});
}
@@ -25128,6 +25128,8 @@ pub(crate) fn init_test(cx: &mut TestAppContext, f: fn(&mut AllLanguageSettingsC
assets::Assets.load_test_fonts(cx);
let store = SettingsStore::test(cx);
cx.set_global(store);
+ SettingsStore::load_registered_settings(cx);
+
theme::init(theme::LoadThemes::JustBase, cx);
release_channel::init(SemanticVersion::default(), cx);
client::init_settings(cx);
@@ -5,10 +5,10 @@ pub mod merge_from;
mod settings_content;
mod settings_file;
mod settings_json;
+pub mod settings_registration;
mod settings_store;
mod settings_ui_core;
mod vscode_import;
-
pub use settings_content::*;
use gpui::{App, Global};
@@ -0,0 +1,12 @@
+use gpui::App;
+pub use inventory;
+
+pub struct RegisterSettingFn(fn(&mut App));
+
+inventory::collect!(RegisterSettingFn);
+
+pub fn load_registered_settings(cx: &mut App) {
+ for register_function in inventory::iter::<RegisterSettingFn> {
+ (register_function.0)(cx);
+ }
+}
@@ -235,6 +235,10 @@ impl SettingsStore {
}
}
+ pub fn load_registered_settings(cx: &mut App) {
+ crate::settings_registration::load_registered_settings(cx);
+ }
+
pub fn observe_active_settings_profile_name(cx: &mut App) -> gpui::Subscription {
cx.observe_global::<ActiveSettingsProfileName>(|cx| {
Self::update_global(cx, |store, cx| {
@@ -1,6 +1,6 @@
use proc_macro::TokenStream;
-use quote::quote;
-use syn::{Data, DeriveInput, Fields, parse_macro_input};
+use quote::{format_ident, quote};
+use syn::{Data, DeriveInput, Fields, Ident, parse_macro_input};
/// Derives the `MergeFrom` trait for a struct.
///
@@ -76,3 +76,36 @@ pub fn derive_merge_from(input: TokenStream) -> TokenStream {
TokenStream::from(expanded)
}
+
+/// This can be used to register an action with the GPUI runtime when you want to manually implement
+/// the `Action` trait. Typically you should use the `Action` derive macro or `actions!` macro
+/// instead.
+#[proc_macro_derive(RegisterSetting)]
+pub fn register_settings(ident: TokenStream) -> TokenStream {
+ let type_name = parse_macro_input!(ident as Ident);
+
+ let settings_registration_fn_name = format_ident!(
+ "__settings_registration_{}",
+ type_name.to_string().to_lowercase()
+ );
+
+ quote! {
+ impl #type_name {
+ /// This is an auto generated function, do not use.
+ #[automatically_derived]
+ #[doc(hidden)]
+ fn __autogenerated() {
+ /// This is an auto generated function, do not use.
+ #[doc(hidden)]
+ fn #settings_registration_fn_name(cx: &mut gpui::AppContext) {
+ #type_name::register(cx);
+ }
+
+ settings::settings_registration::inventory::submit! {
+ settings::settings_registration::RegisterSettingFn(#settings_registration_fn_name)
+ }
+ }
+ }
+ }
+ .into()
+}
@@ -33,6 +33,8 @@ pub fn init(cx: &mut App) -> ZetaCliAppState {
let settings_store = SettingsStore::new(cx, &settings::default_settings());
cx.set_global(settings_store);
+ SettingsStore::load_registered_settings(cx);
+
client::init_settings(cx);
// Set User-Agent so we can download language servers from GitHub