Theme-able Vim Mode wrapper (#39813)

Closes [#14093](https://github.com/zed-industries/zed/issues/14093)
Builds on [#32279](https://github.com/zed-industries/zed/pull/32279) by
making it theme dependent.
Discussion
[#37816](https://github.com/zed-industries/zed/discussions/37816)

Wraps the mode label indicator in a div and makes the wrapper and label
theme-able. Label weight to medium
Mode indicator will render like previously if not theme colors have been
set. (i.e., they match zed default- and fallbacks)
Really helps with visual confirmation of current mode.

_Did not investigate further if there is a way to keep the leading and
trailing -- if no theme var given._

Can be applied either by a theme itself or using `theme_overrides` in
settings.json

Theme colors applied via `theme_overrides`
<img width="233" height="34" alt="Screenshot 2025-10-08 at 23 01 08"
src="https://github.com/user-attachments/assets/a00d9ae4-b6db-46a0-84e2-98d2691a11ad"
/>
<img width="233" height="34" alt="Screenshot 2025-10-08 at 23 01 16"
src="https://github.com/user-attachments/assets/f27fddab-524d-43c4-9307-46b6a656cd35"
/>
<img width="233" height="34" alt="Screenshot 2025-10-08 at 23 01 23"
src="https://github.com/user-attachments/assets/7e477fff-7a40-4c01-95a7-fbd40fff6caa"
/>

No theme applied
<img width="233" height="34" alt="Screenshot 2025-10-08 at 23 01 31"
src="https://github.com/user-attachments/assets/8b7b2c75-007b-4074-a552-181c53f31213"
/>
<img width="233" height="34" alt="Screenshot 2025-10-08 at 23 01 36"
src="https://github.com/user-attachments/assets/7a708d81-2033-4d72-a844-57607a0434ea"
/>
<img width="233" height="34" alt="Screenshot 2025-10-08 at 23 01 40"
src="https://github.com/user-attachments/assets/526f9d10-4d0f-4bc5-af89-31fcca538ce4"
/>



https://github.com/user-attachments/assets/d0d71d4d-504f-4d18-bbd9-83d3a4b2adb7


Release Notes:

- Vim make mode indicator themeable

---------

Co-authored-by: willyHetland <willy.hetland@zeekit.no>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Willy Hetland
2025-10-21 04:30:30 +00:00
committed by GitHub
co-authored by willyHetland Conrad Irwin
parent 917f22f884
commit 71ea133d72
6 changed files with 176 additions and 12 deletions
+18
View File
@@ -154,6 +154,15 @@ impl ThemeColors {
version_control_ignored: gray().light().step_12(),
version_control_conflict_marker_ours: green().light().step_10().alpha(0.5),
version_control_conflict_marker_theirs: blue().light().step_10().alpha(0.5),
vim_normal_background: system.transparent,
vim_insert_background: system.transparent,
vim_replace_background: system.transparent,
vim_visual_background: system.transparent,
vim_visual_line_background: system.transparent,
vim_visual_block_background: system.transparent,
vim_helix_normal_background: system.transparent,
vim_helix_select_background: system.transparent,
vim_mode_text: system.transparent,
}
}
@@ -280,6 +289,15 @@ impl ThemeColors {
version_control_ignored: gray().dark().step_12(),
version_control_conflict_marker_ours: green().dark().step_10().alpha(0.5),
version_control_conflict_marker_theirs: blue().dark().step_10().alpha(0.5),
vim_normal_background: system.transparent,
vim_insert_background: system.transparent,
vim_replace_background: system.transparent,
vim_visual_background: system.transparent,
vim_visual_line_background: system.transparent,
vim_visual_block_background: system.transparent,
vim_helix_normal_background: system.transparent,
vim_helix_select_background: system.transparent,
vim_mode_text: system.transparent,
}
}
}
+10
View File
@@ -233,6 +233,16 @@ pub(crate) fn zed_default_dark() -> Theme {
version_control_ignored: crate::gray().light().step_12(),
version_control_conflict_marker_ours: crate::green().light().step_12().alpha(0.5),
version_control_conflict_marker_theirs: crate::blue().light().step_12().alpha(0.5),
vim_normal_background: SystemColors::default().transparent,
vim_insert_background: SystemColors::default().transparent,
vim_replace_background: SystemColors::default().transparent,
vim_visual_background: SystemColors::default().transparent,
vim_visual_line_background: SystemColors::default().transparent,
vim_visual_block_background: SystemColors::default().transparent,
vim_helix_normal_background: SystemColors::default().transparent,
vim_helix_select_background: SystemColors::default().transparent,
vim_mode_text: SystemColors::default().transparent,
},
status: StatusColors {
conflict: yellow,
+36
View File
@@ -756,6 +756,42 @@ pub fn theme_colors_refinement(
.as_ref()
.or(this.version_control_conflict_theirs_background.as_ref())
.and_then(|color| try_parse_color(color).ok()),
vim_normal_background: this
.vim_normal_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
vim_insert_background: this
.vim_insert_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
vim_replace_background: this
.vim_replace_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
vim_visual_background: this
.vim_visual_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
vim_visual_line_background: this
.vim_visual_line_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
vim_visual_block_background: this
.vim_visual_block_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
vim_helix_normal_background: this
.vim_helix_normal_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
vim_helix_select_background: this
.vim_helix_select_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
vim_mode_text: this
.vim_mode_text
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
}
}
+19
View File
@@ -162,6 +162,25 @@ pub struct ThemeColors {
/// The border color of the minimap thumb.
pub minimap_thumb_border: Hsla,
/// Background color for Vim Normal mode indicator.
pub vim_normal_background: Hsla,
/// Background color for Vim Insert mode indicator.
pub vim_insert_background: Hsla,
/// Background color for Vim Replace mode indicator.
pub vim_replace_background: Hsla,
/// Background color for Vim Visual mode indicator.
pub vim_visual_background: Hsla,
/// Background color for Vim Visual Line mode indicator.
pub vim_visual_line_background: Hsla,
/// Background color for Vim Visual Block mode indicator.
pub vim_visual_block_background: Hsla,
/// Background color for Vim Helix Normal mode indicator.
pub vim_helix_normal_background: Hsla,
/// Background color for Vim Helix Select mode indicator.
pub vim_helix_select_background: Hsla,
/// Text color for Vim mode indicator label.
pub vim_mode_text: Hsla,
// ===
// Editor
// ===