diff options
author | Blaž Hrastnik | 2020-10-14 09:07:42 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-10-14 09:07:42 +0000 |
commit | 6e658aae1c05fdd9f9ee36b39a948028bcaad446 (patch) | |
tree | 7d703103fbf12f64928a72746cd8c6aa29260c42 /helix-core/src/state.rs | |
parent | 6ae3c26def0e4fe4b3e4ce21f1e8d569c627e738 (diff) |
Auto-indent on enter based on tree-sitter scopes.
Diffstat (limited to 'helix-core/src/state.rs')
-rw-r--r-- | helix-core/src/state.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/helix-core/src/state.rs b/helix-core/src/state.rs index 7035b27c..1b0a67ae 100644 --- a/helix-core/src/state.rs +++ b/helix-core/src/state.rs @@ -86,6 +86,17 @@ impl State { Ok(state) } + pub fn set_language(&mut self, scope: &str, scopes: &[String]) { + if let Some(language_config) = LOADER.language_config_for_scope(scope) { + let highlight_config = language_config.highlight_config(scopes).unwrap().unwrap(); + // TODO: config.configure(scopes) is now delayed, is that ok? + + let syntax = Syntax::new(&self.doc, highlight_config.clone()); + + self.syntax = Some(syntax); + }; + } + // TODO: doc/selection accessors // TODO: be able to take either Rope or RopeSlice |