Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-loader/src/config.rs')
-rw-r--r--helix-loader/src/config.rs41
1 files changed, 24 insertions, 17 deletions
diff --git a/helix-loader/src/config.rs b/helix-loader/src/config.rs
index 1f414de6..04bb55bf 100644
--- a/helix-loader/src/config.rs
+++ b/helix-loader/src/config.rs
@@ -1,5 +1,7 @@
use std::str::from_utf8;
+use crate::workspace_trust::{quick_query_workspace, TrustStatus};
+
/// Default built-in languages.toml.
pub fn default_lang_config() -> toml::Value {
let default_config = include_bytes!("../../languages.toml");
@@ -8,23 +10,28 @@ pub fn default_lang_config() -> toml::Value {
}
/// User configured languages.toml file, merged with the default config.
-pub fn user_lang_config() -> Result<toml::Value, toml::de::Error> {
- let config = [
- crate::config_dir(),
- crate::find_workspace().0.join(".helix"),
- ]
- .into_iter()
- .map(|path| path.join("languages.toml"))
- .filter_map(|file| {
- std::fs::read_to_string(file)
- .map(|config| toml::from_str(&config))
- .ok()
- })
- .collect::<Result<Vec<_>, _>>()?
- .into_iter()
- .fold(default_lang_config(), |a, b| {
- crate::merge_toml_values(a, b, 3)
- });
+pub fn user_lang_config(insecure: bool) -> Result<toml::Value, toml::de::Error> {
+ let global_config = crate::lang_config_file();
+ let workspace_config = crate::workspace_lang_config_file();
+
+ let files = if let TrustStatus::Trusted = quick_query_workspace(insecure) {
+ vec![global_config, workspace_config]
+ } else {
+ vec![global_config]
+ };
+
+ let config = files
+ .iter()
+ .filter_map(|file| {
+ std::fs::read_to_string(file)
+ .map(|config| toml::from_str(&config))
+ .ok()
+ })
+ .collect::<Result<Vec<_>, _>>()?
+ .into_iter()
+ .fold(default_lang_config(), |a, b| {
+ crate::merge_toml_values(a, b, 3)
+ });
Ok(config)
}