fix(highlight): reduce word-level blend alpha and match line number bg

Problem: word-level diff highlights were too intense at 70% alpha, and
line number backgrounds used the line-level blend instead of matching
the word-level highlights.

Solution: reduce DiffsAddText/DiffsDeleteText blend alpha from 0.7 to
0.6 and use the same blended background for DiffsAddNr/DiffsDeleteNr.
This commit is contained in:
Barrett Ruth 2026-02-07 15:23:14 -05:00
parent d353a6a314
commit d10eaed6ac
2 changed files with 12 additions and 8 deletions

View file

@ -402,6 +402,10 @@ diffs.nvim defines custom highlight groups. Fugitive unified diff groups use
`default = true`, so colorschemes can override them. Diff mode groups are
always derived from the corresponding `Diff*` groups.
All derived groups are computed by alpha-blending a source color into the
`Normal` background. Line-level groups blend at 40% alpha for a subtle tint;
character-level and line-number groups blend at 60% for more contrast.
Fugitive unified diff highlights: ~
*DiffsAdd*
DiffsAdd Background for `+` lines. Derived by blending
@ -413,23 +417,23 @@ Fugitive unified diff highlights: ~
*DiffsAddNr*
DiffsAddNr Line number for `+` lines. Foreground from
`diffAdded`, background from `DiffsAdd`.
`diffAdded`, background from `DiffsAddText`.
*DiffsDeleteNr*
DiffsDeleteNr Line number for `-` lines. Foreground from
`diffRemoved`, background from `DiffsDelete`.
`diffRemoved`, background from `DiffsDeleteText`.
*DiffsAddText*
DiffsAddText Character-level background for changed characters
within `+` lines. Derived by blending `diffAdded`
foreground with `Normal` background at 70% alpha.
foreground with `Normal` background at 60% alpha.
Only sets `bg`, so treesitter foreground colors show
through.
*DiffsDeleteText*
DiffsDeleteText Character-level background for changed characters
within `-` lines. Derived by blending `diffRemoved`
foreground with `Normal` background at 70% alpha.
foreground with `Normal` background at 60% alpha.
Diff mode window highlights: ~
These are used for |winhighlight| remapping in `&diff` windows.

View file

@ -192,14 +192,14 @@ local function compute_highlight_groups()
local blended_add = blend_color(add_bg, bg, 0.4)
local blended_del = blend_color(del_bg, bg, 0.4)
local blended_add_text = blend_color(add_fg, bg, 0.7)
local blended_del_text = blend_color(del_fg, bg, 0.7)
local blended_add_text = blend_color(add_fg, bg, 0.6)
local blended_del_text = blend_color(del_fg, bg, 0.6)
vim.api.nvim_set_hl(0, 'DiffsClear', { default = true, fg = normal.fg or 0xc0c0c0 })
vim.api.nvim_set_hl(0, 'DiffsAdd', { default = true, bg = blended_add })
vim.api.nvim_set_hl(0, 'DiffsDelete', { default = true, bg = blended_del })
vim.api.nvim_set_hl(0, 'DiffsAddNr', { default = true, fg = add_fg, bg = blended_add })
vim.api.nvim_set_hl(0, 'DiffsDeleteNr', { default = true, fg = del_fg, bg = blended_del })
vim.api.nvim_set_hl(0, 'DiffsAddNr', { default = true, fg = add_fg, bg = blended_add_text })
vim.api.nvim_set_hl(0, 'DiffsDeleteNr', { default = true, fg = del_fg, bg = blended_del_text })
vim.api.nvim_set_hl(0, 'DiffsAddText', { default = true, bg = blended_add_text })
vim.api.nvim_set_hl(0, 'DiffsDeleteText', { default = true, bg = blended_del_text })