-
Notifications
You must be signed in to change notification settings - Fork 32
Description
I used to use vim-plug whose documentation included an if statement you could use to drop a vimrc/init.vim on a new system and the first time you started vim, it'd install all your plugins for you. Useful if you are constantly blowing away the contents of a machine and want to easily deploy a functional environment to it.
Unfortunately minpac doesn't have such a simple single-file you can download, but I came up with this:
" self-install minipac!
if empty(glob('~/.config/nvim/pack/minpac/opt/minpac'))
let g:minpac_first_install = 1
silent !git clone https://github.com/k-takata/minpac.git
\ ~/.config/nvim/pack/minpac/opt/minpac
endif
" regular minpac setup
packadd minpac
call minpac#init()
call minpac#add('k-takata/minpac', {'type': 'opt'}) " opt is required for minpac
" other plugins here
" actually install plugins
if exists('g:minpac_first_install')
call minpac#update()
endifThis seems about as convenient as defining commands to call minpac's function. Unless I did it "wrong", in which case I'm sure the Internet will inform me of how I should've done it.
One niggle: My colorscheme is unavailable a few lines later in init.vim because minpac#update() hasn't finished installing it. I've protected it with a try block for now since I can run the single command myself once the job finishes.