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.

Current issues:
- doesn't work well in 8 color mode, since the background and foreground
  colors used remain un-distinguishable.

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.

I hope this makes kind of sense.

Signed-off-by: Christian Brabandt <[email protected]>
  • Loading branch information
chrisbra committed Dec 11, 2023
1 parent abfa13e commit 9fce89b
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 @@ -220,8 +220,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=Grey42 guifg=LightGrey"),
#ifdef FEAT_DIFF
CENT("DiffAdd term=bold ctermbg=LightBlue",
"DiffAdd term=bold ctermbg=LightBlue guibg=LightBlue"),
Expand Down Expand Up @@ -309,8 +309,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=235 ctermfg=LightGrey",
"Visual ctermbg=235 ctermfg=LightGrey guifg=LightGrey guibg=Grey15"),
#ifdef FEAT_DIFF
CENT("DiffAdd term=bold ctermbg=DarkBlue",
"DiffAdd term=bold ctermbg=DarkBlue guibg=DarkBlue"),
Expand Down Expand Up @@ -437,14 +437,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 9fce89b

Please sign in to comment.