191 words
1 minute
Vim Plug Autoload
This post is about how to write some vim-script to autoload the plugin manager from the .vimrc. This makes the process of getting up and running on a new system easier because the plugin manager is automatically downloaded as well as the plugins are also automatically downloaded.
Using the commands from https://github.com/junegunn/vim-plug I was able to create a script to auto download VimPlug for vim and NeoVim on windows and on Linux.
" Expand the home directory to an absolute path.let homeDir = expand('~')
" Find the desired VimPlug install location for different system configurations.if(has('win32') || has('win64')) if has('nvim') let shareDir=homeDir.'\AppData\Local\nvim' let plugVim=shareDir.'\autoload\plug.vim' else let shareDir=homeDir.'\vimfiles' let plugVim=shareDir.'\autoload\plug.vim' endifelse if has('nvim') let shareDir=homeDir.'/.local/share/nvim/site' let plugVim=shareDir.'/autoload/plug.vim' else let shareDir=homeDir.'/.vim' let plugVim=shareDir.'/autoload/plug.vim' endifendif
" Url of the VimPlug script.let plugUri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'if empty(glob(expand(plugVim))) if has('win32') || has('win64') " Make sure the autoload directory has been created. exec '!md '.shareDir.'\autoload'
" Download VimPlug using PowerSHell. exec '!powershell -command Invoke-WebRequest -Uri "'.plugUri.'" -OutFile '.plugVim.'"' else " Download VimPlug using curl. exec '!curl -fLo '.plugVim.' --create-dirs '.plugUri endif
# Automatically run PlugInstall command. autocmd VimEnter * PlugInstall --sync | source $MYVIMRCendif
Vim Plug Autoload
https://jonathanhamberg.com/posts/2019-09-23-vim-plug-autoload/