From 152c6ac1f9f2674f32a460e40ced27b77e91ebc8 Mon Sep 17 00:00:00 2001 From: Mathspy Date: Sun, 26 Jun 2022 10:28:55 -0400 Subject: [PATCH] Add editor.colors-mode config --- book/src/configuration.md | 1 + helix-term/src/ui/editor.rs | 13 ++++++++++--- helix-view/src/editor.rs | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/book/src/configuration.md b/book/src/configuration.md index 3fa9b307ab38..306b842125ea 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -45,6 +45,7 @@ hidden = false | `auto-info` | Whether to display infoboxes | `true` | | `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` | | `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file. | `[]` | +| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` | ### `[editor.lsp]` Section diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index b909410948c0..194269f0223b 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -157,7 +157,7 @@ impl EditorView { .area .clip_top(view.area.height.saturating_sub(1)) .clip_bottom(1); // -1 from bottom to remove commandline - self.render_statusline(doc, view, statusline_area, surface, theme, is_focused); + self.render_statusline(editor, doc, view, statusline_area, surface, is_focused); } pub fn render_rulers( @@ -688,11 +688,11 @@ impl EditorView { pub fn render_statusline( &self, + editor: &Editor, doc: &Document, view: &View, viewport: Rect, surface: &mut Surface, - theme: &Theme, is_focused: bool, ) { use tui::text::{Span, Spans}; @@ -701,6 +701,7 @@ impl EditorView { // Left side of the status line. //------------------------------- + let theme = &editor.theme; let (mode, mode_style) = match doc.mode() { Mode::Insert => (" INS ", theme.get("ui.statusline.insert")), Mode::Select => (" SEL ", theme.get("ui.statusline.select")), @@ -723,7 +724,13 @@ impl EditorView { // statusline surface.set_style(viewport.with_height(1), base_style); if is_focused { - surface.set_string(viewport.x, viewport.y, mode, mode_style); + let color_modes = editor.config().color_modes; + surface.set_string( + viewport.x, + viewport.y, + mode, + if color_modes { mode_style } else { base_style }, + ); } surface.set_string(viewport.x + 5, viewport.y, progress, base_style); diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index c5a458d7f7db..2c81f197b33b 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -158,6 +158,8 @@ pub struct Config { pub whitespace: WhitespaceConfig, /// Vertical indent width guides. pub indent_guides: IndentGuidesConfig, + /// Whether to color modes with different colors. Defaults to `false`. + pub color_modes: bool, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -410,6 +412,7 @@ impl Default for Config { rulers: Vec::new(), whitespace: WhitespaceConfig::default(), indent_guides: IndentGuidesConfig::default(), + color_modes: false, } } }