gruvbox icon indicating copy to clipboard operation
gruvbox copied to clipboard

Not setting the background contrast mode as expected

Open Tormenta74 opened this issue 6 years ago • 5 comments

At the end of my init.vim I have this line

let g:gruvbox_contrast_dark = 'hard'

as per the documentation on the wiki for setting the background contrast mode. However, when I load Neovim, the change is not applied; when I :so $MYVIMRC it applies the changes. Am I doing something wrong here?

example

Tormenta74 avatar Jan 14 '19 18:01 Tormenta74

I had the same issue, fixed it by configuring the theme before applying it:

set background=dark
let g:gruvbox_contrast_dark='hard'
colorscheme gruvbox

EDIT: updated variables as others pointed below.

kakig avatar Jan 24 '19 14:01 kakig

I also had a similar issue, and DzKaki's suggestion partially fixed it, but on load I always get the error message: g:gruvbox_contrast is deprecated; use g:gruvbox_contrast_light and g:gruvbox_contrast_dark instead repeated three times.

g:gruvbox_contrast does not appear anywhere in my .vimrc except within g:gruvbox_contrast_dark

const-chris avatar Feb 01 '19 17:02 const-chris

@GHDIShfdiod876dhs I couldn't recreate it with your .vimrc uploaded to github with gruvbox installed (assuming that's an accurate representation of your setup).

Sounds like #73, even though that's an old version.

Also, that warning should not be showing up multiple times.

Is there any reason that an older version might be installed or gruvbox would be loading multiple times?

rbong avatar May 31 '19 07:05 rbong

Yeah, I had the same issue, in my case, I solved this adding "set background=dark" like this:

colorshceme gruvbox set background=dark let g:gruvbox_contrast="hard"

Raynou avatar May 02 '21 00:05 Raynou

You need to set the variable (g:gruvbox_contrast_light or g:gruvbox_contrast_dark) before setting the colorscheme.

This is from my .vimrc:

set background=dark
let g:gruvbox_contrast_dark='hard'
colorscheme gruvbox

From my understanding, g:<var_name> are global variables in vimscript and the order of execution matters. colorscheme gruvbox executes gruvbox.vim which expects g:gruvbox_contrast_dark/light to be defined before it is called. So if you define the variable after setting the colorscheme, it will only be detected after reloading your vimrc because global variables aren't cleared on reload.

mukul29 avatar Sep 19 '21 20:09 mukul29