I use vundle as plugin manager for vim. And I want to use ansible to automate vundle plugin installation.
But I just can't get ansible to do provision automatically:
- name: install vundle plugin
shell: vim +PluginInstall +qall
above is the ansible playbook YML file for vim.
When ansible start to run this task, it just goes on forever, it never ends and it never fails. Until I force it to stop by CTRL C
.
If I run that command directly in the guest os, it works fine, vim shows up and finishes installation.
What's the problem here?
==========================================
Edit:
After read Roy Zuo
's answer, and turn on verbose mode of vim, I tried the following command:
vim -E -s -c "source ~/.vimrc" +PluginInstall +qall -V
and below is the output:
continuing in /home/vagrant/.vimrc
Searching for "/usr/share/vim/vimfiles/after/syntax/syncolor.vim"
Searching for "/home/vagrant/.vim/after/syntax/syncolor.vim"
Searching for "/home/vagrant/.vim/bundle/Vundle.vim/syntax/syncolor.vim"
Searching for "/after/syntax/syncolor.vim"
Searching for "colors/solarized.vim" in "/home/vagrant/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/home/vagrant/.vim/after,/home/vagrant/.vim/bundle/Vundle.vim,/after"
Searching for "/home/vagrant/.vim/colors/solarized.vim"
Searching for "/usr/share/vim/vimfiles/colors/solarized.vim"
Searching for "/usr/share/vim/vim74/colors/solarized.vim"
Searching for "/usr/share/vim/vimfiles/after/colors/solarized.vim"
Searching for "/home/vagrant/.vim/after/colors/solarized.vim"
Searching for "/home/vagrant/.vim/bundle/Vundle.vim/colors/solarized.vim"
Searching for "/after/colors/solarized.vim"
not found in 'runtimepath': "colors/solarized.vim"
line 188:
E185: Cannot find color scheme 'solarized'
finished sourcing /home/vagrant/.vimrc
continuing in command line
It seems vim stopped when it can't find the plugin specified in .vimrc. Any idea how to continue?
You would want vim in this case to run in EX mode which avoids bringing up the visual interface which requires a tty for display. Try the following command instead.
vim -E -s -c "source ~/.vimrc" -c PluginInstall -c qa
Here -E
tells vim to start in EX mode, and "-s" (only available in EX mode, help -s-ex
) means we want it to run silently without any prompts or informative messages. Moreover, without sourcing your runtime file, EX mode does not know how to execute PluginInstall
command.
-s Silent or batch mode. Only when Vim was started as "ex" or
when preceded with the "-e" argument. Otherwise see -s,
which does take an argument while this use of "-s" doesn't.
To be used when Vim is used to execute Ex commands from a file
instead of a terminal. Switches off most prompts and
informative messages. Also warnings and error messages.
The output of these commands is displayed (to stdout):
:print
:list
:number
:set to display option values.
====================
As for your Solarized color scheme missing, since you are already with Vundle, it is easy to have the following in your vimrc
.
Plugin 'altercation/vim-colors-solarized'
and you should make sure colorscheme solarized
line come after it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With