
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>
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
mod keymap_file;
|
|
mod settings_file;
|
|
mod settings_store;
|
|
|
|
use rust_embed::RustEmbed;
|
|
use std::{borrow::Cow, str};
|
|
use util::asset_str;
|
|
|
|
pub use keymap_file::KeymapFile;
|
|
pub use settings_file::*;
|
|
pub use settings_store::{
|
|
Settings, SettingsJsonSchemaParams, SettingsLocation, SettingsSources, SettingsStore,
|
|
};
|
|
|
|
#[derive(RustEmbed)]
|
|
#[folder = "../../assets"]
|
|
#[include = "settings/*"]
|
|
#[include = "keymaps/*"]
|
|
#[exclude = "*.DS_Store"]
|
|
pub struct SettingsAssets;
|
|
|
|
pub fn default_settings() -> Cow<'static, str> {
|
|
asset_str::<SettingsAssets>("settings/default.json")
|
|
}
|
|
|
|
#[cfg(target_os = "macos")]
|
|
pub const DEFAULT_KEYMAP_PATH: &str = "keymaps/default-macos.json";
|
|
|
|
#[cfg(not(target_os = "macos"))]
|
|
pub const DEFAULT_KEYMAP_PATH: &str = "keymaps/default-linux.json";
|
|
|
|
pub fn default_keymap() -> Cow<'static, str> {
|
|
asset_str::<SettingsAssets>(DEFAULT_KEYMAP_PATH)
|
|
}
|
|
|
|
pub fn vim_keymap() -> Cow<'static, str> {
|
|
asset_str::<SettingsAssets>("keymaps/vim.json")
|
|
}
|
|
|
|
pub fn initial_user_settings_content() -> Cow<'static, str> {
|
|
asset_str::<SettingsAssets>("settings/initial_user_settings.json")
|
|
}
|
|
|
|
pub fn initial_local_settings_content() -> Cow<'static, str> {
|
|
asset_str::<SettingsAssets>("settings/initial_local_settings.json")
|
|
}
|
|
|
|
pub fn initial_tasks_content() -> Cow<'static, str> {
|
|
asset_str::<SettingsAssets>("settings/initial_tasks.json")
|
|
}
|