Skip to content

Commit

Permalink
[Breaking-Change]: re-work the (default) Visual Highlighting
Browse files Browse the repository at this point in the history
The default visual highlighting currently is nice in that it overlays
the actual syntax highlighting by using a separate distinct background
color.

However, this can cause hard to read text, because the contrast
between the actual syntax element and the background color is way too
low. That is an issue, that has been bothering colorschemes authors for
quite some time so much, that they are defining the Visual highlighting
group to use a separate foreground and background color, so that the
syntax highlighting vanishes, but the text remains readable (ref:
vim/colorschemes#250)

So this is an attempt to perform the same fix for the default Visual
highlighting and just use a default foreground and background color
instead of using reverse.

I also removed the hard-coded changes to the Visual highlighting in
init_highlight. It's not quite clear to me, why those were there and not
added directly to the highlighting_init_<dark|light> struct.

Signed-off-by: Christian Brabandt <[email protected]>
  • Loading branch information
chrisbra committed Jan 25, 2024
1 parent 1f47db7 commit c0b1bb0
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/highlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ static char *(highlight_init_light[]) = {
CENT("SignColumn term=standout ctermbg=Grey ctermfg=DarkBlue",
"SignColumn term=standout ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue"),
#endif
CENT("Visual term=reverse",
"Visual term=reverse guibg=LightGrey"),
CENT("Visual ctermbg=DarkGrey ctermfg=White",
"Visual ctermbg=DarkGrey ctermfg=White guibg=LightGrey"),
#ifdef FEAT_DIFF
CENT("DiffAdd term=bold ctermbg=LightBlue",
"DiffAdd term=bold ctermbg=LightBlue guibg=LightBlue"),
Expand Down Expand Up @@ -310,8 +310,8 @@ static char *(highlight_init_dark[]) = {
CENT("SignColumn term=standout ctermbg=DarkGrey ctermfg=Cyan",
"SignColumn term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan"),
#endif
CENT("Visual term=reverse",
"Visual term=reverse guibg=DarkGrey"),
CENT("Visual ctermbg=Grey ctermfg=Black",
"Visual ctermbg=Grey ctermfg=Black guibg=#575757"),
#ifdef FEAT_DIFF
CENT("DiffAdd term=bold ctermbg=DarkBlue",
"DiffAdd term=bold ctermbg=DarkBlue guibg=DarkBlue"),
Expand Down Expand Up @@ -438,14 +438,8 @@ init_highlight(
// With 8 colors brown is equal to yellow, need to use black for Search fg
// to avoid Statement highlighted text disappears.
// Clear the attributes, needed when changing the t_Co value.
if (t_colors > 8)
do_highlight((char_u *)(*p_bg == 'l'
? "Visual cterm=NONE ctermbg=LightGrey"
: "Visual cterm=NONE ctermbg=DarkGrey"), FALSE, TRUE);
else
if (t_colors <= 8)
{
do_highlight((char_u *)"Visual cterm=reverse ctermbg=NONE",
FALSE, TRUE);
if (*p_bg == 'l')
do_highlight((char_u *)"Search ctermfg=black", FALSE, TRUE);
}
Expand Down

0 comments on commit c0b1bb0

Please sign in to comment.