Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Without Opening Vim / Automated Install via Command Line #225

Closed
rosstimson opened this issue Apr 30, 2015 · 18 comments
Closed

Install Without Opening Vim / Automated Install via Command Line #225

rosstimson opened this issue Apr 30, 2015 · 18 comments

Comments

@rosstimson
Copy link

I've just tried vim-plug out after using Vundle and NeoBundle in the past.

I'd like to try and automate the install of all my plugins as I'm going to do this in a Dockerfile, in Vundle I would be able to do something like: vim +BundleInstall +qall.

I've attempted vim +PlugInstall +qall but that quits before my plugins have installed. I've also tried creating a shell script similar to the one NeoBundle uses to do this: https://github.com/Shougo/neobundle.vim/blob/master/bin/neoinstall but nothing seems to work.

I also get an error about my colorscheme not being present as it is installed via vim-plug and obviously I can't manage to install everything without manual intervention.

This is all possible, and fairly simple, with NeoBundle and Vundle; any ideas how this can be achieved with vim-plug as I like vim-plug's more minimal approach?

Thanks for any help and this great project.

@vheon
Copy link
Contributor

vheon commented Apr 30, 2015

@rosstimson are you using neovim?? the installer should be synchronous in vim but there are some problem with neovim, see #104. For the error about the colorscheme, I personally use silent! colorscheme solarized so in case (n)vim cannot find the colorscheme it doesn't choke on that.

@junegunn
Copy link
Owner

junegunn commented May 1, 2015

As @vheon mentioned, it looks like you're running Neovim. We've been planning to make Neovim installer synchronous only during vim_starting for such use case and for that we're waiting for some Neovim issues to be resolved.

(@vheon Since the only workaround for this is to use plain Vim, we could possibly make installer synchronous when :PlugInstall 1, but I still much prefer vim_starting approach)

I also get an error about my colorscheme not being present as it is installed
via vim-plug and obviously I can't manage to install everything without manual
intervention.

This is all possible, and fairly simple, with NeoBundle and Vundle

You should run into the same problem regarding colorscheme not present even if you use NeoBundle or Vundle. There's essentially no difference in how these plugin managers update your &runtimepath. I also use silent! colo ....

@rosstimson
Copy link
Author

Thank you both, you are indeed correct, I had recently changed my Dockerfile to use Neovim. I'll keep an eye on issue #104 that you mentioned.

The colorscheme thing was just an aside as it seemed to be a stumbling block with getting an automated install going. I'll use the silent! option. My Dockerfile definitely built fine and installed all vim plugins without stalling on the colorscheme warning when I previously used NeoBundle and standard vim so not sure how.

Anyway, I'm sure my main issue is now down to Neovim (#104), apologies for being such a n00b and thank you both for the pointers.

@junegunn
Copy link
Owner

junegunn commented May 1, 2015

No problem. Maybe it's a good idea to install both vim and neovim until #104 is fixed and use vim for synchronous installation.

@longkai
Copy link

longkai commented Aug 10, 2016

Hi, I am dockerizing vim with the command vim +slient +VimEnter +PlugInstall +qall but always shows the annoying Press ENTER or type command to continue. My env is centos 7 with the 7.4 version.

Any ideas?

@junegunn
Copy link
Owner

@longkai Is +slient a typo? Anyway vim +PlugInstall +qall should suffice.

@longkai
Copy link

longkai commented Aug 10, 2016

@junegunn Thank you for your reply. I try vim +PlugInstall +qall at first but didn't work so I prepend +slient later.

I find there is an error when executing: E185: Cannot find color scheme 'solarized'. It is fine if I comment colorscheme solarized this line.

My .vimrc file(partial) is:

call plug#begin('~/.vim/plugged')
Plug 'https://github.com/altercation/vim-colors-solarized.git'
call plug#end()

colorscheme solarized

How can I fix it? Thanks in advance.

@junegunn
Copy link
Owner

@longkai Well, that's not a valid way to use silent. You see the error message because at the moment solarized is not yet installed. Prepend silent! to the line: silent! colorscheme solarized.

@longkai
Copy link

longkai commented Aug 10, 2016

@junegunn thx, it works!

karlhungus added a commit to karlhungus/dotfiles that referenced this issue Oct 22, 2017
@rbhanot4739
Copy link

rbhanot4739 commented Sep 9, 2018

I am also facing the same issue, i need to setup neovim on a machine and then install the plugins non-intercatively.
When i run nvim +PlugInstall +qall. , it opens up the Neovim window showing the progress of Plugin installations.

Is it possible to make this run in background ?

@rafaelmoraes
Copy link

It's worked for me:

vim -E -s -u "path_to_vim_rc/.vimrc" +PlugInstall +qall

@golonzovsky
Copy link

@rbhanot4739 this looks better for my Dockerfile build: vim +PlugInstall +qall > /dev/null

@asolopovas
Copy link

@golonzovsky in my case I use nvim if I add > /dev/null it throws code 139 error. Do you know a way around it?

@alecatslalom
Copy link

alecatslalom commented Feb 7, 2020

@asolopovas I just figured it out. Looks like nvim has --headless. So for me, nvim --headless +PlugInstall +qall is working while building my Docker containers. Presumably, it has something to do with the lack of ttys

atweiden pushed a commit to atweiden/macfiles that referenced this issue Jul 15, 2020
atweiden pushed a commit to atweiden/pacfiles that referenced this issue Jul 15, 2020
atweiden pushed a commit to atweiden/ttyfiles that referenced this issue Jul 15, 2020
atweiden pushed a commit to atweiden/voidfiles that referenced this issue Jul 15, 2020
@tamakiii
Copy link

vim -E -s +PlugInstall +qall exit with non-zero(1). Adding +visual worked.

$ vim --version | head -n 1
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 15 2019 16:41:15)
$ vim -E -s +PlugInstall +qall; echo $?
1
$ vim -E -s +PlugInstall +visual +qall; echo $?
0

@salmanwaheed
Copy link

it worked for me :) vim +PlugInstall +qall >/dev/null 2>&1

@mflai
Copy link

mflai commented Mar 31, 2021

Coming across this looking for a solution and here was how I fixed it (Docker example):

#Setup Vim
RUN git clone https://github.com/VundleVim/Vundle.vim.git /home//.vim/bundle/Vundle.vim
COPY --chown= ./.vimrc_plugin_install /home/
RUN vim -u .vimrc_plugin_install +PluginInstall +qall
RUN rm ./.vimrc_plugin_install
COPY --chown= ./.vimrc /home/
RUN vim +PluginInstall +qall

Errors were popping up in Vim because lines in .vimrc that depended on my plugins, e.g. colorscheme=gruvbox. But then +PluginInstall cannot complete on command line because of the errors popping up. Cyclic dependency ;) My fix is to make a .vimrc_plugin_install that just installs all the plugins, and then put the .vimrc proper back.

@mvcouwen
Copy link

mvcouwen commented Aug 2, 2021

I came across this topic and wanted to share the following. You can install vimplug and the plugins directly from within your vimrc by putting

" Install vim plug if not installed
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
  silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

before calling

call plug#begin('~/.vim/plugged')

or anything plugin related.
Source: #792

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests