-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Breaking-Change]: re-work the (default) Visual Highlighting #13663
Conversation
Windows terminalLight on light
Dark on light
|
I have no idea, why compilation fails in CI 🤔 |
Applying ChrisBra's temptative fixes to highlight.c
src/highlight.c
Outdated
CENT("Visual term=reverse", | ||
"Visual term=reverse guibg=LightGrey"), | ||
CENT("Visual ctermbg=DarkGrey ctermfg=White", | ||
"Visual ctermbg=DarkGrey ctermfg=White guibg=#6b6b6b guifg=LightGrey"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/highlight.c
Outdated
CENT("Visual term=reverse", | ||
"Visual term=reverse guibg=DarkGrey"), | ||
CENT("Visual ctermbg=235 ctermfg=LightGrey", | ||
"Visual ctermbg=235 ctermfg=LightGrey guifg=LightGrey guibg=#262626"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ctermbg=235
is too optimistic, I think DarkGray would be a safer bet
@romainl, @neutaaaaan what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your tweaks to the 24bit version are fine. It's a completely different colourscheme anyway.
On the other hand, I disagree with the changes made to the 256c selections , as both versions are inherently 8c colourschemes that haphazardly use colors from the extended palette.
Being the default colourscheme, this is actually a fairly sensible behavior to ensure the best compatibility possible regardless of configuration mishaps, and I've extended that behavior by bolting as many of the hl groups used during common editing down in my back of the napkin patch referenced earlier.
This is what the end user will see first in most cases.
This is what the end user will end up using in most cases.
We cannot ever assume their environment will be set up correctly.
We cannot ever assume vim will be able to autodetect the terminal background color.
The only safe assumption, is that the light version of the colorscheme is going to be loaded, eventually, and rework that as the new background agnostic default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grey is hard to get right in 8c and 16c.
Assuming the user's terminal emulator's palette follows the same structure as the default xterm palette, we only have two greys that can be reliably used for background in 16c:
- 7 is very light at
#dfdfdf
, - 8 is very dark at
#6c6c6c
.
This limits what can be done for visual selection if we insist on using grey:
- 0 on 7 works,
- 7 on 8 works,
- 15 on 8 works.
In 8c, the only viable grey background is 7, which restricts us to:
- 0 on 7
My advice would thus be to use ctermbg=grey ctermfg=black
for both 8c (because of 8c limitations) and 16c (because of consistency with 8c):
Note that the limited grey palette is quite problematic when it comes to UI. A mostly grey chrome is quite practical because it doesn't distract from the syntax highlighting. The problem is that we have lots of greys to play with in GUI and 256c but very few in 16c and 8c. If we shoot for consistency, we should, IMO keep all the greys we can for the chrome (status line, tab line, completion menu, etc.). This means using colors as much as possible for in-buffer highlighting.
Something like the following might be more effective?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grey is hard to get right in 8c and 16c.
Which is why I don't use it.
The only available colors that in the default colourschemes don't outright disappear inside diffs would be green and yellow.
I settled on black foreground, yellow background long ago.
Please take a look at this branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/highlight.c
Outdated
CENT("Visual term=reverse", | ||
"Visual term=reverse guibg=DarkGrey"), | ||
CENT("Visual ctermbg=Grey ctermfg=Black", | ||
"Visual ctermbg=Grey ctermfg=Black guibg=DarkGrey"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <cb@256bit.org>
okay, I think I have addressed all concerns and I mark it as ready. |
Looks good! Now we need to tackle other things (diff colors and others) |
Problem: UX of visual highlighting can be improved Solution: Improve readibility of visual highlighting, by setting better foreground and background colors 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/colorschemesvim/vim#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. closes: vim/vim#13663 related: vim/colorschemesvim/vim#250 vim/vim@e6d8b46 Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: UX of visual highlighting can be improved Solution: Improve readibility of visual highlighting, by setting better foreground and background colors 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/colorschemesvim/vim#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. closes: vim/vim#13663 related: vim/colorschemes#250 vim/vim@e6d8b46 Co-authored-by: Christian Brabandt <cb@256bit.org>
{ | ||
do_highlight((char_u *)"Visual cterm=reverse ctermbg=NONE", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need this for terminals without (or less than 8) color support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, seems so
There is a breaking change upstream: vim/vim#13663
This is indeed a breaking change. Fortunately the fix was simple (and I don't have a lot of colorschemes). |
…#27256) Problem: UX of visual highlighting can be improved Solution: Improve readibility of visual highlighting, by setting better foreground and background colors 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/colorschemesvim/vim#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. closes: vim/vim#13663 related: vim/colorschemes#250 vim/vim@e6d8b46 Co-authored-by: Christian Brabandt <cb@256bit.org>
…#27256) Problem: UX of visual highlighting can be improved Solution: Improve readibility of visual highlighting, by setting better foreground and background colors 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/colorschemesvim/vim#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. closes: vim/vim#13663 related: vim/colorschemes#250 vim/vim@e6d8b46 Co-authored-by: Christian Brabandt <cb@256bit.org>
Essentially it undoes the following change in Vim: <vim/vim#13663>
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:
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.