diff --git a/tips.md b/tips.md index e4922d7..a9a3fd6 100644 --- a/tips.md +++ b/tips.md @@ -20,6 +20,25 @@ If you're behind an HTTP proxy and your proxy does not have TLS/SSL certificates Resort to this only if git cannot get updated certificates or if Github has TLS/SSL issues. +#### Automatic installation of missing plugins + +You can even go a step further and make `:PlugInstall` run on startup if there are any missing plugins. + +```vim +" Install vim-plug if not found +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +endif + +" Run PlugInstall if there are missing plugins +if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif +``` + +Note that this may increase the startup time of Vim. + ### Install plugins on the command line ```sh