diff options
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r-- | helix-view/src/document.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 579349ee..0ac8e80b 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -359,7 +359,7 @@ impl Document { path: &Path, encoding: Option<&'static encoding::Encoding>, theme: Option<&Theme>, - config_loader: Option<&syntax::Loader>, + config_loader: Option<Arc<syntax::Loader>>, ) -> Result<Self, Error> { // Open the file if it exists, otherwise assume it is a new file (and thus empty). let (rope, encoding) = if path.exists() { @@ -498,12 +498,12 @@ impl Document { } /// Detect the programming language based on the file type. - pub fn detect_language(&mut self, theme: Option<&Theme>, config_loader: &syntax::Loader) { + pub fn detect_language(&mut self, theme: Option<&Theme>, 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(theme, language_config); + self.set_language(theme, language_config, Some(config_loader)); } } @@ -579,11 +579,12 @@ impl Document { &mut self, theme: Option<&Theme>, language_config: Option<Arc<helix_core::syntax::LanguageConfiguration>>, + loader: Option<Arc<helix_core::syntax::Loader>>, ) { - if let Some(language_config) = language_config { + if let (Some(language_config), Some(loader)) = (language_config, loader) { let scopes = theme.map(|theme| theme.scopes()).unwrap_or(&[]); if let Some(highlight_config) = language_config.highlight_config(scopes) { - let syntax = Syntax::new(&self.text, highlight_config); + let syntax = Syntax::new(&self.text, highlight_config, loader); self.syntax = Some(syntax); // TODO: config.configure(scopes) is now delayed, is that ok? } @@ -605,7 +606,7 @@ impl Document { ) { let language_config = config_loader.language_config_for_scope(scope); - self.set_language(theme, language_config); + self.set_language(theme, language_config, Some(config_loader)); } /// Set the LSP. |