diff --git a/crates/language_models/src/provider/vercel.rs b/crates/language_models/src/provider/vercel.rs index 86f3dc6a1672e19716afefcdaf32ca71fc43ae88..5f6fa23c642afbf57acb88d6429c07721dd74acc 100644 --- a/crates/language_models/src/provider/vercel.rs +++ b/crates/language_models/src/provider/vercel.rs @@ -29,7 +29,7 @@ const PROVIDER_NAME: LanguageModelProviderName = LanguageModelProviderName::new( const API_KEY_ENV_VAR_NAME: &str = "VERCEL_API_KEY"; static API_KEY_ENV_VAR: LazyLock = env_var!(API_KEY_ENV_VAR_NAME); -#[derive(Default, Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq)] pub struct VercelSettings { pub api_url: String, pub available_models: Vec, diff --git a/crates/language_models/src/settings.rs b/crates/language_models/src/settings.rs index 808a1e88d7c039ea2576aae9472d4ee73437accb..30b208a170794a0d4018e8ebce39f1020b4c9b29 100644 --- a/crates/language_models/src/settings.rs +++ b/crates/language_models/src/settings.rs @@ -18,7 +18,6 @@ pub fn init_settings(cx: &mut App) { AllLanguageModelSettings::register(cx); } -#[derive(Default)] pub struct AllLanguageModelSettings { pub anthropic: AnthropicSettings, pub bedrock: AmazonBedrockSettings, diff --git a/crates/project/src/debugger/dap_store.rs b/crates/project/src/debugger/dap_store.rs index ab0d69b6d9f7da254e659a0d5e5d0cfee0322711..d96e5c220fcc98413a42dc46e0889004300d1e2f 100644 --- a/crates/project/src/debugger/dap_store.rs +++ b/crates/project/src/debugger/dap_store.rs @@ -5,8 +5,10 @@ use super::{ session::{self, Session, SessionStateEvent}, }; use crate::{ - InlayHint, InlayHintLabel, ProjectEnvironment, ResolveState, debugger::session::SessionQuirks, - project_settings::ProjectSettings, worktree_store::WorktreeStore, + InlayHint, InlayHintLabel, ProjectEnvironment, ResolveState, + debugger::session::SessionQuirks, + project_settings::{DapBinary, ProjectSettings}, + worktree_store::WorktreeStore, }; use anyhow::{Context as _, Result, anyhow}; use async_trait::async_trait; @@ -209,8 +211,10 @@ impl DapStore { let dap_settings = ProjectSettings::get(Some(settings_location), cx) .dap .get(&adapter.name()); - let user_installed_path = - dap_settings.and_then(|s| s.binary.as_ref().map(PathBuf::from)); + let user_installed_path = dap_settings.and_then(|s| match &s.binary { + DapBinary::Default => None, + DapBinary::Custom(binary) => Some(PathBuf::from(binary)), + }); let user_args = dap_settings.map(|s| s.args.clone()); let delegate = self.delegate(worktree, console, cx); diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rs index 80bf667b2cd204b9a0989fdbad87efa84cd5c819..8cba826ca95c48aa34064086fca8c267704f3923 100644 --- a/crates/project/src/project_settings.rs +++ b/crates/project/src/project_settings.rs @@ -20,8 +20,8 @@ use serde::{Deserialize, Serialize}; pub use settings::DirenvSettings; pub use settings::LspSettings; use settings::{ - InvalidSettingsError, LocalSettingsKind, Settings, SettingsLocation, SettingsStore, SettingsUi, - parse_json_with_comments, watch_config_file, + DapSettingsContent, InvalidSettingsError, LocalSettingsKind, Settings, SettingsLocation, + SettingsStore, SettingsUi, parse_json_with_comments, watch_config_file, }; use std::{ path::{Path, PathBuf}, @@ -54,7 +54,7 @@ pub struct ProjectSettings { pub global_lsp_settings: GlobalLspSettings, /// Configuration for Debugger-related features - pub dap: HashMap, + pub dap: HashMap, /// Settings for context servers used for AI-related features. pub context_servers: HashMap, ContextServerSettings>, @@ -494,7 +494,7 @@ impl Settings for ProjectSettings { .dap .clone() .into_iter() - .map(|(key, value)| (DebugAdapterName(key.into()), value)) + .map(|(key, value)| (DebugAdapterName(key.into()), DapSettings::from(value))) .collect(), diagnostics: DiagnosticsSettings { button: diagnostics.button.unwrap(), @@ -534,7 +534,7 @@ impl Settings for ProjectSettings { .dap .clone() .into_iter() - .map(|(key, value)| (DebugAdapterName(key.into()), value)), + .map(|(key, value)| (DebugAdapterName(key.into()), DapSettings::from(value))), ); if let Some(diagnostics) = content.diagnostics.as_ref() { if let Some(inline) = &diagnostics.inline { @@ -1326,3 +1326,26 @@ pub fn local_settings_kind_to_proto(kind: LocalSettingsKind) -> proto::LocalSett LocalSettingsKind::Debug => proto::LocalSettingsKind::Debug, } } + +#[derive(Debug, Clone)] +pub struct DapSettings { + pub binary: DapBinary, + pub args: Vec, +} + +impl From for DapSettings { + fn from(content: DapSettingsContent) -> Self { + DapSettings { + binary: content + .binary + .map_or_else(|| DapBinary::Default, |binary| DapBinary::Custom(binary)), + args: content.args.unwrap_or_default(), + } + } +} + +#[derive(Debug, Clone)] +pub enum DapBinary { + Default, + Custom(String), +} diff --git a/crates/settings/src/settings_content/project.rs b/crates/settings/src/settings_content/project.rs index fd4f34ff4fc647c389ab977b1076003516cb7421..e857fdcb604da7f1b56e01507377667892a23bd0 100644 --- a/crates/settings/src/settings_content/project.rs +++ b/crates/settings/src/settings_content/project.rs @@ -30,7 +30,7 @@ pub struct ProjectSettingsContent { /// Configuration for Debugger-related features #[serde(default)] - pub dap: HashMap, DapSettings>, + pub dap: HashMap, DapSettingsContent>, /// Settings for context servers used for AI-related features. #[serde(default)] @@ -141,10 +141,10 @@ pub struct GlobalLspSettingsContent { #[skip_serializing_none] #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "snake_case")] -pub struct DapSettings { +pub struct DapSettingsContent { pub binary: Option, #[serde(default)] - pub args: Vec, + pub args: Option>, } #[skip_serializing_none]