mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 02:37:21 +00:00
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>
39 lines
1,009 B
Rust
39 lines
1,009 B
Rust
use gpui::AppContext;
|
|
use schemars::JsonSchema;
|
|
use serde::{Deserialize, Serialize};
|
|
use settings::{Settings, SettingsSources};
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
|
pub struct WorktreeSettings {
|
|
/// Completely ignore files matching globs from `file_scan_exclusions`
|
|
///
|
|
/// Default: [
|
|
/// "**/.git",
|
|
/// "**/.svn",
|
|
/// "**/.hg",
|
|
/// "**/CVS",
|
|
/// "**/.DS_Store",
|
|
/// "**/Thumbs.db",
|
|
/// "**/.classpath",
|
|
/// "**/.settings"
|
|
/// ]
|
|
#[serde(default)]
|
|
pub file_scan_exclusions: Option<Vec<String>>,
|
|
|
|
/// Treat the files matching these globs as `.env` files.
|
|
/// Default: [ "**/.env*" ]
|
|
pub private_files: Option<Vec<String>>,
|
|
}
|
|
|
|
impl Settings for WorktreeSettings {
|
|
const KEY: Option<&'static str> = None;
|
|
|
|
type FileContent = Self;
|
|
|
|
fn load(
|
|
sources: SettingsSources<Self::FileContent>,
|
|
_: &mut AppContext,
|
|
) -> anyhow::Result<Self> {
|
|
sources.json_merge()
|
|
}
|
|
}
|