on master help sign in
Add mode specific styles (#2676)
d06800fMathspy
book/src/configuration.md+1
@@ -46,6 +46,7 @@ hidden = false
46| `auto-info` | Whether to display infoboxes | `true` |
46| `auto-info` | Whether to display infoboxes | `true` |
47| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` |
47| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` |
48| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file. | `[]` |
48| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file. | `[]` |
49+| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |
49
50
50### `[editor.lsp]` Section
51### `[editor.lsp]` Section
51
52
book/src/themes.md+5−2
@@ -219,6 +219,9 @@ These scopes are used for theming the editor interface.
219| `ui.linenr.selected` | Line number for the line the cursor is on |
219| `ui.linenr.selected` | Line number for the line the cursor is on |
220| `ui.statusline` | Statusline |
220| `ui.statusline` | Statusline |
221| `ui.statusline.inactive` | Statusline (unfocused document) |
221| `ui.statusline.inactive` | Statusline (unfocused document) |
222+| `ui.statusline.normal` | Statusline mode during normal mode ([only if `editor.color-modes` is enabled][editor-section]) |
223+| `ui.statusline.insert` | Statusline mode during insert mode ([only if `editor.color-modes` is enabled][editor-section]) |
224+| `ui.statusline.select` | Statusline mode during select mode ([only if `editor.color-modes` is enabled][editor-section]) |
222| `ui.popup` | Documentation popups (e.g space-k) |
225| `ui.popup` | Documentation popups (e.g space-k) |
223| `ui.popup.info` | Prompt for multiple key options |
226| `ui.popup.info` | Prompt for multiple key options |
224| `ui.window` | Border lines separating splits |
227| `ui.window` | Border lines separating splits |
@@ -226,7 +229,7 @@ These scopes are used for theming the editor interface.
226| `ui.text` | Command prompts, popup text, etc. |
229| `ui.text` | Command prompts, popup text, etc. |
227| `ui.text.focus` | |
230| `ui.text.focus` | |
228| `ui.text.info` | The key: command text in `ui.popup.info` boxes |
231| `ui.text.info` | The key: command text in `ui.popup.info` boxes |
229−| `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][rulers-config])|
232+| `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][editor-section])|
230| `ui.virtual.whitespace` | Visible white-space characters |
233| `ui.virtual.whitespace` | Visible white-space characters |
231| `ui.virtual.indent-guide` | Vertical indent width guides |
234| `ui.virtual.indent-guide` | Vertical indent width guides |
232| `ui.menu` | Code and command completion menus |
235| `ui.menu` | Code and command completion menus |
@@ -246,4 +249,4 @@ These scopes are used for theming the editor interface.
246| `diagnostic.warning` | Diagnostics warning (editing area) |
249| `diagnostic.warning` | Diagnostics warning (editing area) |
247| `diagnostic.error` | Diagnostics error (editing area) |
250| `diagnostic.error` | Diagnostics error (editing area) |
248
251
249−[rulers-config]: ./configuration.md#editor-section
252+[editor-section]: ./configuration.md#editor-section
helix-term/src/ui/editor.rs+14−7
@@ -161,7 +161,7 @@ impl EditorView {
161 .area
161 .area
162 .clip_top(view.area.height.saturating_sub(1))
162 .clip_top(view.area.height.saturating_sub(1))
163 .clip_bottom(1); // -1 from bottom to remove commandline
163 .clip_bottom(1); // -1 from bottom to remove commandline
164− self.render_statusline(doc, view, statusline_area, surface, theme, is_focused);
164+ self.render_statusline(editor, doc, view, statusline_area, surface, is_focused);
165 }
165 }
166
166
167 pub fn render_rulers(
167 pub fn render_rulers(
@@ -732,11 +732,11 @@ impl EditorView {
732
732
733 pub fn render_statusline(
733 pub fn render_statusline(
734 &self,
734 &self,
735+ editor: &Editor,
735 doc: &Document,
736 doc: &Document,
736 view: &View,
737 view: &View,
737 viewport: Rect,
738 viewport: Rect,
738 surface: &mut Surface,
739 surface: &mut Surface,
739− theme: &Theme,
740 is_focused: bool,
740 is_focused: bool,
741 ) {
741 ) {
742 use tui::text::{Span, Spans};
742 use tui::text::{Span, Spans};
@@ -745,10 +745,11 @@ impl EditorView {
745 // Left side of the status line.
745 // Left side of the status line.
746 //-------------------------------
746 //-------------------------------
747
747
748+ let theme = &editor.theme;
748− let mode = match doc.mode() {
749+ let (mode, mode_style) = match doc.mode() {
749− Mode::Insert => "INS",
750+ Mode::Insert => (" INS ", theme.get("ui.statusline.insert")),
750− Mode::Select => "SEL",
751+ Mode::Select => (" SEL ", theme.get("ui.statusline.select")),
751− Mode::Normal => "NOR",
752+ Mode::Normal => (" NOR ", theme.get("ui.statusline.normal")),
752 };
753 };
753 let progress = doc
754 let progress = doc
754 .language_server()
755 .language_server()
@@ -767,7 +768,13 @@ impl EditorView {
767 // statusline
768 // statusline
768 surface.set_style(viewport.with_height(1), base_style);
769 surface.set_style(viewport.with_height(1), base_style);
769 if is_focused {
770 if is_focused {
771+ let color_modes = editor.config().color_modes;
770− surface.set_string(viewport.x + 1, viewport.y, mode, base_style);
772+ surface.set_string(
773+ viewport.x,
774+ viewport.y,
775+ mode,
776+ if color_modes { mode_style } else { base_style },
777+ );
771 }
778 }
772 surface.set_string(viewport.x + 5, viewport.y, progress, base_style);
779 surface.set_string(viewport.x + 5, viewport.y, progress, base_style);
773
780
helix-view/src/editor.rs+3
@@ -161,6 +161,8 @@ pub struct Config {
161 pub whitespace: WhitespaceConfig,
161 pub whitespace: WhitespaceConfig,
162 /// Vertical indent width guides.
162 /// Vertical indent width guides.
163 pub indent_guides: IndentGuidesConfig,
163 pub indent_guides: IndentGuidesConfig,
164+ /// Whether to color modes with different colors. Defaults to `false`.
165+ pub color_modes: bool,
164}
166}
165
167
166#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
168#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
@@ -414,6 +416,7 @@ impl Default for Config {
414 rulers: Vec::new(),
416 rulers: Vec::new(),
415 whitespace: WhitespaceConfig::default(),
417 whitespace: WhitespaceConfig::default(),
416 indent_guides: IndentGuidesConfig::default(),
418 indent_guides: IndentGuidesConfig::default(),
419+ color_modes: false,
417 }
420 }
418 }
421 }
419}
422}
runtime/themes/rose_pine.toml+3
@@ -9,6 +9,9 @@
9"ui.selection" = { bg = "highlight" }
9"ui.selection" = { bg = "highlight" }
10"comment" = "subtle"
10"comment" = "subtle"
11"ui.statusline" = {fg = "foam", bg = "surface" }
11"ui.statusline" = {fg = "foam", bg = "surface" }
12+"ui.statusline.insert" = {fg = "base", bg = "foam", modifiers = ["bold"]}
13+"ui.statusline.normal" = {fg = "base", bg = "rose", modifiers = ["bold"]}
14+"ui.statusline.select" = {fg = "base", bg = "iris", modifiers = ["bold"]}
12"ui.statusline.inactive" = { fg = "iris", bg = "surface" }
15"ui.statusline.inactive" = { fg = "iris", bg = "surface" }
13"ui.cursor" = { fg = "rose", modifiers = ["reversed"] }
16"ui.cursor" = { fg = "rose", modifiers = ["reversed"] }
14"ui.text" = { fg = "text" }
17"ui.text" = { fg = "text" }