After updating to vim 9.1 yesterday, diff highlighting colors were broken for me. Comparing with an older vim (7.4) on a different machine, it seems that the cause was probably a change in the diff.vim syntax file using DiffAdd/Delete/Change as the relevant highlighting groups instead of Identifier/Special/PreProc like previously; thus I fixed this by adding the appropriate hi
entries to my color scheme. But during the investigation, I could not figure out how the default colors for those hl groups are determined.
For example, here are the values for DiffDelete
as given by :echo hlget('DiffDelete')
before adding a hi DiffDelete
entry to my scheme:
[{'id': 30, 'ctermfg': '12', 'name': 'DiffDelete', 'gui': {'bold': v:true},
'term': {'bold': v:true}, 'ctermbg': '6', 'guibg': 'DarkCyan', 'guifg': 'Blue'}]
Also, vim used the guifg/bg
values instead of the ctermfg/bg
values, as ctermfg=12
should be red but deleted lines were highlighted blue on cyan.
Example:
.
I checked the following places for highlighting definitions and related config:
- The default color scheme under
$VIMRUNTIME/colors/default.vim
is basically empty and does not define any relevant colors. - My existing color scheme (based on mustang) did not define them either.
- Other color schemes in
$VIMRUNTIME/colors
definieDiffDelete
highlights, but no scheme matches even one of the fg/bg values.
I'm setting t_Co=256
in my vimrc and $TERM
is xterm-256color
; I don't think any other vimrc settings are relevant.
So in summary, here's my questions:
- Are the default color values such as the hlget output above hardcoded somewhere in the vim code? If not, is it in some configuration file outside of
$VIMRUNTIME
, or is it dynamically determined based on the env / terminal / whatever? - Why does the default highlighting above result in the
guibg/fg
being applied instead of thectermbg/fg
values - shouldn't the gui values only be used in gvim etc and not in a terminal?
vim-9.0.2167
previously. Highlighting looks as expected when reverting to that version and removing thehi Diff*
lines in my colorscheme. Thehlget('DiffDelete')
output is identical, but it's not yet relevant in that version as can be seen in the doc linked by Christian.