
We also change the structure of the settings ui macro. The trait is still a requirement on the Settings trait implementation, but it returns a SettingUIItemVariant now, which the settings ui crate will take adventage of to generate UI This allows us to get around circular dependency errors and still get the type system to ensure all settings fulfill the settings UI crate Co-authored-by: Ben Kunkle <ben@zed.dev>
38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
use anyhow::Result;
|
|
use gpui::App;
|
|
use schemars::JsonSchema;
|
|
use serde::{Deserialize, Serialize};
|
|
use settings::{SettingsUI, Settings, SettingsSources};
|
|
|
|
/// Settings for slash commands.
|
|
#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, SettingsUI)]
|
|
pub struct SlashCommandSettings {
|
|
/// Settings for the `/cargo-workspace` slash command.
|
|
#[serde(default)]
|
|
pub cargo_workspace: CargoWorkspaceCommandSettings,
|
|
}
|
|
|
|
/// Settings for the `/cargo-workspace` slash command.
|
|
#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema)]
|
|
pub struct CargoWorkspaceCommandSettings {
|
|
/// Whether `/cargo-workspace` is enabled.
|
|
#[serde(default)]
|
|
pub enabled: bool,
|
|
}
|
|
|
|
impl Settings for SlashCommandSettings {
|
|
const KEY: Option<&'static str> = Some("slash_commands");
|
|
|
|
type FileContent = Self;
|
|
|
|
fn load(sources: SettingsSources<Self::FileContent>, _cx: &mut App) -> Result<Self> {
|
|
SettingsSources::<Self::FileContent>::json_merge_with(
|
|
[sources.default]
|
|
.into_iter()
|
|
.chain(sources.user)
|
|
.chain(sources.server),
|
|
)
|
|
}
|
|
|
|
fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
|
|
}
|