Vim8+ packages
Starting from Vim8 plugins can be installed in ~/.vim/pack
folder. In this folder there could be also repositories. For example Git repositories.
Install NERDTree plugin
The following is the NERDTree installation using Vim8+ packages. As you can see a plugin can be installed in ~./bim/pack
folder. This folder can contain a git repository. In the first line the plugin is installed. In the second line its documentation is installed too.
git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree
vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q
A bash version
In the following four lines the job is the same of the previous chapter. The difference is that destination folder and plugin urls now are variables. So, ... what plugin become a list of items?
folder="~/.vim/pack/vendor/start/nerdtree"
url="https://github.com/preservim/nerdtree.git"
git clone $url $folder
vim -u NONE -c "helptags $golder/doc" -c q
Bash array
I created this simple bash array. Odd items are repository path. Even numbers are folders.
plugins=(
"$HOME/.vim/pack/vendor/start/vim-airline"
"https://github.com/vim-airline/vim-airline.git"
"$HOME/.vim/pack/vendor/start/nerdtree"
"https://github.com/preservim/nerdtree.git"
"$HOME/.vim/pack/vendor/start/nerdtree-git-plugin"
"https://github.com/Xuyuanp/nerdtree-git-plugin.git"
"$HOME/.vim/pack/packages/start/fzf"
"https://github.com/junegunn/fzf.git"
"$HOME/.vim/pack/packages/start/fzf.vim"
"https://github.com/junegunn/fzf.vim.git"
"$HOME/.vim/pack/tpope/start/fugitive"
"https://github.com/tpope/vim-fugitive.git/"
"$HOME/.vim/pack/vendor/start/vim-gitgutter"
"https://github.com/airblade/vim-gitgutter.git/"
)
Array iteration
The following is a script that iterate the array listed in the previous chapter. As you can see only even item are considered. Even items are the folders (folder="${plugins[$i]}"
). Odd items are urls (url="${plugins[$i+1]}"
). In this script I'll check if folder already exists. If the folder exists the repository is pulled down. If the folder does not exists the repository is just cloned.
for i in ${!plugins[@]};
do
if (( i % 2 == 0 ))
then
# echo $i
folder="${plugins[$i]}"
url="${plugins[$i+1]}"
if [ ! -d "$folder" ] ; then
git clone "$url" "$folder"
else
git -C $folder pull
fi
fi
done
Final result
In the final result code I've added just a new line to add the documentation of the plugin.
plugins=(
"$HOME/.vim/pack/vendor/start/vim-airline"
"https://github.com/vim-airline/vim-airline.git"
"$HOME/.vim/pack/vendor/start/nerdtree"
"https://github.com/preservim/nerdtree.git"
"$HOME/.vim/pack/vendor/start/nerdtree-git-plugin"
"https://github.com/Xuyuanp/nerdtree-git-plugin.git"
"$HOME/.vim/pack/packages/start/fzf"
"https://github.com/junegunn/fzf.git"
"$HOME/.vim/pack/packages/start/fzf.vim"
"https://github.com/junegunn/fzf.vim.git"
"$HOME/.vim/pack/tpope/start/fugitive"
"https://github.com/tpope/vim-fugitive.git/"
"$HOME/.vim/pack/vendor/start/vim-gitgutter"
"https://github.com/airblade/vim-gitgutter.git/"
)
echo "\n >>> START plugins installation "
for i in ${!plugins[@]};
do
if (( i % 2 == 0 ))
then
# echo $i
folder="${plugins[$i]}"
url="${plugins[$i+1]}"
if [ ! -d "$folder" ] ; then
git clone "$url" "$folder"
else
git -C $folder pull
fi
fi
vim -u NONE -c "helptags $folder/doc" -c q
done
echo " >>> END plugins installation "
The distro
You can find the full and updated version of this vim distro here: sensorario/newdots
Top comments (0)