diff options
author | Blaž Hrastnik | 2021-03-25 06:26:25 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-25 06:26:25 +0000 |
commit | e3c4edae32f6d70bf20655c7c25b3cdf39f3f281 (patch) | |
tree | 5351a5a797de5f213b87f25ae4ba049c8e74d11b /helix-view/src | |
parent | a900159a863c24e4afb1485d8dcff760f722f36b (diff) |
Add the machinery to load syntax config from TOML.
It's embedded into the binary at build time for now, but it's progress.
Diffstat (limited to 'helix-view/src')
-rw-r--r-- | helix-view/src/document.rs | 14 |
1 files changed, 9 insertions, 5 deletions
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) |