Skip to content

Commit 5be4b60

Browse files
authored
Customizable vim mode text color (#46639)
Release Notes: - Added ability to customize vim mode foreground --- <video src="https://github.com/user-attachments/assets/776ecfcd-9600-4a04-b3cf-e78af439aab2" />
1 parent d67c8f2 commit 5be4b60

File tree

6 files changed

+104
-12
lines changed

6 files changed

+104
-12
lines changed

crates/settings/src/settings_content/theme.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -961,10 +961,30 @@ pub struct ThemeColorsContent {
961961
/// Background color for Vim Helix Select mode indicator.
962962
#[serde(rename = "vim.helix_select.background")]
963963
pub vim_helix_select_background: Option<String>,
964-
965-
/// Text color for Vim mode indicator label.
966-
#[serde(rename = "vim.mode.text")]
967-
pub vim_mode_text: Option<String>,
964+
/// Background color for Vim Normal mode indicator.
965+
#[serde(rename = "vim.normal.foreground")]
966+
pub vim_normal_foreground: Option<String>,
967+
/// Foreground color for Vim Insert mode indicator.
968+
#[serde(rename = "vim.insert.foreground")]
969+
pub vim_insert_foreground: Option<String>,
970+
/// Foreground color for Vim Replace mode indicator.
971+
#[serde(rename = "vim.replace.foreground")]
972+
pub vim_replace_foreground: Option<String>,
973+
/// Foreground color for Vim Visual mode indicator.
974+
#[serde(rename = "vim.visual.foreground")]
975+
pub vim_visual_foreground: Option<String>,
976+
/// Foreground color for Vim Visual Line mode indicator.
977+
#[serde(rename = "vim.visual_line.foreground")]
978+
pub vim_visual_line_foreground: Option<String>,
979+
/// Foreground color for Vim Visual Block mode indicator.
980+
#[serde(rename = "vim.visual_block.foreground")]
981+
pub vim_visual_block_foreground: Option<String>,
982+
/// Foreground color for Vim Helix Normal mode indicator.
983+
#[serde(rename = "vim.helix_normal.foreground")]
984+
pub vim_helix_normal_foreground: Option<String>,
985+
/// Foreground color for Vim Helix Select mode indicator.
986+
#[serde(rename = "vim.helix_select.foreground")]
987+
pub vim_helix_select_foreground: Option<String>,
968988
}
969989

970990
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]

crates/theme/src/default_colors.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,14 @@ impl ThemeColors {
177177
vim_visual_block_background: system.transparent,
178178
vim_helix_normal_background: system.transparent,
179179
vim_helix_select_background: system.transparent,
180-
vim_mode_text: system.transparent,
180+
vim_normal_foreground: system.transparent,
181+
vim_insert_foreground: system.transparent,
182+
vim_replace_foreground: system.transparent,
183+
vim_visual_foreground: system.transparent,
184+
vim_visual_line_foreground: system.transparent,
185+
vim_visual_block_foreground: system.transparent,
186+
vim_helix_normal_foreground: system.transparent,
187+
vim_helix_select_foreground: system.transparent,
181188
}
182189
}
183190

@@ -315,7 +322,14 @@ impl ThemeColors {
315322
vim_visual_block_background: system.transparent,
316323
vim_helix_normal_background: system.transparent,
317324
vim_helix_select_background: system.transparent,
318-
vim_mode_text: system.transparent,
325+
vim_normal_foreground: system.transparent,
326+
vim_insert_foreground: system.transparent,
327+
vim_replace_foreground: system.transparent,
328+
vim_visual_foreground: system.transparent,
329+
vim_visual_line_foreground: system.transparent,
330+
vim_visual_block_foreground: system.transparent,
331+
vim_helix_normal_foreground: system.transparent,
332+
vim_helix_select_foreground: system.transparent,
319333
}
320334
}
321335
}

crates/theme/src/fallback_themes.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,14 @@ pub(crate) fn zed_default_dark() -> Theme {
257257
vim_visual_block_background: SystemColors::default().transparent,
258258
vim_helix_normal_background: SystemColors::default().transparent,
259259
vim_helix_select_background: SystemColors::default().transparent,
260-
vim_mode_text: SystemColors::default().transparent,
260+
vim_normal_foreground: SystemColors::default().transparent,
261+
vim_insert_foreground: SystemColors::default().transparent,
262+
vim_replace_foreground: SystemColors::default().transparent,
263+
vim_visual_foreground: SystemColors::default().transparent,
264+
vim_visual_line_foreground: SystemColors::default().transparent,
265+
vim_visual_block_foreground: SystemColors::default().transparent,
266+
vim_helix_normal_foreground: SystemColors::default().transparent,
267+
vim_helix_select_foreground: SystemColors::default().transparent,
261268
},
262269
status: StatusColors {
263270
conflict: yellow,

crates/theme/src/schema.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,36 @@ pub fn theme_colors_refinement(
803803
.vim_helix_select_background
804804
.as_ref()
805805
.and_then(|color| try_parse_color(color).ok()),
806-
vim_mode_text: this
807-
.vim_mode_text
806+
vim_normal_foreground: this
807+
.vim_normal_foreground
808+
.as_ref()
809+
.and_then(|color| try_parse_color(color).ok()),
810+
vim_insert_foreground: this
811+
.vim_insert_foreground
812+
.as_ref()
813+
.and_then(|color| try_parse_color(color).ok()),
814+
vim_replace_foreground: this
815+
.vim_replace_foreground
816+
.as_ref()
817+
.and_then(|color| try_parse_color(color).ok()),
818+
vim_visual_foreground: this
819+
.vim_visual_foreground
820+
.as_ref()
821+
.and_then(|color| try_parse_color(color).ok()),
822+
vim_visual_line_foreground: this
823+
.vim_visual_line_foreground
824+
.as_ref()
825+
.and_then(|color| try_parse_color(color).ok()),
826+
vim_visual_block_foreground: this
827+
.vim_visual_block_foreground
828+
.as_ref()
829+
.and_then(|color| try_parse_color(color).ok()),
830+
vim_helix_normal_foreground: this
831+
.vim_helix_normal_foreground
832+
.as_ref()
833+
.and_then(|color| try_parse_color(color).ok()),
834+
vim_helix_select_foreground: this
835+
.vim_helix_select_foreground
808836
.as_ref()
809837
.and_then(|color| try_parse_color(color).ok()),
810838
}

crates/theme/src/styles/colors.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,22 @@ pub struct ThemeColors {
179179
pub vim_helix_normal_background: Hsla,
180180
/// Background color for Vim Helix Select mode indicator.
181181
pub vim_helix_select_background: Hsla,
182-
/// Text color for Vim mode indicator label.
183-
pub vim_mode_text: Hsla,
182+
/// Foreground color for Vim Normal mode indicator.
183+
pub vim_normal_foreground: Hsla,
184+
/// Foreground color for Vim Insert mode indicator.
185+
pub vim_insert_foreground: Hsla,
186+
/// Foreground color for Vim Replace mode indicator.
187+
pub vim_replace_foreground: Hsla,
188+
/// Foreground color for Vim Visual mode indicator.
189+
pub vim_visual_foreground: Hsla,
190+
/// Foreground color for Vim Visual Line mode indicator.
191+
pub vim_visual_line_foreground: Hsla,
192+
/// Foreground color for Vim Visual Block mode indicator.
193+
pub vim_visual_block_foreground: Hsla,
194+
/// Foreground color for Vim Helix Normal mode indicator.
195+
pub vim_helix_normal_foreground: Hsla,
196+
/// Foreground color for Vim Helix Select mode indicator.
197+
pub vim_helix_select_foreground: Hsla,
184198

185199
// ===
186200
// Editor

crates/vim/src/mode_indicator.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,16 @@ impl Render for ModeIndicator {
100100
let theme = cx.theme();
101101
let colors = theme.colors();
102102
let system_transparent = gpui::hsla(0.0, 0.0, 0.0, 0.0);
103-
let vim_mode_text = colors.vim_mode_text;
103+
let vim_mode_text = match mode {
104+
crate::state::Mode::Normal => colors.vim_normal_foreground,
105+
crate::state::Mode::Insert => colors.vim_insert_foreground,
106+
crate::state::Mode::Replace => colors.vim_replace_foreground,
107+
crate::state::Mode::Visual => colors.vim_visual_foreground,
108+
crate::state::Mode::VisualLine => colors.vim_visual_line_foreground,
109+
crate::state::Mode::VisualBlock => colors.vim_visual_block_foreground,
110+
crate::state::Mode::HelixNormal => colors.vim_helix_normal_foreground,
111+
crate::state::Mode::HelixSelect => colors.vim_helix_select_foreground,
112+
};
104113
let bg_color = match mode {
105114
crate::state::Mode::Normal => colors.vim_normal_background,
106115
crate::state::Mode::Insert => colors.vim_insert_background,

0 commit comments

Comments
 (0)