@@ -64,6 +64,7 @@ impl EditorView {
64 surface: &mut Surface,
64 surface: &mut Surface,
65 theme: &Theme,
65 theme: &Theme,
66 is_focused: bool,
66 is_focused: bool,
67+ loader: &syntax::Loader,
68 let area = Rect::new(
69 let area = Rect::new(
69 view.area.x + OFFSET,
70 view.area.x + OFFSET,
@@ -72,7 +73,7 @@ impl EditorView {
72 view.area.height.saturating_sub(1),
73 view.area.height.saturating_sub(1),
73 ); // - 1 for statusline
74 ); // - 1 for statusline
75− self.render_buffer(doc, view, area, surface, theme, is_focused);
76+ self.render_buffer(doc, view, area, surface, theme, is_focused, loader);
77 // if we're not at the edge of the screen, draw a right border
78 // if we're not at the edge of the screen, draw a right border
78 if viewport.right() != view.area.right() {
79 if viewport.right() != view.area.right() {
@@ -98,6 +99,7 @@ impl EditorView {
98 self.render_statusline(doc, view, area, surface, theme, is_focused);
99 self.render_statusline(doc, view, area, surface, theme, is_focused);
102+ #[allow(clippy::too_many_arguments)]
101 pub fn render_buffer(
103 pub fn render_buffer(
103 doc: &Document,
105 doc: &Document,
@@ -106,6 +108,7 @@ impl EditorView {
106 surface: &mut Surface,
108 surface: &mut Surface,
107 theme: &Theme,
109 theme: &Theme,
108 is_focused: bool,
110 is_focused: bool,
111+ loader: &syntax::Loader,
110 let text = doc.text().slice(..);
113 let text = doc.text().slice(..);
@@ -122,8 +125,26 @@ impl EditorView {
122 // TODO: range doesn't actually restrict source, just highlight range
125 // TODO: range doesn't actually restrict source, just highlight range
123 let highlights: Vec<_> = match doc.syntax() {
126 let highlights: Vec<_> = match doc.syntax() {
124 Some(syntax) => {
127 Some(syntax) => {
128+ let scopes = theme.scopes();
126− .highlight_iter(text.slice(..), Some(range), None, |_| None)
130+ .highlight_iter(text.slice(..), Some(range), None, |language| {
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::<
142+ &'static syntax::HighlightConfiguration,
127 .collect() // TODO: we collect here to avoid holding the lock, fix later
148 .collect() // TODO: we collect here to avoid holding the lock, fix later
129 None => vec![Ok(HighlightEvent::Source {
150 None => vec![Ok(HighlightEvent::Source {
@@ -719,7 +740,16 @@ impl Component for EditorView {
720 for (view, is_focused) in cx.editor.tree.views() {
741 for (view, is_focused) in cx.editor.tree.views() {
721 let doc = cx.editor.document(view.doc).unwrap();
742 let doc = cx.editor.document(view.doc).unwrap();
743+ let loader = &cx.editor.syn_loader;
722− self.render_view(doc, view, area, surface, &cx.editor.theme, is_focused);
744+ self.render_view(
725 if let Some(info) = std::mem::take(&mut cx.editor.autoinfo) {
755 if let Some(info) = std::mem::take(&mut cx.editor.autoinfo) {