From 9fce89bac4bfce607f963b12c347d36d9e8a8a95 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Mon, 11 Dec 2023 17:57:20 +0100 Subject: [PATCH] [Breaking-Change]: re-work the (default) Visual Highlighting 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_ struct. I hope this makes kind of sense. Signed-off-by: Christian Brabandt --- src/highlight.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/highlight.c b/src/highlight.c index 31c3280e8592b9..a29726865649d6 100644 --- a/src/highlight.c +++ b/src/highlight.c @@ -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"), @@ -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"), @@ -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); }