From d962e06e91b997813092cc5e49a800cc9d4f0ee1 Mon Sep 17 00:00:00 2001 From: Roland Kovacs Date: Tue, 5 Apr 2022 02:56:14 +0200 Subject: Add runtime language configuration (#1794) (#1866) * Add runtime language configuration (#1794) * Add set-language typable command to change the language of current buffer. * Add completer for available language options. * Update set-language to refresh language server as well * Add language id based config lookup on `syntax::Loader`. * Add `Document::set_language3` to set programming language based on language id. * Update `Editor::refresh_language_server` to try language detection only if language is not already set. * Remove language detection from Editor::refresh_language_server * Move document language detection to where the scratch buffer is saved. * Rename Document::set_language3 to Document::set_language_by_language_id. * Remove unnecessary clone in completers::language--- helix-core/src/syntax.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'helix-core/src') diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index e736b370..bb0073e1 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -504,6 +504,13 @@ impl Loader { .cloned() } + pub fn language_config_for_language_id(&self, id: &str) -> Option> { + self.language_configs + .iter() + .find(|config| config.language_id == id) + .cloned() + } + pub fn language_configuration_for_injection_string( &self, string: &str, @@ -529,6 +536,10 @@ impl Loader { None } + pub fn language_configs(&self) -> impl Iterator> { + self.language_configs.iter() + } + pub fn set_scopes(&self, scopes: Vec) { self.scopes.store(Arc::new(scopes)); -- cgit v1.2.3-70-g09d2