@@ -95,17 +95,25 @@ impl EditorView {
9595 let mut decorations = DecorationManager :: default ( ) ;
9696
9797 if is_focused && config. cursorline {
98- decorations. add_decoration ( Self :: cursorline ( doc, view, theme) ) ;
98+ decorations. add_decoration ( Self :: cursorline ( editor , doc, view, theme) ) ;
9999 }
100100
101101 if is_focused && config. cursorcolumn {
102- Self :: highlight_cursorcolumn ( doc, view, surface, theme, inner, & text_annotations) ;
102+ Self :: highlight_cursorcolumn (
103+ editor,
104+ doc,
105+ view,
106+ surface,
107+ theme,
108+ inner,
109+ & text_annotations,
110+ ) ;
103111 }
104112
105113 // Set DAP highlights, if needed.
106114 if let Some ( frame) = editor. current_stack_frame ( ) {
107115 let dap_line = frame. line . saturating_sub ( 1 ) ;
108- let style = theme. get ( "ui.highlight.frameline" ) ;
116+ let style = theme. get ( editor . mode , "ui.highlight.frameline" ) ;
109117 let line_decoration = move |renderer : & mut TextRenderer , pos : LinePos | {
110118 if pos. doc_line != dap_line {
111119 return ;
@@ -192,11 +200,13 @@ impl EditorView {
192200 decorations. add_decoration ( InlineDiagnostics :: new (
193201 doc,
194202 theme,
203+ editor. mode ,
195204 primary_cursor,
196205 inline_diagnostic_config,
197206 config. end_of_line_diagnostics ,
198207 ) ) ;
199208 render_document (
209+ editor,
200210 surface,
201211 inner,
202212 doc,
@@ -211,7 +221,7 @@ impl EditorView {
211221 // if we're not at the edge of the screen, draw a right border
212222 if viewport. right ( ) != view. area . right ( ) {
213223 let x = area. right ( ) ;
214- let border_style = theme. get ( "ui.window" ) ;
224+ let border_style = theme. get ( editor . mode , "ui.window" ) ;
215225 for y in area. top ( ) ..area. bottom ( ) {
216226 surface[ ( x, y) ]
217227 . set_symbol ( tui:: symbols:: line:: VERTICAL )
@@ -223,7 +233,7 @@ impl EditorView {
223233 if config. inline_diagnostics . disabled ( )
224234 && config. end_of_line_diagnostics == DiagnosticFilter :: Disable
225235 {
226- Self :: render_diagnostics ( doc, view, inner, surface, theme) ;
236+ Self :: render_diagnostics ( editor , doc, view, inner, surface, theme) ;
227237 }
228238
229239 let statusline_area = view
@@ -247,7 +257,7 @@ impl EditorView {
247257 ) {
248258 let editor_rulers = & editor. config ( ) . rulers ;
249259 let ruler_theme = theme
250- . try_get ( "ui.virtual.ruler" )
260+ . try_get ( editor . mode , "ui.virtual.ruler" )
251261 . unwrap_or_else ( || Style :: default ( ) . bg ( Color :: Red ) ) ;
252262
253263 let rulers = doc
@@ -598,19 +608,19 @@ impl EditorView {
598608 viewport,
599609 editor
600610 . theme
601- . try_get ( "ui.bufferline.background" )
602- . unwrap_or_else ( || editor. theme . get ( "ui.statusline" ) ) ,
611+ . try_get ( editor . mode , "ui.bufferline.background" )
612+ . unwrap_or_else ( || editor. theme . get ( editor . mode , "ui.statusline" ) ) ,
603613 ) ;
604614
605615 let bufferline_active = editor
606616 . theme
607- . try_get ( "ui.bufferline.active" )
608- . unwrap_or_else ( || editor. theme . get ( "ui.statusline.active" ) ) ;
617+ . try_get ( editor . mode , "ui.bufferline.active" )
618+ . unwrap_or_else ( || editor. theme . get ( editor . mode , "ui.statusline.active" ) ) ;
609619
610620 let bufferline_inactive = editor
611621 . theme
612- . try_get ( "ui.bufferline" )
613- . unwrap_or_else ( || editor. theme . get ( "ui.statusline.inactive" ) ) ;
622+ . try_get ( editor . mode , "ui.bufferline" )
623+ . unwrap_or_else ( || editor. theme . get ( editor . mode , "ui.statusline.inactive" ) ) ;
614624
615625 let mut x = viewport. x ;
616626 let current_doc = view ! ( editor) . doc ;
@@ -662,10 +672,10 @@ impl EditorView {
662672
663673 let mut offset = 0 ;
664674
665- let gutter_style = theme. get ( "ui.gutter" ) ;
666- let gutter_selected_style = theme. get ( "ui.gutter.selected" ) ;
667- let gutter_style_virtual = theme. get ( "ui.gutter.virtual" ) ;
668- let gutter_selected_style_virtual = theme. get ( "ui.gutter.selected.virtual" ) ;
675+ let gutter_style = theme. get ( editor . mode , "ui.gutter" ) ;
676+ let gutter_selected_style = theme. get ( editor . mode , "ui.gutter.selected" ) ;
677+ let gutter_style_virtual = theme. get ( editor . mode , "ui.gutter.virtual" ) ;
678+ let gutter_selected_style_virtual = theme. get ( editor . mode , "ui.gutter.selected.virtual" ) ;
669679
670680 for gutter_type in view. gutters ( ) {
671681 let mut gutter = gutter_type. style ( editor, doc, view, theme, is_focused) ;
@@ -710,6 +720,7 @@ impl EditorView {
710720 }
711721
712722 pub fn render_diagnostics (
723+ editor : & Editor ,
713724 doc : & Document ,
714725 view : & View ,
715726 viewport : Rect ,
@@ -732,13 +743,13 @@ impl EditorView {
732743 diagnostic. range . start <= cursor && diagnostic. range . end >= cursor
733744 } ) ;
734745
735- let warning = theme. get ( "warning" ) ;
736- let error = theme. get ( "error" ) ;
737- let info = theme. get ( "info" ) ;
738- let hint = theme. get ( "hint" ) ;
746+ let warning = theme. get ( editor . mode , "warning" ) ;
747+ let error = theme. get ( editor . mode , "error" ) ;
748+ let info = theme. get ( editor . mode , "info" ) ;
749+ let hint = theme. get ( editor . mode , "hint" ) ;
739750
740751 let mut lines = Vec :: new ( ) ;
741- let background_style = theme. get ( "ui.background" ) ;
752+ let background_style = theme. get ( editor . mode , "ui.background" ) ;
742753 for diagnostic in diagnostics {
743754 let style = Style :: reset ( )
744755 . patch ( background_style)
@@ -773,7 +784,12 @@ impl EditorView {
773784 }
774785
775786 /// Apply the highlighting on the lines where a cursor is active
776- pub fn cursorline ( doc : & Document , view : & View , theme : & Theme ) -> impl Decoration {
787+ pub fn cursorline (
788+ editor : & Editor ,
789+ doc : & Document ,
790+ view : & View ,
791+ theme : & Theme ,
792+ ) -> impl Decoration {
777793 let text = doc. text ( ) . slice ( ..) ;
778794 // TODO only highlight the visual line that contains the cursor instead of the full visual line
779795 let primary_line = doc. selection ( view. id ) . primary ( ) . cursor_line ( text) ;
@@ -790,8 +806,8 @@ impl EditorView {
790806 . map ( |range| range. cursor_line ( text) )
791807 . collect ( ) ;
792808
793- let primary_style = theme. get ( "ui.cursorline.primary" ) ;
794- let secondary_style = theme. get ( "ui.cursorline.secondary" ) ;
809+ let primary_style = theme. get ( editor . mode , "ui.cursorline.primary" ) ;
810+ let secondary_style = theme. get ( editor . mode , "ui.cursorline.secondary" ) ;
795811 let viewport = view. area ;
796812
797813 move |renderer : & mut TextRenderer , pos : LinePos | {
@@ -806,6 +822,7 @@ impl EditorView {
806822
807823 /// Apply the highlighting on the columns where a cursor is active
808824 pub fn highlight_cursorcolumn (
825+ editor : & Editor ,
809826 doc : & Document ,
810827 view : & View ,
811828 surface : & mut Surface ,
@@ -818,13 +835,13 @@ impl EditorView {
818835 // Manual fallback behaviour:
819836 // ui.cursorcolumn.{p/s} -> ui.cursorcolumn -> ui.cursorline.{p/s}
820837 let primary_style = theme
821- . try_get_exact ( "ui.cursorcolumn.primary" )
822- . or_else ( || theme. try_get_exact ( "ui.cursorcolumn" ) )
823- . unwrap_or_else ( || theme. get ( "ui.cursorline.primary" ) ) ;
838+ . try_get_exact ( editor . mode , "ui.cursorcolumn.primary" )
839+ . or_else ( || theme. try_get_exact ( editor . mode , "ui.cursorcolumn" ) )
840+ . unwrap_or_else ( || theme. get ( editor . mode , "ui.cursorline.primary" ) ) ;
824841 let secondary_style = theme
825- . try_get_exact ( "ui.cursorcolumn.secondary" )
826- . or_else ( || theme. try_get_exact ( "ui.cursorcolumn" ) )
827- . unwrap_or_else ( || theme. get ( "ui.cursorline.secondary" ) ) ;
842+ . try_get_exact ( editor . mode , "ui.cursorcolumn.secondary" )
843+ . or_else ( || theme. try_get_exact ( editor . mode , "ui.cursorcolumn" ) )
844+ . unwrap_or_else ( || theme. get ( editor . mode , "ui.cursorline.secondary" ) ) ;
828845
829846 let inner_area = view. inner_area ( doc) ;
830847
@@ -1524,7 +1541,7 @@ impl Component for EditorView {
15241541
15251542 fn render ( & mut self , area : Rect , surface : & mut Surface , cx : & mut Context ) {
15261543 // clear with background color
1527- surface. set_style ( area, cx. editor . theme . get ( "ui.background" ) ) ;
1544+ surface. set_style ( area, cx. editor . theme . get ( cx . editor . mode , "ui.background" ) ) ;
15281545 let config = cx. editor . config ( ) ;
15291546
15301547 // check if bufferline should be rendered
@@ -1568,9 +1585,9 @@ impl Component for EditorView {
15681585 status_msg_width = status_msg. width ( ) ;
15691586 use helix_view:: editor:: Severity ;
15701587 let style = if * severity == Severity :: Error {
1571- cx. editor . theme . get ( "error" )
1588+ cx. editor . theme . get ( cx . editor . mode , "error" )
15721589 } else {
1573- cx. editor . theme . get ( "ui.text" )
1590+ cx. editor . theme . get ( cx . editor . mode , "ui.text" )
15741591 } ;
15751592
15761593 surface. set_string (
@@ -1592,7 +1609,7 @@ impl Component for EditorView {
15921609 for key in & self . pseudo_pending {
15931610 disp. push_str ( & key. key_sequence_format ( ) ) ;
15941611 }
1595- let style = cx. editor . theme . get ( "ui.text" ) ;
1612+ let style = cx. editor . theme . get ( cx . editor . mode , "ui.text" ) ;
15961613 let macro_width = if cx. editor . macro_recording . is_some ( ) {
15971614 3
15981615 } else {
0 commit comments