From e3c4edae32f6d70bf20655c7c25b3cdf39f3f281 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Thu, 25 Mar 2021 15:26:25 +0900 Subject: Add the machinery to load syntax config from TOML. It's embedded into the binary at build time for now, but it's progress. --- helix-view/src/document.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'helix-view/src/document.rs') diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 0286b2b9..0ab8abbb 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -97,7 +97,10 @@ impl Document { let mut doc = Self::new(doc); - let language_config = LOADER.language_config_for_file_name(path.as_path()); + let language_config = LOADER + .get() + .unwrap() + .language_config_for_file_name(path.as_path()); doc.set_language(language_config, scopes); // canonicalize path to absolute value @@ -161,7 +164,8 @@ impl Document { } pub fn set_language2(&mut self, scope: &str, scopes: &[String]) { - let language_config = LOADER.language_config_for_scope(scope); + let language_config = LOADER.get().unwrap().language_config_for_scope(scope); + self.set_language(language_config, scopes); } @@ -304,7 +308,7 @@ impl Document { pub fn tab_width(&self) -> usize { self.language .as_ref() - .and_then(|config| config.indent_config.as_ref()) + .and_then(|config| config.indent.as_ref()) .map(|config| config.tab_width) .unwrap_or(4) // fallback to 4 columns } @@ -313,8 +317,8 @@ impl Document { pub fn indent_unit(&self) -> &str { self.language .as_ref() - .and_then(|config| config.indent_config.as_ref()) - .map(|config| config.indent_unit.as_str()) + .and_then(|config| config.indent.as_ref()) + .map(|config| config.unit.as_str()) .unwrap_or(" ") // fallback to 2 spaces // " ".repeat(TAB_WIDTH) -- cgit v1.2.3-70-g09d2