gruvbox
gruvbox copied to clipboard
Not setting the background contrast mode as expected
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?
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.
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
@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?
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"
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.