
This PR adds the ability for extensions to provide certain language settings via the language `config.toml`. These settings are then merged in with the rest of the settings when the language is loaded from the extension. The language settings that are available are: - `tab_size` - `hard_tabs` - `soft_wrap` Additionally, for bundled languages we moved these settings out of the `settings/default.json` and into their respective `config.toml`s . For languages currently provided by extensions, we are leaving the values in the `settings/default.json` temporarily until all released versions of Zed are able to load these settings from the extension. --- Along the way we ended up refactoring the `Settings::load` method slightly, introducing a new `SettingsSources` struct to better convey where the settings are being loaded from. This makes it easier to load settings from specific locations/sets of locations in an explicit way. Release Notes: - N/A --------- Co-authored-by: Max <max@zed.dev> Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
104 lines
2.6 KiB
Rust
104 lines
2.6 KiB
Rust
use anyhow;
|
|
use gpui::Pixels;
|
|
use schemars::JsonSchema;
|
|
use serde_derive::{Deserialize, Serialize};
|
|
use settings::{Settings, SettingsSources};
|
|
use workspace::dock::DockPosition;
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct CollaborationPanelSettings {
|
|
pub button: bool,
|
|
pub dock: DockPosition,
|
|
pub default_width: Pixels,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct ChatPanelSettings {
|
|
pub button: bool,
|
|
pub dock: DockPosition,
|
|
pub default_width: Pixels,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct NotificationPanelSettings {
|
|
pub button: bool,
|
|
pub dock: DockPosition,
|
|
pub default_width: Pixels,
|
|
}
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
|
pub struct PanelSettingsContent {
|
|
/// Whether to show the panel button in the status bar.
|
|
///
|
|
/// Default: true
|
|
pub button: Option<bool>,
|
|
/// Where to dock the panel.
|
|
///
|
|
/// Default: left
|
|
pub dock: Option<DockPosition>,
|
|
/// Default width of the panel in pixels.
|
|
///
|
|
/// Default: 240
|
|
pub default_width: Option<f32>,
|
|
}
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
|
pub struct MessageEditorSettings {
|
|
/// Whether to automatically replace emoji shortcodes with emoji characters.
|
|
/// For example: typing `:wave:` gets replaced with `👋`.
|
|
///
|
|
/// Default: false
|
|
pub auto_replace_emoji_shortcode: Option<bool>,
|
|
}
|
|
|
|
impl Settings for CollaborationPanelSettings {
|
|
const KEY: Option<&'static str> = Some("collaboration_panel");
|
|
|
|
type FileContent = PanelSettingsContent;
|
|
|
|
fn load(
|
|
sources: SettingsSources<Self::FileContent>,
|
|
_: &mut gpui::AppContext,
|
|
) -> anyhow::Result<Self> {
|
|
sources.json_merge()
|
|
}
|
|
}
|
|
|
|
impl Settings for ChatPanelSettings {
|
|
const KEY: Option<&'static str> = Some("chat_panel");
|
|
|
|
type FileContent = PanelSettingsContent;
|
|
|
|
fn load(
|
|
sources: SettingsSources<Self::FileContent>,
|
|
_: &mut gpui::AppContext,
|
|
) -> anyhow::Result<Self> {
|
|
sources.json_merge()
|
|
}
|
|
}
|
|
|
|
impl Settings for NotificationPanelSettings {
|
|
const KEY: Option<&'static str> = Some("notification_panel");
|
|
|
|
type FileContent = PanelSettingsContent;
|
|
|
|
fn load(
|
|
sources: SettingsSources<Self::FileContent>,
|
|
_: &mut gpui::AppContext,
|
|
) -> anyhow::Result<Self> {
|
|
sources.json_merge()
|
|
}
|
|
}
|
|
|
|
impl Settings for MessageEditorSettings {
|
|
const KEY: Option<&'static str> = Some("message_editor");
|
|
|
|
type FileContent = MessageEditorSettings;
|
|
|
|
fn load(
|
|
sources: SettingsSources<Self::FileContent>,
|
|
_: &mut gpui::AppContext,
|
|
) -> anyhow::Result<Self> {
|
|
sources.json_merge()
|
|
}
|
|
}
|