From 08ee949dcb904dc27aa41a62ad686c14c0a406bb Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 14 Feb 2022 23:23:01 -0600 Subject: add 'use-grammars' to languages.toml The vision with 'use-grammars' is to allow the long-requested feature of being able to declare your own set of grammars that you would like. A simple schema with only/except grammar names controls the list of grammars that is fetched and built. It does not (yet) control which grammars may be loaded at runtime if they already exist. --- helix-core/src/indent.rs | 1 + helix-core/src/syntax.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'helix-core') diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index ba02065c..ee9cbb16 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -445,6 +445,7 @@ where auto_pairs: None, }], grammar: vec![], + grammar_selection: None, }); // set runtime path so we can find the queries diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 52239d10..28aa31f9 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -81,12 +81,21 @@ where } #[derive(Debug, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] +#[serde(rename_all = "kebab-case", deny_unknown_fields)] pub struct Configuration { + #[serde(rename = "use-grammars")] + pub grammar_selection: Option, pub language: Vec, pub grammar: Vec, } +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "lowercase", untagged)] +pub enum GrammarSelection { + Only(HashSet), + Except(HashSet), +} + // largely based on tree-sitter/cli/src/loader.rs #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "kebab-case", deny_unknown_fields)] @@ -2110,6 +2119,7 @@ mod test { let loader = Loader::new(Configuration { language: vec![], grammar: vec![], + grammar_selection: None, }); let language = get_language(&crate::RUNTIME_DIR, "Rust").unwrap(); -- cgit v1.2.3-70-g09d2