From 26dee915ca4aa91c55711c6812783c92d68ee146 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 22 Sep 2025 09:36:01 -0700 Subject: [PATCH] Add initial scaffolding for settings auto-registration --- crates/acp_thread/src/acp_thread.rs | 2 + crates/action_log/src/action_log.rs | 2 + crates/agent/src/agent_profile.rs | 2 + crates/agent/src/context.rs | 2 + crates/agent/src/thread.rs | 2 + crates/agent2/src/agent.rs | 2 + crates/agent2/src/db.rs | 2 + crates/agent2/src/tools/edit_file_tool.rs | 2 + crates/agent2/src/tools/find_path_tool.rs | 2 + crates/agent2/src/tools/grep_tool.rs | 2 + .../agent2/src/tools/list_directory_tool.rs | 2 + crates/agent2/src/tools/open_tool.rs | 2 + crates/agent2/src/tools/read_file_tool.rs | 2 + crates/agent_servers/src/e2e_tests.rs | 2 + crates/agent_ui/src/acp/entry_view_state.rs | 2 + crates/agent_ui/src/acp/thread_view.rs | 2 + .../add_llm_provider_modal.rs | 2 + crates/agent_ui/src/agent_diff.rs | 4 ++ crates/agent_ui/src/buffer_codegen.rs | 2 + .../src/context_picker/completion_provider.rs | 2 + crates/agent_ui/src/text_thread_editor.rs | 2 + .../src/assistant_context_tests.rs | 1 + .../src/file_command.rs | 1 + crates/assistant_tools/src/edit_file_tool.rs | 4 ++ crates/assistant_tools/src/find_path_tool.rs | 2 + crates/assistant_tools/src/grep_tool.rs | 2 + .../src/list_directory_tool.rs | 2 + crates/assistant_tools/src/open_tool.rs | 2 + .../src/project_notifications_tool.rs | 2 + crates/assistant_tools/src/read_file_tool.rs | 2 + crates/assistant_tools/src/terminal_tool.rs | 2 + crates/channel/src/channel_store_tests.rs | 2 + crates/client/src/client.rs | 2 + crates/client/src/telemetry.rs | 1 + crates/collab/src/tests/test_server.rs | 2 + .../src/copilot_completion_provider.rs | 2 + crates/dap/src/client.rs | 2 + crates/debugger_ui/src/tests.rs | 2 + crates/diagnostics/src/diagnostics_tests.rs | 2 + .../src/edit_prediction_context.rs | 2 + .../src/syntax_index.rs | 2 + crates/editor/benches/editor_render.rs | 2 + crates/editor/src/display_map.rs | 2 + crates/editor/src/display_map/block_map.rs | 2 + crates/editor/src/display_map/fold_map.rs | 1 + crates/editor/src/display_map/inlay_map.rs | 2 + crates/editor/src/display_map/wrap_map.rs | 2 + crates/editor/src/editor_tests.rs | 2 + crates/settings/src/settings.rs | 2 +- crates/settings/src/settings_registration.rs | 12 ++++++ crates/settings/src/settings_store.rs | 4 ++ crates/settings_macros/src/settings_macros.rs | 37 ++++++++++++++++++- crates/zeta_cli/src/headless.rs | 2 + 53 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 crates/settings/src/settings_registration.rs diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index f2327ca70b104de12f44d74aacd1a5a2bb1eca3b..4fc3894ce465b60b1f1097433fbc132c163e2d45 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -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); }); diff --git a/crates/action_log/src/action_log.rs b/crates/action_log/src/action_log.rs index 11ba596ac5a0ecd4ed49744d0eafa9defcde20c1..248034f0617f5f232d635c36ef70e68720759484 100644 --- a/crates/action_log/src/action_log.rs +++ b/crates/action_log/src/action_log.rs @@ -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); }); diff --git a/crates/agent/src/agent_profile.rs b/crates/agent/src/agent_profile.rs index 40ba2f07db7ad425a5d0e9befe91499eb746b74e..64ccf27c0765418ad1d82be71b36f9f865897e82 100644 --- a/crates/agent/src/agent_profile.rs +++ b/crates/agent/src/agent_profile.rs @@ -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); diff --git a/crates/agent/src/context.rs b/crates/agent/src/context.rs index 4510b0d3d3548b3ff807a3e549a9f2dc53951452..36792aa8d7117c581e5af8649e7b523e7efa3efa 100644 --- a/crates/agent/src/context.rs +++ b/crates/agent/src/context.rs @@ -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); }); diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index 8b9d489ccf472ca16435934e48a12b70dc783c40..7bd1a692b21f49752ce4993ff196f85674321259 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -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); diff --git a/crates/agent2/src/agent.rs b/crates/agent2/src/agent.rs index 86fb50242c64917248df5c620782af066e639b54..5e24c9a95d55af17c7524ef9241b87f6e0662a76 100644 --- a/crates/agent2/src/agent.rs +++ b/crates/agent2/src/agent.rs @@ -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); diff --git a/crates/agent2/src/db.rs b/crates/agent2/src/db.rs index 3be37bbb55a9b6820b59245ba05143e3432ab397..d5a4883e072a76d51c2cb470069e349a87b17d95 100644 --- a/crates/agent2/src/db.rs +++ b/crates/agent2/src/db.rs @@ -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); diff --git a/crates/agent2/src/tools/edit_file_tool.rs b/crates/agent2/src/tools/edit_file_tool.rs index 81f340b0b5c83648b1ec92210986b475b71c5bcf..acc07eb299721a0893d99654d9af16846ce1fca3 100644 --- a/crates/agent2/src/tools/edit_file_tool.rs +++ b/crates/agent2/src/tools/edit_file_tool.rs @@ -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); diff --git a/crates/agent2/src/tools/find_path_tool.rs b/crates/agent2/src/tools/find_path_tool.rs index b8b60f79f4cf9808a730b0c6428885b23b32d998..527f9d057f797edfae816bde77026842a48a4ca3 100644 --- a/crates/agent2/src/tools/find_path_tool.rs +++ b/crates/agent2/src/tools/find_path_tool.rs @@ -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); }); diff --git a/crates/agent2/src/tools/grep_tool.rs b/crates/agent2/src/tools/grep_tool.rs index 7a2fa4db4009d94644455710429a44d51fdf20dc..cabaaeb6023b404d88ce148854fb3d02445a037f 100644 --- a/crates/agent2/src/tools/grep_tool.rs +++ b/crates/agent2/src/tools/grep_tool.rs @@ -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); }); diff --git a/crates/agent2/src/tools/list_directory_tool.rs b/crates/agent2/src/tools/list_directory_tool.rs index fe7e2a4d85d115d7b9b87be9a2b90f3f7bd19028..5cc3e8249dbb46a18f36e43ea30ad81b03ec77fe 100644 --- a/crates/agent2/src/tools/list_directory_tool.rs +++ b/crates/agent2/src/tools/list_directory_tool.rs @@ -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); }); diff --git a/crates/agent2/src/tools/open_tool.rs b/crates/agent2/src/tools/open_tool.rs index 595a9f380b752635f97ef5d1819a1140c1db8be0..03c3227b4a8ebcaff5f9a80219d56249c714fe60 100644 --- a/crates/agent2/src/tools/open_tool.rs +++ b/crates/agent2/src/tools/open_tool.rs @@ -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); }); diff --git a/crates/agent2/src/tools/read_file_tool.rs b/crates/agent2/src/tools/read_file_tool.rs index 6fa157630d487c517a536126d6b8dd4d4d53a4e1..11c9d54cbbfe2d7bc2c74909dfeed6a4cd3eea0c 100644 --- a/crates/agent2/src/tools/read_file_tool.rs +++ b/crates/agent2/src/tools/read_file_tool.rs @@ -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); }); diff --git a/crates/agent_servers/src/e2e_tests.rs b/crates/agent_servers/src/e2e_tests.rs index 1ee2e099f0ae355267b5f0a5aaddb3371f427240..bf2edfe85f84239f00734f86442900f65eda0f91 100644 --- a/crates/agent_servers/src/e2e_tests.rs +++ b/crates/agent_servers/src/e2e_tests.rs @@ -459,6 +459,8 @@ pub async fn init_test(cx: &mut TestAppContext) -> Arc { 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); diff --git a/crates/agent_ui/src/acp/entry_view_state.rs b/crates/agent_ui/src/acp/entry_view_state.rs index 0d4dfb0c206a78b2af932d5f3ef7d57c9bfbfc16..bdf739ce68b569fb1cae70d5a2915a8b591c53ad 100644 --- a/crates/agent_ui/src/acp/entry_view_state.rs +++ b/crates/agent_ui/src/acp/entry_view_state.rs @@ -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); diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index cd72be9b184ded0d53125bfd569da89acff59a48..0cd9a81364702f20bcda73034a466496dd2dd92b 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -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); diff --git a/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs b/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs index 373756b2c45ceeb65afebaf1f2d82b1fc16c017d..8b06b89c4a234356c90f1c370fe95c0d3fbac529 100644 --- a/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs +++ b/crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs @@ -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); diff --git a/crates/agent_ui/src/agent_diff.rs b/crates/agent_ui/src/agent_diff.rs index 5ae43398d626fd5b5208e5e73d2c034644a29d95..64097cc4462aaf40e5caba5ade588072db4e6418 100644 --- a/crates/agent_ui/src/agent_diff.rs +++ b/crates/agent_ui/src/agent_diff.rs @@ -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); diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index 2309aad754aee55af5ad040c39d22304486446a4..b54ef9180dc0a94dad8568a615dab763ca8e15b6 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -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); } diff --git a/crates/agent_ui/src/context_picker/completion_provider.rs b/crates/agent_ui/src/context_picker/completion_provider.rs index 01a7a51316eee4709eaf9c17c8840e3cd637a62b..0df54ccddbf7d601748c3293fd5982dd97c13d5b 100644 --- a/crates/agent_ui/src/context_picker/completion_provider.rs +++ b/crates/agent_ui/src/context_picker/completion_provider.rs @@ -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); diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index 3c09e47852ffae8f45a5315859a7bb3392b1680d..a9f84b0a3072ba6ec23aed61765aad5e79c14359 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -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); diff --git a/crates/assistant_context/src/assistant_context_tests.rs b/crates/assistant_context/src/assistant_context_tests.rs index 8b182685cfeb4e3ae1b9df8c532b8f0c5ad91235..278ca7b49f7fd3e8fbfb0edcfeda1a66063cb667 100644 --- a/crates/assistant_context/src/assistant_context_tests.rs +++ b/crates/assistant_context/src/assistant_context_tests.rs @@ -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); diff --git a/crates/assistant_slash_commands/src/file_command.rs b/crates/assistant_slash_commands/src/file_command.rs index 4bf53bad9b5364c7fd488cf74644701c6f176b99..d857c9e51bbe2c4257d562a0c23a24b838132228 100644 --- a/crates/assistant_slash_commands/src/file_command.rs +++ b/crates/assistant_slash_commands/src/file_command.rs @@ -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); diff --git a/crates/assistant_tools/src/edit_file_tool.rs b/crates/assistant_tools/src/edit_file_tool.rs index 1fcd7bbf14fb2e37646902102d51392bc8a470f8..b103c212a6e71eb4d1378d6dea02f5be7edcd141 100644 --- a/crates/assistant_tools/src/edit_file_tool.rs +++ b/crates/assistant_tools/src/edit_file_tool.rs @@ -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); diff --git a/crates/assistant_tools/src/find_path_tool.rs b/crates/assistant_tools/src/find_path_tool.rs index d1451132aeb066a5d4ff9e05f81db3855c1d513a..d26d44a082a2c2cccf40de4e1ee95f59de36e8e8 100644 --- a/crates/assistant_tools/src/find_path_tool.rs +++ b/crates/assistant_tools/src/find_path_tool.rs @@ -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); }); diff --git a/crates/assistant_tools/src/grep_tool.rs b/crates/assistant_tools/src/grep_tool.rs index c0de8a8d7e1d5552455656e5a76f3201898e5b67..de12eca0d960a1fffb64270ad2b43d8edf56e59a 100644 --- a/crates/assistant_tools/src/grep_tool.rs +++ b/crates/assistant_tools/src/grep_tool.rs @@ -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); }); diff --git a/crates/assistant_tools/src/list_directory_tool.rs b/crates/assistant_tools/src/list_directory_tool.rs index 9303a50468c428ddd4e603c69d75030dc860e876..204299080b1bb22fa7a2a43389cf368b904786f6 100644 --- a/crates/assistant_tools/src/list_directory_tool.rs +++ b/crates/assistant_tools/src/list_directory_tool.rs @@ -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); }); diff --git a/crates/assistant_tools/src/open_tool.rs b/crates/assistant_tools/src/open_tool.rs index 6dbf66749b932804df6e00fed726360f0492c7f3..b15d4558f41cf6833393b4bfe8375908f30c12e9 100644 --- a/crates/assistant_tools/src/open_tool.rs +++ b/crates/assistant_tools/src/open_tool.rs @@ -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); }); diff --git a/crates/assistant_tools/src/project_notifications_tool.rs b/crates/assistant_tools/src/project_notifications_tool.rs index e30d80207dae4de1e69efe99724a2a5343b57664..495f69c1da316fefa58d661732d79deb2b3f9de6 100644 --- a/crates/assistant_tools/src/project_notifications_tool.rs +++ b/crates/assistant_tools/src/project_notifications_tool.rs @@ -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); diff --git a/crates/assistant_tools/src/read_file_tool.rs b/crates/assistant_tools/src/read_file_tool.rs index 7006cc690375b904be2128e16d254cc6acbaac01..889a6e9721984e994cf17334cf954f38e641a0e3 100644 --- a/crates/assistant_tools/src/read_file_tool.rs +++ b/crates/assistant_tools/src/read_file_tool.rs @@ -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); }); diff --git a/crates/assistant_tools/src/terminal_tool.rs b/crates/assistant_tools/src/terminal_tool.rs index 8014a39e23137ad71b91e5c24d5d79699b530e5d..2f1ae5e2b3559967b9a291f035660d36afcce6de 100644 --- a/crates/assistant_tools/src/terminal_tool.rs +++ b/crates/assistant_tools/src/terminal_tool.rs @@ -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); diff --git a/crates/channel/src/channel_store_tests.rs b/crates/channel/src/channel_store_tests.rs index fbdfe9f8b59f2b5e47720bb497c56b47c8abb77e..3885ef3abf74ee6e225716fabf17e4d3a3d55dc9 100644 --- a/crates/channel/src/channel_store_tests.rs +++ b/crates/channel/src/channel_store_tests.rs @@ -236,6 +236,8 @@ fn test_dangling_channel_paths(cx: &mut App) { fn init_test(cx: &mut App) -> Entity { 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); diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index e098e7aed52281605c2882514b23c81d2041c6db..6ce8cd4b634322467c67972b4cb07f26cc7f0cd9 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -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); }); } diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index 7ab289a0ecdbab0909b90f2ef289af3c5d4a61b8..d524bd6246b4111b5b48af57fd3568d2694205d1 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -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); }); } diff --git a/crates/collab/src/tests/test_server.rs b/crates/collab/src/tests/test_server.rs index 5e99cc192ad080c1a79913c79fbbaae9d8b6d951..776f5e498bfb63f9a452d4dbc406fcd1d6bc2fa7 100644 --- a/crates/collab/src/tests/test_server.rs +++ b/crates/collab/src/tests/test_server.rs @@ -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); }); diff --git a/crates/copilot/src/copilot_completion_provider.rs b/crates/copilot/src/copilot_completion_provider.rs index c122dccec069ff636d39c64f24ef0aca41145012..5929e8919c172f105e0dd81c299c87978b19a098 100644 --- a/crates/copilot/src/copilot_completion_provider.rs +++ b/crates/copilot/src/copilot_completion_provider.rs @@ -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); diff --git a/crates/dap/src/client.rs b/crates/dap/src/client.rs index 15801e989169677f6e42bdd7b9c5642d82ea644a..acbfe437f0491e7a4227493008acc159ea586900 100644 --- a/crates/dap/src/client.rs +++ b/crates/dap/src/client.rs @@ -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); }); } diff --git a/crates/debugger_ui/src/tests.rs b/crates/debugger_ui/src/tests.rs index ac3fdf1f18c8250e0d8c3b897682652e694e2170..1147bf539a53019dd710fcc3a3fdf481f622b861 100644 --- a/crates/debugger_ui/src/tests.rs +++ b/crates/debugger_ui/src/tests.rs @@ -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); diff --git a/crates/diagnostics/src/diagnostics_tests.rs b/crates/diagnostics/src/diagnostics_tests.rs index a50e20f579e67010819de0fdb7273d4c9912b8b8..bc64a329475dd2a4f32ef6de848d73469a3f15bf 100644 --- a/crates/diagnostics/src/diagnostics_tests.rs +++ b/crates/diagnostics/src/diagnostics_tests.rs @@ -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); diff --git a/crates/edit_prediction_context/src/edit_prediction_context.rs b/crates/edit_prediction_context/src/edit_prediction_context.rs index aed2953777d82d65b7e9cb42229d78634d5e4a3d..c82f3345a7cf8912e8642d4b6bdc46549db3211b 100644 --- a/crates/edit_prediction_context/src/edit_prediction_context.rs +++ b/crates/edit_prediction_context/src/edit_prediction_context.rs @@ -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); }); diff --git a/crates/edit_prediction_context/src/syntax_index.rs b/crates/edit_prediction_context/src/syntax_index.rs index 64982f5805f08a3ba791578e28778f0c8399fde8..3bbeec6f0ae8ca3273e907c11ffabc5071fa84bd 100644 --- a/crates/edit_prediction_context/src/syntax_index.rs +++ b/crates/edit_prediction_context/src/syntax_index.rs @@ -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); }); diff --git a/crates/editor/benches/editor_render.rs b/crates/editor/benches/editor_render.rs index 0ae1af5537fb62a7658ccd306545503b818c28ae..a8680b11283570fe1fa7d2e5b5f83483368c751a 100644 --- a/crates/editor/benches/editor_render.rs +++ b/crates/editor/benches/editor_render.rs @@ -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); diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index cc6bb3571bc11c836fa4d13abb76f6cd4a554755..1d34d533225bd35543e76c539260445833e18106 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -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); diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 2d16e6af8b469ff6e94b1b9fc7d11f7186e7b3c3..4964c0dfce10049d110c4e8a894448fb4232653b 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -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); } diff --git a/crates/editor/src/display_map/fold_map.rs b/crates/editor/src/display_map/fold_map.rs index 405f25219fa6d7bcef03c745aa34fec351d7abd3..5a63d9224d71ba93e841247115ee45e25588a4c2 100644 --- a/crates/editor/src/display_map/fold_map.rs +++ b/crates/editor/src/display_map/fold_map.rs @@ -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 { diff --git a/crates/editor/src/display_map/inlay_map.rs b/crates/editor/src/display_map/inlay_map.rs index 9ceb0897d242f710353c2f7a90992b2a39f40958..bdbeed7ebf40ce2ccdbe8ac2f042343044eba72f 100644 --- a/crates/editor/src/display_map/inlay_map.rs +++ b/crates/editor/src/display_map/inlay_map.rs @@ -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); } diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index cd354d8229634956651ab74dd384332db0eb219e..355e050c00d940225eade340c2722743e3fa3821 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -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); }); } diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index f18187d558f1cb90e137d06591ec5b2ecb7b1654..9b03747b54383cef69681d63d886e0340bc43894 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -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); diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rs index 4b53b8b6ea49bc45a059776e3f863d2dd2961651..d27c75e4264831ba98fda0ef5eaf9eedfe8d9456 100644 --- a/crates/settings/src/settings.rs +++ b/crates/settings/src/settings.rs @@ -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}; diff --git a/crates/settings/src/settings_registration.rs b/crates/settings/src/settings_registration.rs new file mode 100644 index 0000000000000000000000000000000000000000..86ba9a674bd4d20552bbee87e27083c6368bc996 --- /dev/null +++ b/crates/settings/src/settings_registration.rs @@ -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:: { + (register_function.0)(cx); + } +} diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs index a575182a4144d99bf3c3c7f29f649735ea8b8891..e143a7f5001295f541e5f3d6e8cb73edb9ad6ffb 100644 --- a/crates/settings/src/settings_store.rs +++ b/crates/settings/src/settings_store.rs @@ -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::(|cx| { Self::update_global(cx, |store, cx| { diff --git a/crates/settings_macros/src/settings_macros.rs b/crates/settings_macros/src/settings_macros.rs index 1a7c391847e5093754f241ffccb079cc5ddd1a6b..5aa6c19e81515ff81387495654556579017af941 100644 --- a/crates/settings_macros/src/settings_macros.rs +++ b/crates/settings_macros/src/settings_macros.rs @@ -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() +} diff --git a/crates/zeta_cli/src/headless.rs b/crates/zeta_cli/src/headless.rs index bb4cb010cba6ea29a9bcd6d8cc0dc93475dbc2a0..dfb6881003e8989ced39ca2ff1f135dfc44a41ea 100644 --- a/crates/zeta_cli/src/headless.rs +++ b/crates/zeta_cli/src/headless.rs @@ -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