Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Simone Gentili
Simone Gentili

Posted on • Edited on

     

Little Vim distro using Vim8+ packages

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/nerdtreevim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q
Enter fullscreen modeExit fullscreen mode

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 $foldervim -u NONE -c "helptags $golder/doc" -c q
Enter fullscreen modeExit fullscreen mode

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/")
Enter fullscreen modeExit fullscreen mode

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    fidone
Enter fullscreen modeExit fullscreen mode

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 qdoneecho " >>> END plugins installation "
Enter fullscreen modeExit fullscreen mode

The distro

You can find the full and updated version of this vim distro here:sensorario/newdots

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Father
  • Work
    Software Developer @ radical storage
  • Joined

More fromSimone Gentili

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp