Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

vim: Add configurable yank highlight background color (#49517)

Kasper Nyhusbf6a737e5979
diff --git a/crates/settings_content/src/theme.rs b/crates/settings_content/src/theme.rs
index c63536b0749..623e463cfb6 100644
--- a/crates/settings_content/src/theme.rs
+++ b/crates/settings_content/src/theme.rs
@@ -1033,6 +1033,9 @@ pub struct ThemeColorsContent {
/// Background color for Vim Visual Block mode indicator.
#[serde(rename = "vim.visual_block.background")]
pub vim_visual_block_background: Option<String>,
+ /// Background color for Vim yank highlight.
+ #[serde(rename = "vim.yank.background")]
+ pub vim_yank_background: Option<String>,
/// Background color for Vim Helix Normal mode indicator.
#[serde(rename = "vim.helix_normal.background")]
pub vim_helix_normal_background: Option<String>,
diff --git a/crates/theme/src/default_colors.rs b/crates/theme/src/default_colors.rs
index cc5bdd1f32d..fce0e54c720 100644
--- a/crates/theme/src/default_colors.rs
+++ b/crates/theme/src/default_colors.rs
@@ -175,6 +175,7 @@ impl ThemeColors {
vim_visual_background: system.transparent,
vim_visual_line_background: system.transparent,
vim_visual_block_background: system.transparent,
+ vim_yank_background: neutral().light_alpha().step_3(),
vim_helix_normal_background: system.transparent,
vim_helix_select_background: system.transparent,
vim_normal_foreground: system.transparent,
@@ -320,6 +321,7 @@ impl ThemeColors {
vim_visual_background: system.transparent,
vim_visual_line_background: system.transparent,
vim_visual_block_background: system.transparent,
+ vim_yank_background: neutral().dark_alpha().step_4(),
vim_helix_normal_background: system.transparent,
vim_helix_select_background: system.transparent,
vim_normal_foreground: system.transparent,
diff --git a/crates/theme/src/fallback_themes.rs b/crates/theme/src/fallback_themes.rs
index b04d6767746..72b65f85c9e 100644
--- a/crates/theme/src/fallback_themes.rs
+++ b/crates/theme/src/fallback_themes.rs
@@ -257,6 +257,7 @@ pub(crate) fn zed_default_dark() -> Theme {
vim_visual_background: SystemColors::default().transparent,
vim_visual_line_background: SystemColors::default().transparent,
vim_visual_block_background: SystemColors::default().transparent,
+ vim_yank_background: hsla(207.8 / 360., 81. / 100., 66. / 100., 0.2),
vim_helix_normal_background: SystemColors::default().transparent,
vim_helix_select_background: SystemColors::default().transparent,
vim_normal_foreground: SystemColors::default().transparent,
diff --git a/crates/theme/src/schema.rs b/crates/theme/src/schema.rs
index afe7bf759dd..61cf869b951 100644
--- a/crates/theme/src/schema.rs
+++ b/crates/theme/src/schema.rs
@@ -796,6 +796,11 @@ pub fn theme_colors_refinement(
.vim_visual_block_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
+ vim_yank_background: this
+ .vim_yank_background
+ .as_ref()
+ .and_then(|color| try_parse_color(color).ok())
+ .or(editor_document_highlight_read_background),
vim_helix_normal_background: this
.vim_helix_normal_background
.as_ref()
diff --git a/crates/theme/src/styles/colors.rs b/crates/theme/src/styles/colors.rs
index b54dc38fdf8..75ba8ea3918 100644
--- a/crates/theme/src/styles/colors.rs
+++ b/crates/theme/src/styles/colors.rs
@@ -175,6 +175,8 @@ pub struct ThemeColors {
pub vim_visual_line_background: Hsla,
/// Background color for Vim Visual Block mode indicator.
pub vim_visual_block_background: Hsla,
+ /// Background color for Vim yank highlight.
+ pub vim_yank_background: Hsla,
/// Background color for Vim Helix Normal mode indicator.
pub vim_helix_normal_background: Hsla,
/// Background color for Vim Helix Select mode indicator.
diff --git a/crates/theme_importer/src/vscode/converter.rs b/crates/theme_importer/src/vscode/converter.rs
index 2df113bfe80..b052e865265 100644
--- a/crates/theme_importer/src/vscode/converter.rs
+++ b/crates/theme_importer/src/vscode/converter.rs
@@ -207,6 +207,7 @@ impl VsCodeThemeConverter {
terminal_ansi_white: vscode_colors.terminal.ansi_white.clone(),
terminal_ansi_bright_white: vscode_colors.terminal.ansi_bright_white.clone(),
link_text_hover: vscode_colors.text_link.active_foreground.clone(),
+ vim_yank_background: vscode_colors.editor.range_highlight_background.clone(),
..Default::default()
})
}
diff --git a/crates/vim/src/normal/yank.rs b/crates/vim/src/normal/yank.rs
index 8ad4e6b9c02..6f2abfddd57 100644
--- a/crates/vim/src/normal/yank.rs
+++ b/crates/vim/src/normal/yank.rs
@@ -228,7 +228,7 @@ impl Vim {
editor.highlight_background(
HighlightKey::HighlightOnYank,
&ranges_to_highlight,
- |_, colors| colors.colors().editor_document_highlight_read_background,
+ |_, colors| colors.colors().vim_yank_background,
cx,
);
cx.spawn(async move |this, cx| {