gruvbox-community/gruvbox

Visual selections have very bright, harsh and inverted background colors

nickjj opened this issue ยท 10 comments

Hi,

When you make a visual selection, the selected background color of previously syntax highlighted code gets changed. The background color of the selection is also very bright.

This creates a very disorienting combination of colors. In fact, someone who watched one of my videos said they almost had a seizure when I selected some text.

I think a picture speaks a million words here. I ended up asking for help on IRC (thanks @romainl) and have a solution to fix it, but check this out to see the problem with a default installation of this theme:

vim-colors

The fix is to drop this into your ~/.vimrc file.

if (&background == 'dark')
  hi Visual cterm=NONE ctermfg=NONE ctermbg=237 guibg=#3a3a3a
else
  hi Visual cterm=NONE ctermfg=NONE ctermbg=223 guibg=#ffd7af
endif

I matched the colors to what the column marker color's is for both the dark and light variants.

It would be nice if this could get merged in at some point.

There is a config option for that

You just have to put let g:gruvbox_invert_selection = 0 in your vimrc and your done :)

Ah neat. Although in that case if I remove my snippet and replace it with your setting, it does fix the inverted colors but the selected color is too light for the dark variant and too dark for the light variant.

Here's a few examples:

Your setting suggestion without my color changes:

image

image

My color changes without your setting:

image

image

Personally I find the bottom set of screenshots a lot more readable when a selection is active. The contrast ratio is much higher and the selection itself is still bright enough to see it at a glance. It also matches the color column and cursorline colors if you have them enabled.

Okay, I see what you mean. BTW your comment is not visible to the project but to your fork, I think
you should open an issue here https://github.com/morhetz/gruvbox/issues instead

I was under the impression the original repo is no longer maintained and this fork is the official unofficial successor to gruvbox?

Ah apologises, I wasn't aware that the official plugin is not maintained any more :)

I'm not 100% on the details but there's a lot of talk about it here from ~7 months ago: https://www.reddit.com/r/vim/comments/bu5x8c/starting_gruvbox_community_fork_all_pull_requests/

Adding let g:gruvbox_invert_selection = 0 to my configuration file did not change the color of highlighted text. The workaround proposed by @nickjj worked for me. I am using NVIM-QT v0.2.16.1

rbong commented

@NoahRoseLedesma did you make sure to place the configuration line before colorscheme gruvbox?

Concerning the maintenance status of the original repo - I think the most Morhetz has said on it is that he's just busy. He also does not want to add more maintainers. It's not technically unmaintained, but he has said that if you want certain fixes, to fork it yourself. This community effort is just to get fixes in faster, and to avoid everyone having to make their own fork.

@rbong thanks for that part, initially had the configuration line before the line that you have mentioned. Its working now.

thanks for the solution posted here. putting the code snippet let g:gruvbox_invert_selection=0 before colorscheme gruvbox in my .vimrc solved the issue for me