How can I detect whether a color scheme installed via a vim-plug plug-in is available?
For context, I'm trying to automate my Vim setup on a new machine, pulling the vimrc from a git repository. The vimrc has
:Plug directives to load all the plugins, but on the first run they're not installed yet. Later on I have a
:colorscheme setting, but that fails if the plug-ins are not installed yet.
I can automate installing plug-ins on first run with:
vim -c PlugInstall -c qa
But that trips on the
Error detected while processing ~/.vimrc: line 123: E185: Cannot find color scheme 'blablabla' Press ENTER or type command to continue
After pressing Enter, plug-ins are installed correctly and next time everything works as expected... But it's still inconvenient to have this on installation (which is supposed to be as automatic as possible.)
I found some solutions for the problem, but none of them seems ideal... Using
:silent! colorscheme makes it fail silently, but that's not great since other than during setup I would actually want to know when this fails.
I looked at vim-plug documentation to see if there's a function telling whether plug-in X is installed but couldn't find it...
There's also a possibility of loading the colorscheme using
:runtime colors/blablabla.vim but that's not really great since later on typing
:colo will not report which one is in use.
Vim knows about the color schemes, since when typing
:colorscheme Ctrl+D it will autocomplete all those which are available. But I couldn't really find a good way to get that list from VimL.
Is there a good way to programatically tell which color schemes are installed or available?
Would you suggest I take a different approach in this case? (I'm open to alternatives that involve radically different ways to fixing the core problem, which is reliable first-time plug-in installation...)
if index(getcompletion('', 'color'), 'blablabla') >= 0worked great. Thanks!