aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorRoland Kovacs2022-04-05 00:56:14 +0000
committerGitHub2022-04-05 00:56:14 +0000
commitd962e06e91b997813092cc5e49a800cc9d4f0ee1 (patch)
tree9ccbee392cbee6d0dc5e9c30bd73e44d5c47a444 /helix-view/src
parent6fc6f87260a2f11a892f09678fc6c10b01e88e3f (diff)
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
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/document.rs11
-rw-r--r--helix-view/src/editor.rs1
2 files changed, 11 insertions, 1 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index c9c1e502..5d739af5 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -607,6 +607,17 @@ impl Document {
self.set_language(language_config, Some(config_loader));
}
+ /// Set the programming language for the file if you know the language but don't have the
+ /// [`syntax::LanguageConfiguration`] for it.
+ pub fn set_language_by_language_id(
+ &mut self,
+ language_id: &str,
+ config_loader: Arc<syntax::Loader>,
+ ) {
+ let language_config = config_loader.language_config_for_language_id(language_id);
+ self.set_language(language_config, Some(config_loader));
+ }
+
/// Set the LSP.
pub fn set_language_server(&mut self, language_server: Option<Arc<helix_lsp::Client>>) {
self.language_server = language_server;
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 9a2b4297..c4e9ec28 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -448,7 +448,6 @@ impl Editor {
/// Refreshes the language server for a given document
pub fn refresh_language_server(&mut self, doc_id: DocumentId) -> Option<()> {
let doc = self.documents.get_mut(&doc_id)?;
- doc.detect_language(self.syn_loader.clone());
Self::launch_language_server(&mut self.language_servers, doc)
}