diff options
-rw-r--r-- | .vim/after/plugin/minpac.vim | 78 | ||||
-rwxr-xr-x | bin/vim-pack | 119 |
2 files changed, 78 insertions, 119 deletions
diff --git a/.vim/after/plugin/minpac.vim b/.vim/after/plugin/minpac.vim new file mode 100644 index 0000000..9dde72d --- /dev/null +++ b/.vim/after/plugin/minpac.vim @@ -0,0 +1,78 @@ +let g:minpac_initialized = 0 + +function! InitMinpac() abort + if g:minpac_initialized + return + endif + + if empty(glob('~/.vim/pack/vendor/opt/minpac')) + silent !git clone https://github.com/k-takata/minpac.git + \ ~/.vim/pack/vendor/opt/minpac/ + endif + + packadd minpac + call minpac#init({'package_name': 'vendor'}) + + call minpac#add('https://github.com/k-takata/minpac', {'type': 'opt'}) + + call minpac#add('https://github.com/ycm-core/YouCompleteMe', + \ {'do': function('s:build_ycm')}) + call minpac#add('https://github.com/tpope/vim-commentary') + + call minpac#add('https://github.com/SirVer/ultisnips.git') + call minpac#add('https://github.com/honza/vim-snippets') + + call minpac#add('https://github.com/mcchrish/nnn.vim.git') + call minpac#add('https://github.com/junegunn/fzf.git') + call minpac#add('https://github.com/junegunn/fzf.vim.git', {'type': 'opt'}) + call minpac#add('https://github.com/mbbill/undotree.git') + call minpac#add('https://github.com/dense-analysis/ale.git') + call minpac#add('https://github.com/tpope/vim-eunuch.git') + call minpac#add('https://github.com/tpope/vim-sleuth.git') + call minpac#add('https://github.com/godlygeek/tabular.git') + call minpac#add('https://github.com/airblade/vim-rooter.git') + call minpac#add('https://github.com/ludovicchabant/vim-gutentags.git') + call minpac#add('https://github.com/easymotion/vim-easymotion.git') + call minpac#add('https://github.com/editorconfig/editorconfig-vim.git') + call minpac#add('https://github.com/habamax/vim-godot.git') + call minpac#add('https://github.com/ledger/vim-ledger.git') + call minpac#add('https://github.com/mhinz/vim-signify.git') + call minpac#add('https://github.com/tpope/vim-unimpaired.git') + call minpac#add('https://github.com/tpope/vim-surround.git') + call minpac#add('https://github.com/tpope/vim-rsi.git') + call minpac#add('https://github.com/tpope/vim-dispatch.git') + call minpac#add('https://github.com/axvr/org.vim.git') + call minpac#add('https://github.com/dhruvasagar/vim-table-mode.git') + + call minpac#add('https://github.com/voldikss/vim-floaterm.git') + + " git + call minpac#add('https://github.com/tpope/vim-fugitive.git') + call minpac#add('https://github.com/rbong/vim-flog.git') + call minpac#add('https://github.com/iberianpig/tig-explorer.vim') + + " appearance + call minpac#add('https://github.com/joshdick/onedark.vim.git', {'type': 'opt'}) + call minpac#add('https://github.com/vim-airline/vim-airline.git') + call minpac#add('https://github.com/vim-airline/vim-airline-themes.git') + + " chinese input method + call minpac#add('https://github.com/lilydjwg/fcitx.vim.git', {'type': 'opt'}) + call minpac#add('https://github.com/ybian/smartim.git', {'type': 'opt'}) + + let g:minpac_initialized = 1 +endfunction + +command! MinpacUpdate source $MYVIMRC | call InitMinpac() | call minpac#update() +command! MinpacClean source $MYVIMRC | call InitMinpac() | call minpac#clean() +command! MinpacStatus call InitMinpac() | call minpac#status() + +function! s:build_ycm(hooktype, name) + let ycm_install_options = ' --clangd-completer' + + if executable('go') + let ycm_install_options = ycm_install_options . ' --go-completer' + endif + + exec '!python3 ./install.py' . ycm_install_options +endfunction diff --git a/bin/vim-pack b/bin/vim-pack deleted file mode 100755 index 00426ee..0000000 --- a/bin/vim-pack +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env bash - -# package_dirs records directories of all installed packages. It is used -# to help clean unused packages. -package_dirs_file=/tmp/my-vim-package-dirs -[ -f $package_dirs_file ] && rm $package_dirs_file - -package_dirs=() - -update_package () { - name=$1 - remote_url=$2 - - load_type='start' - [ $# -ge 3 ] && load_type=$3 - - package_dir="$HOME/.vim/pack/vendor/$load_type/$name" - echo "$package_dir" >> $package_dirs_file - if [ ! -d $package_dir ]; then - echo "$name : Installing ... " - mkdir -p $package_dir - git clone --depth 1 $remote_url $package_dir && echo "$name : Done" || echo "$name : FAIL" - fi - - cd $package_dir - git fetch origin > /dev/null - - UPSTREAM='@{u}' - LOCAL=$(git rev-parse @) - REMOTE=$(git rev-parse "$UPSTREAM") - BASE=$(git merge-base @ "$UPSTREAM") - UPDATED=0 - - if [ $LOCAL != $REMOTE -a $LOCAL = $BASE ]; then - echo "$name : Updating ... " - git pull && echo "$name : Done" || echo "$name : FAIL" - UPDATED=1 - else - echo "$name : Up to date" - fi - - git submodule update --init --recursive --depth 1 - - if [ $UPDATED -eq 1 -a $# -ge 4 ]; then - $4 - fi -} - -clean () { - if [ ! -f $package_dirs_file ]; then - return - fi - - while IFS= read -r line; do - package_dirs+=("$line") - done < $package_dirs_file - - for load_type in 'opt' 'start'; do - for package_name in $(ls $HOME/.vim/pack/vendor/$load_type); do - package_dir=$HOME/.vim/pack/vendor/$load_type/$package_name - if [[ ! " ${package_dirs[*]} " =~ " ${package_dir} " ]]; then - read -r -p "rm -rf $package_dir? [y/N]: " response - response=${response,,} - if [[ "$response" =~ ^(yes|y)$ ]]; then - rm -rf $package_dir - fi - fi - done - done - - rm $package_dirs_file -} - -install_ycm () { - opts=' --clangd-completer' - - if [ -f /usr/bin/go -o -f /usr/local/bin/go ]; then - opts="$opts --go-completer" - fi - - python3 ./install.py $opts -} - -update_package 'YouCompleteMe' 'https://github.com/ycm-core/YouCompleteMe.git' 'start' 'install_ycm' & -update_package "nnn.vim" "https://github.com/mcchrish/nnn.vim.git" & -update_package 'vim-fugitive' 'https://github.com/tpope/vim-fugitive.git' & -update_package 'vim-flog' 'https://github.com/rbong/vim-flog.git' & -update_package 'fzf' 'https://github.com/junegunn/fzf.git' & -update_package 'fzf.vim' 'https://github.com/junegunn/fzf.vim.git' & -update_package 'ultisnips' 'https://github.com/SirVer/ultisnips.git' & -update_package 'vim-snippets' 'https://github.com/honza/vim-snippets.git' & -update_package 'onedark.vim' 'https://github.com/joshdick/onedark.vim.git' 'opt' & -update_package undotree https://github.com/mbbill/undotree.git & -update_package ale https://github.com/dense-analysis/ale.git & -update_package vim-eunuch https://github.com/tpope/vim-eunuch.git & -update_package vim-sleuth https://github.com/tpope/vim-sleuth.git & -update_package tabular https://github.com/godlygeek/tabular.git & -update_package vim-rooter https://github.com/airblade/vim-rooter.git & -update_package vim-gutentags https://github.com/ludovicchabant/vim-gutentags.git & -update_package vim-airline https://github.com/vim-airline/vim-airline.git & -update_package vim-airline-themes https://github.com/vim-airline/vim-airline-themes.git & -update_package vim-easymotion https://github.com/easymotion/vim-easymotion.git & -update_package editorconfig-vim https://github.com/editorconfig/editorconfig-vim.git & -update_package vim-godot https://github.com/habamax/vim-godot.git & -update_package vim-ledger https://github.com/ledger/vim-ledger.git & -update_package vim-signify https://github.com/mhinz/vim-signify.git & -update_package vim-unimpaired https://github.com/tpope/vim-unimpaired.git & -update_package vim-surround https://github.com/tpope/vim-surround.git & -update_package vim-rsi https://github.com/tpope/vim-rsi.git & -update_package vim-dispatch https://github.com/tpope/vim-dispatch.git & -update_package org.vim https://github.com/axvr/org.vim.git & -update_package fcitx.vim https://github.com/lilydjwg/fcitx.vim.git opt & -update_package smartim https://github.com/ybian/smartim.git opt & -update_package vim-table-mode https://github.com/dhruvasagar/vim-table-mode.git & - -wait -vim '"+helptags ALL"' +q - -clean |