Reputation: 9428
I am trying to create installation script for https://github.com/junegunn/vim-plug/wiki/tips
if empty(glob('~/.vim/autoload/plug.vim'))
let s:downloadurl = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
let s:destinedirectory = $HOME . "/.vim/autoload/"
let s:destinefile = s:destinedirectory . "plug.vim"
if !isdirectory(s:destinedirectory)
call mkdir(s:destinedirectory, "p")
echo "Created directory: " . s:destinedirectory
endif
if executable("curl")
silent !curl --location --fail --output s:destinefile --create-dirs s:downloadurl
else
silent !wget -o s:destinefile --force-directories s:downloadurl
endif
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
But vim is not evaluating my variables, i.e., instead of running the command
wget -o /home/user/.vim/plug.vim --force-directories https://raw.githubusercontent...
It is running:
wget -o s:destinefile --force-directories s:downloadurl
Upvotes: 1
Views: 130
Reputation: 7627
You could use execute
to evaluate the variables in commands. For your case:
silent execute '!wget -o '.s:destinefile.' --force-directories '.s:downloadurl
Here the dot is the string concatenation operator documented in :help expr-.
.
Upvotes: 2