Automate settings registration (#42238)
Release Notes: - N/A --------- Co-authored-by: Nia <nia@zed.dev>
This commit is contained in:
@@ -20,7 +20,7 @@ use remote::RemoteClient;
|
||||
use rpc::{AnyProtoClient, TypedEnvelope, proto};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::SettingsStore;
|
||||
use settings::{RegisterSetting, SettingsStore};
|
||||
use task::Shell;
|
||||
use util::{ResultExt as _, debug_panic};
|
||||
|
||||
@@ -1618,7 +1618,7 @@ pub const GEMINI_NAME: &'static str = "gemini";
|
||||
pub const CLAUDE_CODE_NAME: &'static str = "claude";
|
||||
pub const CODEX_NAME: &'static str = "codex";
|
||||
|
||||
#[derive(Default, Clone, JsonSchema, Debug, PartialEq)]
|
||||
#[derive(Default, Clone, JsonSchema, Debug, PartialEq, RegisterSetting)]
|
||||
pub struct AllAgentServersSettings {
|
||||
pub gemini: Option<BuiltinAgentServerSettings>,
|
||||
pub claude: Option<BuiltinAgentServerSettings>,
|
||||
|
||||
@@ -1307,7 +1307,6 @@ mod tests {
|
||||
cx.update(|cx| {
|
||||
let settings_store = SettingsStore::test(cx);
|
||||
cx.set_global(settings_store);
|
||||
Project::init_settings(cx);
|
||||
let mut settings = ProjectSettings::get_global(cx).clone();
|
||||
for (id, config) in context_server_configurations {
|
||||
settings.context_servers.insert(id, config);
|
||||
|
||||
@@ -268,13 +268,10 @@ mod tests {
|
||||
status::{UnmergedStatus, UnmergedStatusCode},
|
||||
};
|
||||
use gpui::{BackgroundExecutor, TestAppContext};
|
||||
use language::language_settings::AllLanguageSettings;
|
||||
use serde_json::json;
|
||||
use settings::Settings as _;
|
||||
use text::{Buffer, BufferId, Point, ReplicaId, ToOffset as _};
|
||||
use unindent::Unindent as _;
|
||||
use util::{path, rel_path::rel_path};
|
||||
use worktree::WorktreeSettings;
|
||||
|
||||
#[test]
|
||||
fn test_parse_conflicts_in_buffer() {
|
||||
@@ -488,9 +485,6 @@ mod tests {
|
||||
zlog::init_test();
|
||||
cx.update(|cx| {
|
||||
settings::init(cx);
|
||||
WorktreeSettings::register(cx);
|
||||
Project::init_settings(cx);
|
||||
AllLanguageSettings::register(cx);
|
||||
});
|
||||
let initial_text = "
|
||||
one
|
||||
@@ -589,9 +583,6 @@ mod tests {
|
||||
zlog::init_test();
|
||||
cx.update(|cx| {
|
||||
settings::init(cx);
|
||||
WorktreeSettings::register(cx);
|
||||
Project::init_settings(cx);
|
||||
AllLanguageSettings::register(cx);
|
||||
});
|
||||
|
||||
let initial_text = "
|
||||
|
||||
@@ -688,7 +688,6 @@ mod tests {
|
||||
cx.update(|cx| {
|
||||
let settings_store = SettingsStore::test(cx);
|
||||
cx.set_global(settings_store);
|
||||
Project::init_settings(cx);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -920,8 +920,6 @@ mod tests {
|
||||
cx.update(|cx| {
|
||||
let settings_store = SettingsStore::test(cx);
|
||||
cx.set_global(settings_store);
|
||||
language::init(cx);
|
||||
Project::init_settings(cx);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ mod yarn;
|
||||
use dap::inline_value::{InlineValueLocation, VariableLookupKind, VariableScope};
|
||||
|
||||
use crate::{
|
||||
agent_server_store::AllAgentServersSettings,
|
||||
git_store::GitStore,
|
||||
lsp_store::{SymbolLocation, log_store::LogKind},
|
||||
};
|
||||
@@ -101,7 +100,7 @@ use rpc::{
|
||||
};
|
||||
use search::{SearchInputKind, SearchQuery, SearchResult};
|
||||
use search_history::SearchHistory;
|
||||
use settings::{InvalidSettingsError, Settings, SettingsLocation, SettingsStore};
|
||||
use settings::{InvalidSettingsError, RegisterSetting, Settings, SettingsLocation, SettingsStore};
|
||||
use smol::channel::Receiver;
|
||||
use snippet::Snippet;
|
||||
use snippet_provider::SnippetProvider;
|
||||
@@ -996,7 +995,7 @@ pub enum PulledDiagnostics {
|
||||
/// Whether to disable all AI features in Zed.
|
||||
///
|
||||
/// Default: false
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[derive(Copy, Clone, Debug, RegisterSetting)]
|
||||
pub struct DisableAiSettings {
|
||||
pub disable_ai: bool,
|
||||
}
|
||||
@@ -1010,16 +1009,8 @@ impl settings::Settings for DisableAiSettings {
|
||||
}
|
||||
|
||||
impl Project {
|
||||
pub fn init_settings(cx: &mut App) {
|
||||
WorktreeSettings::register(cx);
|
||||
ProjectSettings::register(cx);
|
||||
DisableAiSettings::register(cx);
|
||||
AllAgentServersSettings::register(cx);
|
||||
}
|
||||
|
||||
pub fn init(client: &Arc<Client>, cx: &mut App) {
|
||||
connection_manager::init(client.clone(), cx);
|
||||
Self::init_settings(cx);
|
||||
|
||||
let client: AnyProtoClient = client.clone().into();
|
||||
client.add_entity_message_handler(Self::handle_add_collaborator);
|
||||
@@ -5759,7 +5750,6 @@ mod disable_ai_settings_tests {
|
||||
async fn test_disable_ai_settings_security(cx: &mut TestAppContext) {
|
||||
cx.update(|cx| {
|
||||
settings::init(cx);
|
||||
Project::init_settings(cx);
|
||||
|
||||
// Test 1: Default is false (AI enabled)
|
||||
assert!(
|
||||
|
||||
@@ -20,8 +20,8 @@ use serde::{Deserialize, Serialize};
|
||||
pub use settings::DirenvSettings;
|
||||
pub use settings::LspSettings;
|
||||
use settings::{
|
||||
DapSettingsContent, InvalidSettingsError, LocalSettingsKind, Settings, SettingsLocation,
|
||||
SettingsStore, parse_json_with_comments, watch_config_file,
|
||||
DapSettingsContent, InvalidSettingsError, LocalSettingsKind, RegisterSetting, Settings,
|
||||
SettingsLocation, SettingsStore, parse_json_with_comments, watch_config_file,
|
||||
};
|
||||
use std::{path::PathBuf, sync::Arc, time::Duration};
|
||||
use task::{DebugTaskFile, TaskTemplates, VsCodeDebugTaskFile, VsCodeTaskFile};
|
||||
@@ -33,7 +33,7 @@ use crate::{
|
||||
worktree_store::{WorktreeStore, WorktreeStoreEvent},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, RegisterSetting)]
|
||||
pub struct ProjectSettings {
|
||||
/// Configuration for language servers.
|
||||
///
|
||||
|
||||
@@ -10091,8 +10091,6 @@ pub fn init_test(cx: &mut gpui::TestAppContext) {
|
||||
let settings_store = SettingsStore::test(cx);
|
||||
cx.set_global(settings_store);
|
||||
release_channel::init(SemanticVersion::default(), cx);
|
||||
language::init(cx);
|
||||
Project::init_settings(cx);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user