aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/document.rs17
-rw-r--r--helix-view/src/editor.rs11
2 files changed, 8 insertions, 20 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 0ac8e80b..0b5cfd22 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -19,7 +19,7 @@ use helix_core::{
};
use helix_lsp::util::LspFormatting;
-use crate::{DocumentId, Theme, ViewId};
+use crate::{DocumentId, ViewId};
/// 8kB of buffer space for encoding and decoding `Rope`s.
const BUF_SIZE: usize = 8192;
@@ -358,7 +358,6 @@ impl Document {
pub fn open(
path: &Path,
encoding: Option<&'static encoding::Encoding>,
- theme: Option<&Theme>,
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).
@@ -376,7 +375,7 @@ impl Document {
// set the path and try detecting the language
doc.set_path(Some(path))?;
if let Some(loader) = config_loader {
- doc.detect_language(theme, loader);
+ doc.detect_language(loader);
}
doc.detect_indent_and_line_ending();
@@ -498,12 +497,12 @@ impl Document {
}
/// Detect the programming language based on the file type.
- pub fn detect_language(&mut self, theme: Option<&Theme>, config_loader: Arc<syntax::Loader>) {
+ 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(theme, language_config, Some(config_loader));
+ self.set_language(language_config, Some(config_loader));
}
}
@@ -577,16 +576,13 @@ impl Document {
/// if it exists.
pub fn set_language(
&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), Some(loader)) = (language_config, loader) {
- let scopes = theme.map(|theme| theme.scopes()).unwrap_or(&[]);
- if let Some(highlight_config) = language_config.highlight_config(scopes) {
+ if let Some(highlight_config) = language_config.highlight_config(&loader.scopes()) {
let syntax = Syntax::new(&self.text, highlight_config, loader);
self.syntax = Some(syntax);
- // TODO: config.configure(scopes) is now delayed, is that ok?
}
self.language = Some(language_config);
@@ -601,12 +597,11 @@ impl Document {
pub fn set_language2(
&mut self,
scope: &str,
- theme: Option<&Theme>,
config_loader: Arc<syntax::Loader>,
) {
let language_config = config_loader.language_config_for_scope(scope);
- self.set_language(theme, language_config, Some(config_loader));
+ self.set_language(language_config, Some(config_loader));
}
/// Set the LSP.
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 9ad1558b..caf2bce7 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -268,13 +268,7 @@ impl Editor {
}
let scopes = theme.scopes();
- for config in self
- .syn_loader
- .language_configs_iter()
- .filter(|cfg| cfg.is_highlight_initialized())
- {
- config.reconfigure(scopes);
- }
+ self.syn_loader.set_scopes(scopes.to_vec());
self.theme = theme;
self._refresh();
@@ -283,7 +277,7 @@ 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(Some(&self.theme), self.syn_loader.clone());
+ doc.detect_language(self.syn_loader.clone());
Self::launch_language_server(&mut self.language_servers, doc)
}
@@ -465,7 +459,6 @@ impl Editor {
let mut doc = Document::open(
&path,
None,
- Some(&self.theme),
Some(self.syn_loader.clone()),
)?;