aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorPascal Kuthe2023-05-12 14:42:00 +0000
committerBlaž Hrastnik2023-05-18 06:23:37 +0000
commit2f2306475cac7ee9385b816424137421c13bf4c2 (patch)
tree13203943b250e2cb9f7acb5ec2388863a8b8177c /helix-view/src
parentc6f169b1f87d01d72713e84bd331743e4da40f5f (diff)
async picker syntax highlighting
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/document.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index e29e52cc..770341dc 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -154,9 +154,9 @@ pub struct Document {
/// The document's default line ending.
pub line_ending: LineEnding,
- syntax: Option<Syntax>,
+ pub syntax: Option<Syntax>,
/// Corresponding language scope name. Usually `source.<lang>`.
- pub(crate) language: Option<Arc<LanguageConfiguration>>,
+ pub language: Option<Arc<LanguageConfiguration>>,
/// Pending changes since last history commit.
changes: ChangeSet,
@@ -869,12 +869,20 @@ impl Document {
/// Detect the programming language based on the file type.
pub fn detect_language(&mut self, config_loader: Arc<syntax::Loader>) {
- if let Some(path) = &self.path {
- let language_config = config_loader
- .language_config_for_file_name(path)
- .or_else(|| config_loader.language_config_for_shebang(self.text()));
- self.set_language(language_config, Some(config_loader));
- }
+ self.set_language(
+ self.detect_language_config(&config_loader),
+ Some(config_loader),
+ );
+ }
+
+ /// Detect the programming language based on the file type.
+ pub fn detect_language_config(
+ &self,
+ config_loader: &syntax::Loader,
+ ) -> Option<Arc<helix_core::syntax::LanguageConfiguration>> {
+ config_loader
+ .language_config_for_file_name(self.path.as_ref()?)
+ .or_else(|| config_loader.language_config_for_shebang(self.text()))
}
/// Detect the indentation used in the file, or otherwise defaults to the language indentation