morhetz / gruvbox

Retro groove color scheme for Vim
13.85k stars 1.11k forks source link

Flag to Indicate Gruvbox Loaded #256

Open neur1n opened 5 years ago

neur1n commented 5 years ago

Hello, I have the problem that if I deploy my vimrc in a new environment, an error occurs if gruvbox is not installed since I use vim-plug to install it afterwards. So can it provide a flag that indicating if gruvbox is loaded, so that I can make it fall back to a builtin colorscheme.

Or, is there a workaround? Thanks.

ghost commented 5 years ago

Gruvbox itself can't provide that flag, because (as you mentioned) gruvbox isn't loaded/installed so there is no way it could set any flags.

In the other hand, there are some workarounds. You could make the colorscheme gruvbox silent so there wouldn't be any errors if it couldn't be loaded like so silent! colorscheme gruvbox.

For a default color scheme, you need to add it BEFORE gruvbox. For example, if you want desert to be your default color scheme add these lines to your vimrc:

silent! colorscheme desert
silent! colorscheme gruvbox

Forum post can be found here.

Also, notice that this approach may not work for airline/lightline if you are using them.