From 8961ae1dc66633ea6c9f761896cb0d885ae078ed Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 29 May 2025 09:53:12 -0400 Subject: [PATCH] Consistently use `helix_core::config::default_{lang,config}_loader` This avoids using any custom configuration in a user-defined `languages.toml` config for the syntax test cases. The test cases should only use the builtin `languages.toml` config. Also the xtask crate reimplemented `default_lang_loader` and `default_lang_config`. These functions are replaced with calls into `helix_core`. --- helix-core/src/syntax.rs | 2 +- xtask/src/docgen.rs | 2 +- xtask/src/helpers.rs | 10 ---------- xtask/src/main.rs | 2 +- xtask/src/path.rs | 4 ---- 5 files changed, 3 insertions(+), 17 deletions(-) diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 57b9e5c3..ac689eb3 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -964,7 +964,7 @@ mod test { use super::*; use crate::{Rope, Transaction}; - static LOADER: Lazy = Lazy::new(|| crate::config::user_lang_loader().unwrap()); + static LOADER: Lazy = Lazy::new(crate::config::default_lang_loader); #[test] fn test_textobject_queries() { diff --git a/xtask/src/docgen.rs b/xtask/src/docgen.rs index 2b58e732..d31c396d 100644 --- a/xtask/src/docgen.rs +++ b/xtask/src/docgen.rs @@ -129,7 +129,7 @@ pub fn lang_features() -> Result { cols.push("Default language servers".to_owned()); md.push_str(&md_table_heading(&cols)); - let config = helpers::lang_config(); + let config = helix_core::config::default_lang_config(); let mut langs = config .language diff --git a/xtask/src/helpers.rs b/xtask/src/helpers.rs index 9bdca561..0156f253 100644 --- a/xtask/src/helpers.rs +++ b/xtask/src/helpers.rs @@ -1,7 +1,6 @@ use std::path::{Path, PathBuf}; use crate::path; -use helix_core::syntax::{self, config::Configuration as LangConfig}; use helix_term::health::TsFeature; /// Get the list of languages that support a particular tree-sitter @@ -37,12 +36,3 @@ pub fn find_files(dir: &Path, filename: &str) -> Vec { .flatten() .collect() } - -pub fn lang_config() -> LangConfig { - let text = std::fs::read_to_string(path::lang_config()).unwrap(); - toml::from_str(&text).unwrap() -} - -pub fn syn_loader() -> syntax::Loader { - syntax::Loader::new(lang_config()).unwrap() -} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index c6875d95..d4995ce3 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -22,7 +22,7 @@ pub mod tasks { use helix_core::syntax::LanguageData; let languages_to_check: HashSet<_> = languages.collect(); - let loader = crate::helpers::syn_loader(); + let loader = helix_core::config::default_lang_loader(); for (_language, lang_data) in loader.languages() { if !languages_to_check.is_empty() && !languages_to_check.contains(&lang_data.config().language_id) diff --git a/xtask/src/path.rs b/xtask/src/path.rs index cf8e8792..a46bdda0 100644 --- a/xtask/src/path.rs +++ b/xtask/src/path.rs @@ -22,7 +22,3 @@ pub fn ts_queries() -> PathBuf { pub fn themes() -> PathBuf { runtime().join("themes") } - -pub fn lang_config() -> PathBuf { - project_root().join("languages.toml") -}