@@ -64,6 +64,7 @@ impl EditorView {
6464 surface: &mut Surface,
6565 theme: &Theme,
6666 is_focused: bool,
67+ loader: &syntax::Loader,
6768 ) {
6869 let area = Rect::new(
6970 view.area.x + OFFSET,
@@ -72,7 +73,7 @@ impl EditorView {
7273 view.area.height.saturating_sub(1),
7374 ); // - 1 for statusline
7475
75− self.render_buffer(doc, view, area, surface, theme, is_focused);
76+ self.render_buffer(doc, view, area, surface, theme, is_focused, loader);
7677
7778 // if we're not at the edge of the screen, draw a right border
7879 if viewport.right() != view.area.right() {
@@ -98,6 +99,7 @@ impl EditorView {
9899 self.render_statusline(doc, view, area, surface, theme, is_focused);
99100 }
100101
102+ #[allow(clippy::too_many_arguments)]
101103 pub fn render_buffer(
102104 &self,
103105 doc: &Document,
@@ -106,6 +108,7 @@ impl EditorView {
106108 surface: &mut Surface,
107109 theme: &Theme,
108110 is_focused: bool,
111+ loader: &syntax::Loader,
109112 ) {
110113 let text = doc.text().slice(..);
111114
@@ -122,8 +125,26 @@ impl EditorView {
122125 // TODO: range doesn't actually restrict source, just highlight range
123126 let highlights: Vec<_> = match doc.syntax() {
124127 Some(syntax) => {
128+ let scopes = theme.scopes();
125129 syntax
126− .highlight_iter(text.slice(..), Some(range), None, |_| None)
130+ .highlight_iter(text.slice(..), Some(range), None, |language| {
131+ loader
132+ .language_config_for_scope(&format!("source.{}", language))
133+ .and_then(|language_config| {
134+ let config = language_config.highlight_config(scopes)?;
135+ let config_ref = config.as_ref();
136+ // SAFETY: the referenced `HighlightConfiguration` behind
137+ // the `Arc` is guaranteed to remain valid throughout the
138+ // duration of the highlight.
139+ let config_ref = unsafe {
140+ std::mem::transmute::<
141+ _,
142+ &'static syntax::HighlightConfiguration,
143+ >(config_ref)
144+ };
145+ Some(config_ref)
146+ })
147+ })
127148 .collect() // TODO: we collect here to avoid holding the lock, fix later
128149 }
129150 None => vec![Ok(HighlightEvent::Source {
@@ -719,7 +740,16 @@ impl Component for EditorView {
719740
720741 for (view, is_focused) in cx.editor.tree.views() {
721742 let doc = cx.editor.document(view.doc).unwrap();
722− self.render_view(doc, view, area, surface, &cx.editor.theme, is_focused);
743+ let loader = &cx.editor.syn_loader;
744+ self.render_view(
745+ doc,
746+ view,
747+ area,
748+ surface,
749+ &cx.editor.theme,
750+ is_focused,
751+ loader,
752+ );
723753 }
724754
725755 if let Some(info) = std::mem::take(&mut cx.editor.autoinfo) {