Skip to content

Commit 152c6ac

Browse files
committed
Add editor.colors-mode config
1 parent 45b664d commit 152c6ac

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

book/src/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ hidden = false
4545
| `auto-info` | Whether to display infoboxes | `true` |
4646
| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` |
4747
| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file. | `[]` |
48+
| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |
4849

4950
### `[editor.lsp]` Section
5051

helix-term/src/ui/editor.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl EditorView {
157157
.area
158158
.clip_top(view.area.height.saturating_sub(1))
159159
.clip_bottom(1); // -1 from bottom to remove commandline
160-
self.render_statusline(doc, view, statusline_area, surface, theme, is_focused);
160+
self.render_statusline(editor, doc, view, statusline_area, surface, is_focused);
161161
}
162162

163163
pub fn render_rulers(
@@ -688,11 +688,11 @@ impl EditorView {
688688

689689
pub fn render_statusline(
690690
&self,
691+
editor: &Editor,
691692
doc: &Document,
692693
view: &View,
693694
viewport: Rect,
694695
surface: &mut Surface,
695-
theme: &Theme,
696696
is_focused: bool,
697697
) {
698698
use tui::text::{Span, Spans};
@@ -701,6 +701,7 @@ impl EditorView {
701701
// Left side of the status line.
702702
//-------------------------------
703703

704+
let theme = &editor.theme;
704705
let (mode, mode_style) = match doc.mode() {
705706
Mode::Insert => (" INS ", theme.get("ui.statusline.insert")),
706707
Mode::Select => (" SEL ", theme.get("ui.statusline.select")),
@@ -723,7 +724,13 @@ impl EditorView {
723724
// statusline
724725
surface.set_style(viewport.with_height(1), base_style);
725726
if is_focused {
726-
surface.set_string(viewport.x, viewport.y, mode, mode_style);
727+
let color_modes = editor.config().color_modes;
728+
surface.set_string(
729+
viewport.x,
730+
viewport.y,
731+
mode,
732+
if color_modes { mode_style } else { base_style },
733+
);
727734
}
728735
surface.set_string(viewport.x + 5, viewport.y, progress, base_style);
729736

helix-view/src/editor.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ pub struct Config {
158158
pub whitespace: WhitespaceConfig,
159159
/// Vertical indent width guides.
160160
pub indent_guides: IndentGuidesConfig,
161+
/// Whether to color modes with different colors. Defaults to `false`.
162+
pub color_modes: bool,
161163
}
162164

163165
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
@@ -410,6 +412,7 @@ impl Default for Config {
410412
rulers: Vec::new(),
411413
whitespace: WhitespaceConfig::default(),
412414
indent_guides: IndentGuidesConfig::default(),
415+
color_modes: false,
413416
}
414417
}
415418
}

0 commit comments

Comments
 (0)