This PR separates out the associated constant `KEY` from the `Settings` trait into a new trait `SettingsKey`. This allows for the key trait to be derived using attributes to specify the path so that the new `SettingsUi` derive macro can use the same attributes to determine top level settings paths thereby removing the need to duplicate the path in both `Settings::KEY` and `#[settings_ui(path = "...")]` Co-authored-by: Ben Kunkle <ben@zed.dev> Release Notes: - N/A --------- 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::{Settings, SettingsKey, SettingsSources, SettingsUi};
|
|
|
|
/// Settings for slash commands.
|
|
#[derive(Deserialize, Serialize, Debug, Default, Clone, JsonSchema, SettingsUi, SettingsKey)]
|
|
#[settings_key(key = "slash_commands")]
|
|
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 {
|
|
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) {}
|
|
}
|