├── .gitignore ├── src ├── vanilla.vim ├── package.vim ├── pathogen.vim ├── plug-all.vim ├── vundle.vim ├── plug.vim ├── neobundle-all.vim ├── dein-all.vim ├── dein.vim └── neobundle.vim ├── result ├── result.png ├── result.dat ├── result.gnuplot └── result.svg ├── README.md ├── run.sh └── vimrc /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.report 3 | plugins.vim 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /src/vanilla.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=$TEST_DIR 2 | 3 | filetype plugin indent on 4 | syntax enable 5 | -------------------------------------------------------------------------------- /result/result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junegunn/vim-startuptime-benchmark/HEAD/result/result.png -------------------------------------------------------------------------------- /src/package.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=$TEST_DIR 2 | 3 | set packpath+=$TEST_DIR 4 | filetype plugin indent on 5 | syntax enable 6 | -------------------------------------------------------------------------------- /src/pathogen.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=$TEST_DIR 2 | 3 | call pathogen#infect() 4 | filetype plugin indent on 5 | syntax enable 6 | -------------------------------------------------------------------------------- /result/result.dat: -------------------------------------------------------------------------------- 1 | "vanilla" 0 59 2 | "package" 1 145 3 | "pathogen" 2 146 4 | "vundle" 3 162 5 | "neobundle" 4 188 132 6 | "plug" 5 153 98 7 | "dein" 6 154 107 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | vim-startuptime-benchmark 2 | ========================= 3 | 4 | A benchmark result of Vim startup time with different plugin managers. 5 | 6 | Result 7 | ------ 8 | 9 | *Last update: Dec 6, 2016* 10 | 11 | - MacBook Pro (Retina 13-inch, Early 2015) 12 | - 2.9 GHz Intel Core i5 13 | - VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec 3 2016 21:46:33) 14 | 15 | 16 | -------------------------------------------------------------------------------- /result/result.gnuplot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gnuplot 2 | reset 3 | 4 | set size square 5 | 6 | set term svg size 500,500 font "Monaco,11" solid 7 | set output "result.svg" 8 | 9 | set style data histogram 10 | set style histogram clustered 11 | set boxwidth 0.2 relative 12 | set style fill solid 0 border lt 0 13 | 14 | set yrange [0:*] 15 | 16 | plot 'result.dat' using ($2):3:xtic(1) title 'Startup time (ms)' with boxes fill solid 0.1 ls 2, \ 17 | '' using ($2+0.2):4 title 'Startup time (lazy) (ms)' with boxes fill solid 0.3 ls 2 18 | 19 | -------------------------------------------------------------------------------- /src/plug-all.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=$TEST_DIR 2 | 3 | call plug#begin('$TEST_DIR/bundle') 4 | 5 | " My plugins 6 | Plug 'junegunn/vim-easy-align' 7 | Plug 'junegunn/vim-github-dashboard' 8 | Plug 'junegunn/vim-emoji' 9 | Plug 'junegunn/vim-pseudocl' 10 | Plug 'junegunn/vim-slash' 11 | Plug 'junegunn/vim-fnr' 12 | Plug 'junegunn/vim-peekaboo' 13 | Plug 'junegunn/vim-journal' 14 | Plug 'junegunn/seoul256.vim' 15 | Plug 'junegunn/gv.vim' 16 | Plug 'junegunn/goyo.vim' 17 | Plug 'junegunn/limelight.vim' 18 | Plug 'junegunn/vader.vim' 19 | Plug 'junegunn/vim-ruby-x' 20 | Plug 'junegunn/fzf' 21 | Plug 'junegunn/fzf.vim' 22 | Plug 'junegunn/rainbow_parentheses.vim' 23 | Plug 'junegunn/vim-after-object' 24 | Plug 'junegunn/vim-xmark' 25 | 26 | " Colors 27 | Plug 'tomasr/molokai' 28 | Plug 'chriskempson/vim-tomorrow-theme' 29 | 30 | " Edit 31 | Plug 'tpope/vim-repeat' 32 | Plug 'tpope/vim-surround' 33 | Plug 'tpope/vim-endwise' 34 | Plug 'tpope/vim-commentary' 35 | Plug 'mbbill/undotree' 36 | Plug 'vim-scripts/ReplaceWithRegister' 37 | Plug 'AndrewRadev/splitjoin.vim' 38 | Plug 'rhysd/vim-grammarous' 39 | Plug 'junegunn/vim-online-thesaurus' 40 | 41 | " Tmux 42 | Plug 'tpope/vim-tbone' 43 | 44 | " Browsing 45 | Plug 'Yggdroot/indentLine' 46 | Plug 'scrooloose/nerdtree' 47 | 48 | Plug 'majutsushi/tagbar' 49 | Plug 'justinmk/vim-gtfo' 50 | 51 | " Git 52 | Plug 'tpope/vim-fugitive' 53 | Plug 'mhinz/vim-signify' 54 | 55 | " Lang 56 | Plug 'vim-ruby/vim-ruby' 57 | Plug 'kovisoft/paredit' 58 | Plug 'tpope/vim-fireplace' 59 | Plug 'guns/vim-clojure-static' 60 | Plug 'guns/vim-clojure-highlight' 61 | Plug 'guns/vim-slamhound' 62 | Plug 'fatih/vim-go' 63 | Plug 'groenewege/vim-less' 64 | Plug 'pangloss/vim-javascript' 65 | Plug 'mxw/vim-jsx' 66 | Plug 'kchmck/vim-coffee-script' 67 | Plug 'slim-template/vim-slim' 68 | Plug 'Glench/Vim-Jinja2-Syntax' 69 | Plug 'rust-lang/rust.vim' 70 | Plug 'tpope/vim-rails' 71 | Plug 'derekwyatt/vim-scala' 72 | Plug 'ensime/ensime-vim' 73 | Plug 'honza/dockerfile.vim' 74 | Plug 'solarnz/thrift.vim' 75 | Plug 'dag/vim-fish' 76 | Plug 'chrisbra/unicode.vim' 77 | 78 | " Lint 79 | Plug 'scrooloose/syntastic' 80 | 81 | call plug#end() 82 | " plug#end() does `filetype plugin indent on` and `syntax enable` 83 | -------------------------------------------------------------------------------- /src/vundle.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=$TEST_DIR 2 | 3 | filetype off 4 | 5 | set rtp+=$TEST_DIR/Vundle.vim 6 | call vundle#begin() 7 | let vundle#bundle_dir = expand('$TEST_DIR/bundle') 8 | 9 | " My plugins 10 | Plugin 'junegunn/vim-easy-align' 11 | Plugin 'junegunn/vim-github-dashboard' 12 | Plugin 'junegunn/vim-emoji' 13 | Plugin 'junegunn/vim-pseudocl' 14 | Plugin 'junegunn/vim-slash' 15 | Plugin 'junegunn/vim-fnr' 16 | Plugin 'junegunn/vim-peekaboo' 17 | Plugin 'junegunn/vim-journal' 18 | Plugin 'junegunn/seoul256.vim' 19 | Plugin 'junegunn/gv.vim' 20 | Plugin 'junegunn/goyo.vim' 21 | Plugin 'junegunn/limelight.vim' 22 | Plugin 'junegunn/vader.vim' 23 | Plugin 'junegunn/vim-ruby-x' 24 | Plugin 'junegunn/fzf' 25 | Plugin 'junegunn/fzf.vim' 26 | Plugin 'junegunn/rainbow_parentheses.vim' 27 | Plugin 'junegunn/vim-after-object' 28 | Plugin 'junegunn/vim-xmark' 29 | 30 | " Colors 31 | Plugin 'tomasr/molokai' 32 | Plugin 'chriskempson/vim-tomorrow-theme' 33 | 34 | " Edit 35 | Plugin 'tpope/vim-repeat' 36 | Plugin 'tpope/vim-surround' 37 | Plugin 'tpope/vim-endwise' 38 | Plugin 'tpope/vim-commentary' 39 | Plugin 'mbbill/undotree' 40 | Plugin 'vim-scripts/ReplaceWithRegister' 41 | Plugin 'AndrewRadev/splitjoin.vim' 42 | Plugin 'rhysd/vim-grammarous' 43 | Plugin 'junegunn/vim-online-thesaurus' 44 | 45 | " Tmux 46 | Plugin 'tpope/vim-tbone' 47 | 48 | " Browsing 49 | Plugin 'Yggdroot/indentLine' 50 | Plugin 'scrooloose/nerdtree' 51 | 52 | Plugin 'majutsushi/tagbar' 53 | Plugin 'justinmk/vim-gtfo' 54 | 55 | " Git 56 | Plugin 'tpope/vim-fugitive' 57 | Plugin 'mhinz/vim-signify' 58 | 59 | " Lang 60 | Plugin 'vim-ruby/vim-ruby' 61 | Plugin 'kovisoft/paredit' 62 | Plugin 'tpope/vim-fireplace' 63 | Plugin 'guns/vim-clojure-static' 64 | Plugin 'guns/vim-clojure-highlight' 65 | Plugin 'guns/vim-slamhound' 66 | Plugin 'fatih/vim-go' 67 | Plugin 'groenewege/vim-less' 68 | Plugin 'pangloss/vim-javascript' 69 | Plugin 'mxw/vim-jsx' 70 | Plugin 'kchmck/vim-coffee-script' 71 | Plugin 'slim-template/vim-slim' 72 | Plugin 'Glench/Vim-Jinja2-Syntax' 73 | Plugin 'rust-lang/rust.vim' 74 | Plugin 'tpope/vim-rails' 75 | Plugin 'derekwyatt/vim-scala' 76 | Plugin 'ensime/ensime-vim' 77 | Plugin 'honza/dockerfile.vim' 78 | Plugin 'solarnz/thrift.vim' 79 | Plugin 'dag/vim-fish' 80 | Plugin 'chrisbra/unicode.vim' 81 | 82 | " Lint 83 | Plugin 'scrooloose/syntastic' 84 | 85 | call vundle#end() 86 | filetype plugin indent on 87 | syntax enable 88 | -------------------------------------------------------------------------------- /src/plug.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=$TEST_DIR 2 | 3 | call plug#begin('$TEST_DIR/bundle') 4 | 5 | " My plugins 6 | Plug 'junegunn/vim-easy-align', { 'on': ['(EasyAlign)', 'EasyAlign'] } 7 | Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] } 8 | Plug 'junegunn/vim-emoji' 9 | Plug 'junegunn/vim-pseudocl' 10 | Plug 'junegunn/vim-slash' 11 | Plug 'junegunn/vim-fnr' 12 | Plug 'junegunn/vim-peekaboo' 13 | Plug 'junegunn/vim-journal' 14 | Plug 'junegunn/seoul256.vim' 15 | Plug 'junegunn/gv.vim' 16 | Plug 'junegunn/goyo.vim' 17 | Plug 'junegunn/limelight.vim' 18 | Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' } 19 | Plug 'junegunn/vim-ruby-x', { 'on': 'RubyX' } 20 | Plug 'junegunn/fzf' 21 | Plug 'junegunn/fzf.vim' 22 | Plug 'junegunn/rainbow_parentheses.vim' 23 | Plug 'junegunn/vim-after-object' 24 | Plug 'junegunn/vim-xmark' 25 | 26 | " Colors 27 | Plug 'tomasr/molokai' 28 | Plug 'chriskempson/vim-tomorrow-theme' 29 | 30 | " Edit 31 | Plug 'tpope/vim-repeat' 32 | Plug 'tpope/vim-surround' 33 | Plug 'tpope/vim-endwise' 34 | Plug 'tpope/vim-commentary', { 'on': 'Commentary' } 35 | Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' } 36 | Plug 'vim-scripts/ReplaceWithRegister' 37 | Plug 'AndrewRadev/splitjoin.vim' 38 | Plug 'rhysd/vim-grammarous' 39 | Plug 'junegunn/vim-online-thesaurus' 40 | 41 | " Tmux 42 | Plug 'tpope/vim-tbone' 43 | 44 | " Browsing 45 | Plug 'Yggdroot/indentLine', { 'on': 'IndentLinesEnable' } 46 | Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } 47 | 48 | Plug 'majutsushi/tagbar', { 'on': 'TagbarToggle' } 49 | Plug 'justinmk/vim-gtfo' 50 | 51 | " Git 52 | Plug 'tpope/vim-fugitive' 53 | Plug 'mhinz/vim-signify' 54 | 55 | " Lang 56 | Plug 'vim-ruby/vim-ruby' 57 | Plug 'kovisoft/paredit', { 'for': 'clojure' } 58 | Plug 'tpope/vim-fireplace', { 'for': 'clojure' } 59 | Plug 'guns/vim-clojure-static' 60 | Plug 'guns/vim-clojure-highlight' 61 | Plug 'guns/vim-slamhound' 62 | Plug 'fatih/vim-go' 63 | Plug 'groenewege/vim-less' 64 | Plug 'pangloss/vim-javascript' 65 | Plug 'mxw/vim-jsx' 66 | Plug 'kchmck/vim-coffee-script' 67 | Plug 'slim-template/vim-slim' 68 | Plug 'Glench/Vim-Jinja2-Syntax' 69 | Plug 'rust-lang/rust.vim' 70 | Plug 'tpope/vim-rails', { 'for': [] } 71 | Plug 'derekwyatt/vim-scala' 72 | Plug 'ensime/ensime-vim', { 'for': 'scala' } 73 | Plug 'honza/dockerfile.vim' 74 | Plug 'solarnz/thrift.vim' 75 | Plug 'dag/vim-fish' 76 | Plug 'chrisbra/unicode.vim', { 'for': 'journal' } 77 | 78 | " Lint 79 | Plug 'scrooloose/syntastic', { 'on': 'SyntasticCheck' } 80 | 81 | call plug#end() 82 | " plug#end() does `filetype plugin indent on` and `syntax enable` 83 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd $(dirname $BASH_SOURCE) 4 | 5 | export TEST_DIR=/tmp/vim-startuptime-benchmark 6 | 7 | mkdir -p $TEST_DIR/{autoload,bundle} 8 | 9 | if [[ "$1" = 'init' || ! -d "$TEST_DIR" ]]; then 10 | # Pathogen 11 | curl -LSso $TEST_DIR/autoload/pathogen.vim https://tpo.pe/pathogen.vim 12 | 13 | # vim-plug 14 | curl -fLo $TEST_DIR/autoload/plug.vim https://raw.github.com/junegunn/vim-plug/master/plug.vim 15 | 16 | # Vundle 17 | if [ ! -d $TEST_DIR/bundle/Vundle.vim ]; then 18 | git clone https://github.com/gmarik/Vundle.vim.git $TEST_DIR/Vundle.vim 19 | else 20 | (cd $TEST_DIR/Vundle.vim && git pull) 21 | fi 22 | 23 | # NeoBundle 24 | if [ ! -d $TEST_DIR/bundle/neobundle.vim ]; then 25 | git clone https://github.com/Shougo/neobundle.vim $TEST_DIR/neobundle.vim 26 | else 27 | (cd $TEST_DIR/neobundle.vim && git pull) 28 | fi 29 | 30 | # dein.vim 31 | if [ ! -d $TEST_DIR/dein.vim ]; then 32 | git clone https://github.com/Shougo/dein.vim.git $TEST_DIR/dein.vim 33 | else 34 | (cd $TEST_DIR/dein.vim && git pull) 35 | fi 36 | 37 | # Install plugins in bundle directory 38 | vim -Nu src/plug.vim +PlugInstall +qa 39 | 40 | # Dein installs plugins in different directory structure. 41 | # Manually install plugins with :call dein#install() and quit 42 | ln -sf src/dein.vim plugins.vim 43 | vim -Nu vimrc +'echo ":call dein#install()"' 44 | 45 | ln -sf src/dein-all.vim plugins.vim 46 | vim -Nu vimrc +'echo ":call dein#install()"' 47 | 48 | rm -rf $TEST_DIR/pack/foo 49 | mkdir -p $TEST_DIR/pack/foo 50 | ln -sf $TEST_DIR/bundle $TEST_DIR/pack/foo/start 51 | exit 0 52 | fi 53 | 54 | niter=100 55 | 56 | rm -f *.log startuptime.report 57 | touch startuptime.report 58 | 59 | measure() { 60 | local vpm=$1 61 | ln -sf src/$vpm.vim plugins.vim 62 | for n in $(seq 1 $niter); do 63 | echo -ne "\r$vpm #$n" 64 | vim -Nu vimrc --startuptime _.log +q 65 | tail -1 _.log >> $vpm.log 66 | done 67 | echo 68 | cat $vpm.log | awk '{ sum += $1 } END { printf " %d", sum / NR }' >> "$out" 69 | vim -Nu vimrc --startuptime startuptime.report +q 70 | } 71 | 72 | idx=0 73 | out=result/result.dat 74 | rm "$out" 75 | for vpm in vanilla package pathogen vundle neobundle plug dein; do 76 | echo -n "\"$vpm\" $idx" >> "$out" 77 | if [[ $vpm = neobundle ]] || [[ $vpm = plug ]] || [[ $vpm = dein ]]; then 78 | measure $vpm-all 79 | fi 80 | measure $vpm 81 | echo >> "$out" 82 | idx=$(( idx + 1 )) 83 | done 84 | rm -f *.log 85 | 86 | echo "Creating result/result.svg" 87 | set -eu 88 | cd result 89 | gnuplot result.gnuplot 90 | qlmanage -t -s 1000 -o . result.svg 91 | mv result.svg.png result.png 92 | -------------------------------------------------------------------------------- /src/neobundle-all.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=$TEST_DIR 2 | 3 | if has('vim_starting') 4 | " Required: 5 | set runtimepath+=$TEST_DIR/neobundle.vim/ 6 | endif 7 | 8 | " Required: 9 | call neobundle#begin(expand('$TEST_DIR/bundle')) 10 | 11 | " Let NeoBundle manage NeoBundle 12 | " Required: 13 | NeoBundleFetch 'Shougo/neobundle.vim' 14 | 15 | " My plugins 16 | NeoBundle 'junegunn/vim-easy-align' 17 | NeoBundle 'junegunn/vim-github-dashboard' 18 | NeoBundle 'junegunn/vim-emoji' 19 | NeoBundle 'junegunn/vim-pseudocl' 20 | NeoBundle 'junegunn/vim-slash' 21 | NeoBundle 'junegunn/vim-fnr' 22 | NeoBundle 'junegunn/vim-peekaboo' 23 | NeoBundle 'junegunn/vim-journal' 24 | NeoBundle 'junegunn/seoul256.vim' 25 | NeoBundle 'junegunn/gv.vim' 26 | NeoBundle 'junegunn/goyo.vim' 27 | NeoBundle 'junegunn/limelight.vim' 28 | NeoBundle 'junegunn/vader.vim' 29 | NeoBundle 'junegunn/vim-ruby-x' 30 | NeoBundle 'junegunn/fzf' 31 | NeoBundle 'junegunn/fzf.vim' 32 | NeoBundle 'junegunn/rainbow_parentheses.vim' 33 | NeoBundle 'junegunn/vim-after-object' 34 | NeoBundle 'junegunn/vim-xmark' 35 | 36 | " Colors 37 | NeoBundle 'tomasr/molokai' 38 | NeoBundle 'chriskempson/vim-tomorrow-theme' 39 | 40 | " Edit 41 | NeoBundle 'tpope/vim-repeat' 42 | NeoBundle 'tpope/vim-surround' 43 | NeoBundle 'tpope/vim-endwise' 44 | NeoBundle 'tpope/vim-commentary' 45 | NeoBundle 'mbbill/undotree' 46 | NeoBundle 'vim-scripts/ReplaceWithRegister' 47 | NeoBundle 'AndrewRadev/splitjoin.vim' 48 | NeoBundle 'rhysd/vim-grammarous' 49 | NeoBundle 'junegunn/vim-online-thesaurus' 50 | 51 | " Tmux 52 | NeoBundle 'tpope/vim-tbone' 53 | 54 | " Browsing 55 | NeoBundle 'Yggdroot/indentLine' 56 | NeoBundle 'scrooloose/nerdtree' 57 | 58 | NeoBundle 'majutsushi/tagbar' 59 | NeoBundle 'justinmk/vim-gtfo' 60 | 61 | " Git 62 | NeoBundle 'tpope/vim-fugitive' 63 | NeoBundle 'mhinz/vim-signify' 64 | 65 | " Lang 66 | NeoBundle 'vim-ruby/vim-ruby' 67 | NeoBundle 'kovisoft/paredit' 68 | NeoBundle 'tpope/vim-fireplace' 69 | NeoBundle 'guns/vim-clojure-static' 70 | NeoBundle 'guns/vim-clojure-highlight' 71 | NeoBundle 'guns/vim-slamhound' 72 | NeoBundle 'fatih/vim-go' 73 | NeoBundle 'groenewege/vim-less' 74 | NeoBundle 'pangloss/vim-javascript' 75 | NeoBundle 'mxw/vim-jsx' 76 | NeoBundle 'kchmck/vim-coffee-script' 77 | NeoBundle 'slim-template/vim-slim' 78 | NeoBundle 'Glench/Vim-Jinja2-Syntax' 79 | NeoBundle 'rust-lang/rust.vim' 80 | NeoBundle 'tpope/vim-rails' 81 | NeoBundle 'derekwyatt/vim-scala' 82 | NeoBundle 'ensime/ensime-vim' 83 | NeoBundle 'honza/dockerfile.vim' 84 | NeoBundle 'solarnz/thrift.vim' 85 | NeoBundle 'dag/vim-fish' 86 | NeoBundle 'chrisbra/unicode.vim' 87 | 88 | " Lint 89 | NeoBundle 'scrooloose/syntastic' 90 | 91 | call neobundle#end() 92 | 93 | " Required: 94 | filetype plugin indent on 95 | syntax enable 96 | -------------------------------------------------------------------------------- /src/dein-all.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=$TEST_DIR 2 | 3 | set runtimepath+=$TEST_DIR/dein.vim 4 | call dein#begin($TEST_DIR.'/dein-all') 5 | 6 | " My plugins 7 | call dein#add('junegunn/vim-easy-align') 8 | call dein#add('junegunn/vim-github-dashboard') 9 | call dein#add('junegunn/vim-emoji') 10 | call dein#add('junegunn/vim-pseudocl') 11 | call dein#add('junegunn/vim-slash') 12 | call dein#add('junegunn/vim-fnr') 13 | call dein#add('junegunn/vim-peekaboo') 14 | call dein#add('junegunn/vim-journal') 15 | call dein#add('junegunn/seoul256.vim') 16 | call dein#add('junegunn/gv.vim') 17 | call dein#add('junegunn/goyo.vim') 18 | call dein#add('junegunn/limelight.vim') 19 | call dein#add('junegunn/vader.vim') 20 | call dein#add('junegunn/vim-ruby-x') 21 | call dein#add('junegunn/fzf', { 'merged': 0 }) 22 | call dein#add('junegunn/fzf.vim', { 'merged': 0 }) 23 | call dein#add('junegunn/rainbow_parentheses.vim') 24 | call dein#add('junegunn/vim-after-object') 25 | call dein#add('junegunn/vim-xmark') 26 | 27 | " Colors 28 | call dein#add('tomasr/molokai') 29 | call dein#add('chriskempson/vim-tomorrow-theme') 30 | 31 | " Edit 32 | call dein#add('tpope/vim-repeat') 33 | call dein#add('tpope/vim-surround') 34 | call dein#add('tpope/vim-endwise') 35 | call dein#add('tpope/vim-commentary') 36 | call dein#add('mbbill/undotree') 37 | call dein#add('vim-scripts/ReplaceWithRegister') 38 | call dein#add('AndrewRadev/splitjoin.vim') 39 | call dein#add('rhysd/vim-grammarous') 40 | call dein#add('junegunn/vim-online-thesaurus') 41 | 42 | " Tmux 43 | call dein#add('tpope/vim-tbone') 44 | 45 | " Browsing 46 | call dein#add('Yggdroot/indentLine') 47 | call dein#add('scrooloose/nerdtree') 48 | 49 | call dein#add('majutsushi/tagbar') 50 | call dein#add('justinmk/vim-gtfo') 51 | 52 | " Git 53 | call dein#add('tpope/vim-fugitive') 54 | call dein#add('mhinz/vim-signify') 55 | 56 | " Lang 57 | call dein#add('vim-ruby/vim-ruby') 58 | call dein#add('kovisoft/paredit') 59 | call dein#add('tpope/vim-fireplace') 60 | call dein#add('guns/vim-clojure-static') 61 | call dein#add('guns/vim-clojure-highlight') 62 | call dein#add('guns/vim-slamhound') 63 | call dein#add('fatih/vim-go') 64 | call dein#add('groenewege/vim-less') 65 | call dein#add('pangloss/vim-javascript') 66 | call dein#add('mxw/vim-jsx') 67 | call dein#add('kchmck/vim-coffee-script') 68 | call dein#add('slim-template/vim-slim') 69 | call dein#add('Glench/Vim-Jinja2-Syntax') 70 | call dein#add('rust-lang/rust.vim') 71 | call dein#add('tpope/vim-rails') 72 | call dein#add('derekwyatt/vim-scala') 73 | call dein#add('ensime/ensime-vim') 74 | call dein#add('honza/dockerfile.vim') 75 | call dein#add('solarnz/thrift.vim') 76 | call dein#add('dag/vim-fish') 77 | call dein#add('chrisbra/unicode.vim') 78 | 79 | " Lint 80 | call dein#add('scrooloose/syntastic') 81 | 82 | call dein#end() 83 | 84 | filetype plugin indent on 85 | syntax enable 86 | -------------------------------------------------------------------------------- /src/dein.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=$TEST_DIR 2 | 3 | set runtimepath+=$TEST_DIR/dein.vim 4 | call dein#begin($TEST_DIR.'/dein') 5 | 6 | " My plugins 7 | call dein#add('junegunn/vim-easy-align', { 'on_map': '(EasyAlign)', 'on_cmd': 'EasyAlign' }) 8 | call dein#add('junegunn/vim-github-dashboard', { 'on_cmd': ['GHDashboard', 'GHActivity'] }) 9 | call dein#add('junegunn/vim-emoji') 10 | call dein#add('junegunn/vim-pseudocl') 11 | call dein#add('junegunn/vim-slash') 12 | call dein#add('junegunn/vim-fnr') 13 | call dein#add('junegunn/vim-peekaboo') 14 | call dein#add('junegunn/vim-journal') 15 | call dein#add('junegunn/seoul256.vim') 16 | call dein#add('junegunn/gv.vim') 17 | call dein#add('junegunn/goyo.vim') 18 | call dein#add('junegunn/limelight.vim') 19 | call dein#add('junegunn/vader.vim', { 'on_cmd': 'Vader', 'on_ft': 'vader' }) 20 | call dein#add('junegunn/vim-ruby-x', { 'on_cmd': 'RubyX' }) 21 | call dein#add('junegunn/fzf', { 'merged': 0 }) 22 | call dein#add('junegunn/fzf.vim', { 'merged': 0 }) 23 | call dein#add('junegunn/rainbow_parentheses.vim') 24 | call dein#add('junegunn/vim-after-object') 25 | call dein#add('junegunn/vim-xmark') 26 | 27 | " Colors 28 | call dein#add('tomasr/molokai') 29 | call dein#add('chriskempson/vim-tomorrow-theme') 30 | 31 | " Edit 32 | call dein#add('tpope/vim-repeat') 33 | call dein#add('tpope/vim-surround') 34 | call dein#add('tpope/vim-endwise') 35 | call dein#add('tpope/vim-commentary', { 'on_map': 'Commentary' }) 36 | call dein#add('mbbill/undotree', { 'on_cmd': 'UndotreeToggle' }) 37 | call dein#add('vim-scripts/ReplaceWithRegister') 38 | call dein#add('AndrewRadev/splitjoin.vim') 39 | call dein#add('rhysd/vim-grammarous') 40 | call dein#add('junegunn/vim-online-thesaurus') 41 | 42 | " Tmux 43 | call dein#add('tpope/vim-tbone') 44 | 45 | " Browsing 46 | call dein#add('Yggdroot/indentLine', { 'on_cmd': 'IndentLinesEnable' }) 47 | call dein#add('scrooloose/nerdtree', { 'on_cmd': 'NERDTreeToggle' }) 48 | 49 | call dein#add('majutsushi/tagbar', { 'on_cmd': 'TagbarToggle' }) 50 | call dein#add('justinmk/vim-gtfo') 51 | 52 | " Git 53 | call dein#add('tpope/vim-fugitive') 54 | call dein#add('mhinz/vim-signify') 55 | 56 | " Lang 57 | call dein#add('vim-ruby/vim-ruby') 58 | call dein#add('kovisoft/paredit', { 'on_ft': 'clojure' }) 59 | call dein#add('tpope/vim-fireplace', { 'on_ft': 'clojure' }) 60 | call dein#add('guns/vim-clojure-static') 61 | call dein#add('guns/vim-clojure-highlight') 62 | call dein#add('guns/vim-slamhound') 63 | call dein#add('fatih/vim-go') 64 | call dein#add('groenewege/vim-less') 65 | call dein#add('pangloss/vim-javascript') 66 | call dein#add('mxw/vim-jsx') 67 | call dein#add('kchmck/vim-coffee-script') 68 | call dein#add('slim-template/vim-slim') 69 | call dein#add('Glench/Vim-Jinja2-Syntax') 70 | call dein#add('rust-lang/rust.vim') 71 | call dein#add('tpope/vim-rails', { 'on_ft': [] }) 72 | call dein#add('derekwyatt/vim-scala') 73 | call dein#add('ensime/ensime-vim', { 'on_ft': 'scala' }) 74 | call dein#add('honza/dockerfile.vim') 75 | call dein#add('solarnz/thrift.vim') 76 | call dein#add('dag/vim-fish') 77 | call dein#add('chrisbra/unicode.vim', { 'on_ft': 'journal' }) 78 | 79 | " Lint 80 | call dein#add('scrooloose/syntastic', { 'on_cmd': 'SyntasticCheck' }) 81 | 82 | call dein#end() 83 | 84 | filetype plugin indent on 85 | syntax enable 86 | -------------------------------------------------------------------------------- /src/neobundle.vim: -------------------------------------------------------------------------------- 1 | set runtimepath^=$TEST_DIR 2 | 3 | if has('vim_starting') 4 | " Required: 5 | set runtimepath+=$TEST_DIR/neobundle.vim/ 6 | endif 7 | 8 | " Required: 9 | call neobundle#begin(expand('$TEST_DIR/bundle')) 10 | 11 | " Let NeoBundle manage NeoBundle 12 | " Required: 13 | NeoBundleFetch 'Shougo/neobundle.vim' 14 | 15 | " My plugins 16 | NeoBundleLazy 'junegunn/vim-easy-align', { 'autoload': { 'commands': 'EasyAlign', 'mappings': '(EasyAlign)' } } 17 | NeoBundleLazy 'junegunn/vim-github-dashboard', { 'autoload': { 'commands': ['GHDashboard', 'GHActivity'] } } 18 | NeoBundle 'junegunn/vim-emoji' 19 | NeoBundle 'junegunn/vim-pseudocl' 20 | NeoBundle 'junegunn/vim-slash' 21 | NeoBundle 'junegunn/vim-fnr' 22 | NeoBundle 'junegunn/vim-peekaboo' 23 | NeoBundle 'junegunn/vim-journal' 24 | NeoBundle 'junegunn/seoul256.vim' 25 | NeoBundle 'junegunn/gv.vim' 26 | NeoBundle 'junegunn/goyo.vim' 27 | NeoBundle 'junegunn/limelight.vim' 28 | NeoBundleLazy 'junegunn/vader.vim', { 'autoload': { 'commands': 'Vader', 'filetypes': 'vader' } } 29 | NeoBundleLazy 'junegunn/vim-ruby-x', { 'autoload': { 'commands': 'RubyX' } } 30 | NeoBundle 'junegunn/fzf' 31 | NeoBundle 'junegunn/fzf.vim' 32 | NeoBundle 'junegunn/rainbow_parentheses.vim' 33 | NeoBundle 'junegunn/vim-after-object' 34 | NeoBundle 'junegunn/vim-xmark' 35 | 36 | " Colors 37 | NeoBundle 'tomasr/molokai' 38 | NeoBundle 'chriskempson/vim-tomorrow-theme' 39 | 40 | " Edit 41 | NeoBundle 'tpope/vim-repeat' 42 | NeoBundle 'tpope/vim-surround' 43 | NeoBundle 'tpope/vim-endwise' 44 | NeoBundleLazy 'tpope/vim-commentary', { 'autoload': { 'mappings': 'Commentary' } } 45 | NeoBundleLazy 'mbbill/undotree', { 'autoload': { 'commands': 'UndotreeToggle' } } 46 | NeoBundle 'vim-scripts/ReplaceWithRegister' 47 | NeoBundle 'AndrewRadev/splitjoin.vim' 48 | NeoBundle 'rhysd/vim-grammarous' 49 | NeoBundle 'junegunn/vim-online-thesaurus' 50 | 51 | " Tmux 52 | NeoBundle 'tpope/vim-tbone' 53 | 54 | " Browsing 55 | NeoBundleLazy 'Yggdroot/indentLine', { 'autoload': { 'commands': 'IndentLinesToggle' } } 56 | NeoBundleLazy 'scrooloose/nerdtree', { 'autoload': { 'commands': 'NERDTreeToggle' } } 57 | 58 | NeoBundleLazy 'majutsushi/tagbar', { 'autoload': { 'commands': 'TagbarToggle' } } 59 | NeoBundle 'justinmk/vim-gtfo' 60 | 61 | " Git 62 | NeoBundle 'tpope/vim-fugitive' 63 | NeoBundle 'mhinz/vim-signify' 64 | 65 | " Lang 66 | NeoBundle 'vim-ruby/vim-ruby' 67 | NeoBundleLazy 'kovisoft/paredit', { 'autoload': { 'filetypes': 'clojure' } } 68 | NeoBundleLazy 'tpope/vim-fireplace', { 'autoload': { 'filetypes': 'clojure' } } 69 | NeoBundle 'guns/vim-clojure-static' 70 | NeoBundle 'guns/vim-clojure-highlight' 71 | NeoBundle 'guns/vim-slamhound' 72 | NeoBundle 'fatih/vim-go' 73 | NeoBundle 'groenewege/vim-less' 74 | NeoBundle 'pangloss/vim-javascript' 75 | NeoBundle 'mxw/vim-jsx' 76 | NeoBundle 'kchmck/vim-coffee-script' 77 | NeoBundle 'slim-template/vim-slim' 78 | NeoBundle 'Glench/Vim-Jinja2-Syntax' 79 | NeoBundle 'rust-lang/rust.vim' 80 | NeoBundleLazy 'tpope/vim-rails', { 'autoload': { 'filetypes': [] } } 81 | NeoBundle 'derekwyatt/vim-scala' 82 | NeoBundleLazy 'ensime/ensime-vim', { 'autoload': { 'filetypes': 'scala' } } 83 | NeoBundle 'honza/dockerfile.vim' 84 | NeoBundle 'solarnz/thrift.vim' 85 | NeoBundle 'dag/vim-fish' 86 | NeoBundleLazy 'chrisbra/unicode.vim', { 'autoload': { 'filetypes': 'journal' } } 87 | 88 | " Lint 89 | NeoBundleLazy 'scrooloose/syntastic', { 'autoload': { 'commands': 'SyntasticCheck' } } 90 | 91 | call neobundle#end() 92 | 93 | " Required: 94 | filetype plugin indent on 95 | syntax enable 96 | -------------------------------------------------------------------------------- /result/result.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 10 | 11 | Gnuplot 12 | Produced by GNUPLOT 5.0 patchlevel 5 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 0 49 | 50 | 51 | 52 | 53 | 20 54 | 55 | 56 | 57 | 58 | 40 59 | 60 | 61 | 62 | 63 | 60 64 | 65 | 66 | 67 | 68 | 80 69 | 70 | 71 | 72 | 73 | 100 74 | 75 | 76 | 77 | 78 | 120 79 | 80 | 81 | 82 | 83 | 140 84 | 85 | 86 | 87 | 88 | 160 89 | 90 | 91 | 92 | 93 | 180 94 | 95 | 96 | 97 | 98 | 200 99 | 100 | 101 | 102 | 103 | vanilla 104 | 105 | 106 | 107 | 108 | package 109 | 110 | 111 | 112 | 113 | pathogen 114 | 115 | 116 | 117 | 118 | vundle 119 | 120 | 121 | 122 | 123 | neobundle 124 | 125 | 126 | 127 | 128 | plug 129 | 130 | 131 | 132 | 133 | dein 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | Startup time (ms) 143 | 144 | 145 | Startup time (ms) 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | Startup time (lazy) (ms) 192 | 193 | 194 | Startup time (lazy) (ms) 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | " vim: set foldmethod=marker foldlevel=0: 2 | " ============================================================================ 3 | " .vimrc of Junegunn Choi {{{ 4 | " ============================================================================ 5 | 6 | let s:darwin = has('mac') 7 | 8 | " }}} 9 | " ============================================================================ 10 | " Plugin manager {{{ 11 | " ============================================================================ 12 | 13 | execute 'source '.expand(':h').'/plugins.vim' 14 | 15 | " }}} 16 | " ============================================================================ 17 | " BASIC SETTINGS {{{ 18 | " ============================================================================ 19 | 20 | let mapleader = ' ' 21 | let maplocalleader = ' ' 22 | 23 | augroup vimrc 24 | autocmd! 25 | augroup END 26 | 27 | set nu 28 | set autoindent 29 | set smartindent 30 | set lazyredraw 31 | set laststatus=2 32 | set showcmd 33 | set visualbell 34 | set backspace=indent,eol,start 35 | set timeoutlen=500 36 | set whichwrap=b,s 37 | set shortmess=aIT 38 | set hlsearch " CTRL-L / CTRL-R W 39 | set incsearch 40 | set hidden 41 | set ignorecase smartcase 42 | set wildmenu 43 | set wildmode=full 44 | set tabstop=2 45 | set shiftwidth=2 46 | set expandtab smarttab 47 | set scrolloff=5 48 | set encoding=utf-8 49 | set list 50 | set listchars=tab:\|\ , 51 | set virtualedit=block 52 | set nojoinspaces 53 | set diffopt=filler,vertical 54 | set autoread 55 | set clipboard=unnamed 56 | set foldlevelstart=99 57 | set grepformat=%f:%l:%c:%m,%f:%l:%m 58 | set completeopt=menuone,preview 59 | set nocursorline 60 | set nrformats=hex 61 | silent! set cryptmethod=blowfish2 62 | 63 | set formatoptions+=1 64 | if has('patch-7.3.541') 65 | set formatoptions+=j 66 | endif 67 | if has('patch-7.4.338') 68 | let &showbreak = '↳ ' 69 | set breakindent 70 | set breakindentopt=sbr 71 | endif 72 | 73 | if has('termguicolors') 74 | let &t_8f = "\[38;2;%lu;%lu;%lum" 75 | let &t_8b = "\[48;2;%lu;%lu;%lum" 76 | set termguicolors 77 | endif 78 | 79 | " %< Where to truncate 80 | " %n buffer number 81 | " %F Full path 82 | " %m Modified flag: [+], [-] 83 | " %r Readonly flag: [RO] 84 | " %y Type: [vim] 85 | " fugitive#statusline() 86 | " %= Separator 87 | " %-14.(...) 88 | " %l Line 89 | " %c Column 90 | " %V Virtual column 91 | " %P Percentage 92 | " %#HighlightGroup# 93 | set statusline=%<[%n]\ %F\ %m%r%y\ %{exists('g:loaded_fugitive')?fugitive#statusline():''}\ %=%-14.(%l,%c%V%)\ %P 94 | silent! if emoji#available() 95 | let s:ft_emoji = map({ 96 | \ 'c': 'baby_chick', 97 | \ 'clojure': 'lollipop', 98 | \ 'coffee': 'coffee', 99 | \ 'cpp': 'chicken', 100 | \ 'css': 'art', 101 | \ 'eruby': 'ring', 102 | \ 'gitcommit': 'soon', 103 | \ 'haml': 'hammer', 104 | \ 'help': 'angel', 105 | \ 'html': 'herb', 106 | \ 'java': 'older_man', 107 | \ 'javascript': 'monkey', 108 | \ 'make': 'seedling', 109 | \ 'markdown': 'book', 110 | \ 'perl': 'camel', 111 | \ 'python': 'snake', 112 | \ 'ruby': 'gem', 113 | \ 'scala': 'barber', 114 | \ 'sh': 'shell', 115 | \ 'slim': 'dancer', 116 | \ 'text': 'books', 117 | \ 'vim': 'poop', 118 | \ 'vim-plug': 'electric_plug', 119 | \ 'yaml': 'yum', 120 | \ 'yaml.jinja': 'yum' 121 | \ }, 'emoji#for(v:val)') 122 | 123 | function! S_filetype() 124 | if empty(&filetype) 125 | return emoji#for('grey_question') 126 | else 127 | return get(s:ft_emoji, &filetype, '['.&filetype.']') 128 | endif 129 | endfunction 130 | 131 | function! S_modified() 132 | if &modified 133 | return emoji#for('kiss').' ' 134 | elseif !&modifiable 135 | return emoji#for('construction').' ' 136 | else 137 | return '' 138 | endif 139 | endfunction 140 | 141 | function! S_fugitive() 142 | if !exists('g:loaded_fugitive') 143 | return '' 144 | endif 145 | let head = fugitive#head() 146 | if empty(head) 147 | return '' 148 | else 149 | return head == 'master' ? emoji#for('crown') : emoji#for('dango').'='.head 150 | endif 151 | endfunction 152 | 153 | let s:braille = split('"⠉⠒⠤⣀', '\zs') 154 | function! Braille() 155 | let len = len(s:braille) 156 | let [cur, max] = [line('.'), line('$')] 157 | let pos = min([len * (cur - 1) / max([1, max - 1]), len - 1]) 158 | return s:braille[pos] 159 | endfunction 160 | 161 | hi def link User1 TablineFill 162 | let s:cherry = emoji#for('cherry_blossom') 163 | function! MyStatusLine() 164 | let mod = '%{S_modified()}' 165 | let ro = "%{&readonly ? emoji#for('lock') . ' ' : ''}" 166 | let ft = '%{S_filetype()}' 167 | let fug = ' %{S_fugitive()}' 168 | let sep = ' %= ' 169 | let pos = ' %l,%c%V ' 170 | let pct = ' %P ' 171 | 172 | return s:cherry.' [%n] %F %<'.mod.ro.ft.fug.sep.pos.'%{Braille()}%*'.pct.s:cherry 173 | endfunction 174 | 175 | " Note that the "%!" expression is evaluated in the context of the 176 | " current window and buffer, while %{} items are evaluated in the 177 | " context of the window that the statusline belongs to. 178 | set statusline=%!MyStatusLine() 179 | endif 180 | 181 | set pastetoggle= 182 | set modelines=2 183 | set synmaxcol=1000 184 | 185 | " For MacVim 186 | set noimd 187 | set imi=1 188 | set ims=-1 189 | 190 | " ctags 191 | set tags=./tags;/ 192 | 193 | " Annoying temporary files 194 | set backupdir=/tmp//,. 195 | set directory=/tmp//,. 196 | if v:version >= 703 197 | set undodir=/tmp//,. 198 | endif 199 | 200 | " Shift-tab on GNU screen 201 | " http://superuser.com/questions/195794/gnu-screen-shift-tab-issue 202 | set t_kB= 203 | 204 | " set complete=.,w,b,u,t 205 | set complete-=i 206 | 207 | " mouse 208 | silent! set ttymouse=xterm2 209 | set mouse=a 210 | 211 | " 80 chars/line 212 | set textwidth=0 213 | if exists('&colorcolumn') 214 | set colorcolumn=80 215 | endif 216 | 217 | " Keep the cursor on the same column 218 | set nostartofline 219 | 220 | " FOOBAR=~/ 221 | set isfname-== 222 | 223 | if exists('&fixeol') 224 | set nofixeol 225 | endif 226 | 227 | if has('gui_running') 228 | set guifont=Menlo:h14 columns=80 lines=40 229 | silent! colo seoul256-light 230 | else 231 | silent! colo seoul256 232 | endif 233 | 234 | " }}} 235 | " ============================================================================ 236 | " MAPPINGS {{{ 237 | " ============================================================================ 238 | 239 | " ---------------------------------------------------------------------------- 240 | " Basic mappings 241 | " ---------------------------------------------------------------------------- 242 | 243 | noremap 244 | noremap 245 | 246 | " Save 247 | inoremap :update 248 | nnoremap :update 249 | nnoremap s :update 250 | nnoremap w :update 251 | 252 | " Disable CTRL-A on tmux or on screen 253 | if $TERM =~ 'screen' 254 | nnoremap 255 | nnoremap 256 | endif 257 | 258 | " Quit 259 | inoremap :q 260 | nnoremap :q 261 | vnoremap 262 | nnoremap q :q 263 | nnoremap Q :qa! 264 | 265 | " Tag stack 266 | nnoremap g[ :pop 267 | 268 | " Jump list (to newer position) 269 | nnoremap 270 | 271 | " | NERD Tree 272 | nnoremap :NERDTreeToggle 273 | 274 | " | Tagbar 275 | if v:version >= 703 276 | inoremap :TagbarToggle 277 | nnoremap :TagbarToggle 278 | let g:tagbar_sort = 0 279 | endif 280 | 281 | " jk | Escaping! 282 | inoremap jk 283 | xnoremap jk 284 | cnoremap jk 285 | 286 | " Movement in insert mode 287 | inoremap h 288 | inoremap a 289 | inoremap j 290 | inoremap k 291 | inoremap 292 | 293 | " Make Y behave like other capitals 294 | nnoremap Y y$ 295 | 296 | " qq to record, Q to replay (recursive map due to peekaboo) 297 | nmap Q @q 298 | 299 | " Zoom 300 | function! s:zoom() 301 | if winnr('$') > 1 302 | tab split 303 | elseif len(filter(map(range(tabpagenr('$')), 'tabpagebuflist(v:val + 1)'), 304 | \ 'index(v:val, '.bufnr('').') >= 0')) > 1 305 | tabclose 306 | endif 307 | endfunction 308 | nnoremap z :call zoom() 309 | 310 | " ---------------------------------------------------------------------------- 311 | " nvim 312 | " ---------------------------------------------------------------------------- 313 | if has('nvim') 314 | tnoremap a 315 | tnoremap b 316 | tnoremap d 317 | tnoremap f 318 | endif 319 | 320 | " ---------------------------------------------------------------------------- 321 | " Quickfix 322 | " ---------------------------------------------------------------------------- 323 | nnoremap ]q :cnextzz 324 | nnoremap [q :cprevzz 325 | nnoremap ]l :lnextzz 326 | nnoremap [l :lprevzz 327 | 328 | " ---------------------------------------------------------------------------- 329 | " Buffers 330 | " ---------------------------------------------------------------------------- 331 | nnoremap ]b :bnext 332 | nnoremap [b :bprev 333 | 334 | " ---------------------------------------------------------------------------- 335 | " Tabs 336 | " ---------------------------------------------------------------------------- 337 | nnoremap ]t :tabn 338 | nnoremap [t :tabp 339 | 340 | " ---------------------------------------------------------------------------- 341 | " / | Circular windows navigation 342 | " ---------------------------------------------------------------------------- 343 | nnoremap w 344 | nnoremap W 345 | 346 | " ---------------------------------------------------------------------------- 347 | " / / | super-duper-tab 348 | " ---------------------------------------------------------------------------- 349 | function! s:can_complete(func, prefix) 350 | if empty(a:func) || call(a:func, [1, '']) < 0 351 | return 0 352 | endif 353 | let result = call(a:func, [0, matchstr(a:prefix, '\k\+$')]) 354 | return !empty(type(result) == type([]) ? result : result.words) 355 | endfunction 356 | 357 | function! s:super_duper_tab(k, o) 358 | if pumvisible() 359 | return a:k 360 | endif 361 | 362 | let line = getline('.') 363 | let col = col('.') - 2 364 | if line[col] !~ '\k\|[/~.]' 365 | return a:o 366 | endif 367 | 368 | let prefix = expand(matchstr(line[0:col], '\S*$')) 369 | if prefix =~ '^[~/.]' 370 | return "\\" 371 | endif 372 | if s:can_complete(&omnifunc, prefix) 373 | return "\\" 374 | endif 375 | if s:can_complete(&completefunc, prefix) 376 | return "\\" 377 | endif 378 | return a:k 379 | endfunction 380 | 381 | inoremap super_duper_tab("\", "\") 382 | inoremap super_duper_tab("\", "\") 383 | 384 | " ---------------------------------------------------------------------------- 385 | " Markdown headings 386 | " ---------------------------------------------------------------------------- 387 | nnoremap 1 m`yypVr=`` 388 | nnoremap 2 m`yypVr-`` 389 | nnoremap 3 m`^i### ``4l 390 | nnoremap 4 m`^i#### ``5l 391 | nnoremap 5 m`^i##### ``6l 392 | 393 | " ---------------------------------------------------------------------------- 394 | " Moving lines 395 | " ---------------------------------------------------------------------------- 396 | nnoremap :move-2 397 | nnoremap :move+ 398 | nnoremap << 399 | nnoremap >> 400 | xnoremap :move-2gv 401 | xnoremap :move'>+gv 402 | xnoremap >gv 404 | xnoremap < >gv 406 | 407 | " ---------------------------------------------------------------------------- 408 | " Cscope mappings 409 | " ---------------------------------------------------------------------------- 410 | function! s:add_cscope_db() 411 | " add any database in current directory 412 | let db = findfile('cscope.out', '.;') 413 | if !empty(db) 414 | silent cs reset 415 | silent! execute 'cs add' db 416 | " else add database pointed to by environment 417 | elseif !empty($CSCOPE_DB) 418 | silent cs reset 419 | silent! execute 'cs add' $CSCOPE_DB 420 | endif 421 | endfunction 422 | 423 | if has("cscope") 424 | set csprg=/usr/local/bin/cscope 425 | set csto=0 426 | set cst 427 | set nocsverb 428 | set csverb 429 | call s:add_cscope_db() 430 | 431 | " 's' symbol: find all references to the token under cursor 432 | " 'g' global: find global definition(s) of the token under cursor 433 | " 'c' calls: find all calls to the function name under cursor 434 | " 't' text: find all instances of the text under cursor 435 | " 'e' egrep: egrep search for the word under cursor 436 | " 'f' file: open the filename under cursor 437 | " 'i' includes: find files that include the filename under cursor 438 | " 'd' called: find functions that function under cursor calls 439 | nnoremap s :cs find s =expand("") 440 | nnoremap g :cs find g =expand("") 441 | nnoremap c :cs find c =expand("") 442 | nnoremap t :cs find t =expand("") 443 | xnoremap t y:cs find t " 444 | " nnoremap e :cs find e =expand("") 445 | nnoremap f :cs find f =expand("") 446 | " nnoremap i :cs find i ^=expand("")$ 447 | nnoremap d :cs find d =expand("") 448 | 449 | " extends 450 | nnoremap e :cs find t extends =expand("") 451 | " implements 452 | nnoremap i :cs find t implements =expand("") 453 | " new 454 | nnoremap n :cs find t new =expand("") 455 | endif 456 | 457 | " ---------------------------------------------------------------------------- 458 | " c Close quickfix/location window 459 | " ---------------------------------------------------------------------------- 460 | nnoremap c :ccloselclose 461 | 462 | " ---------------------------------------------------------------------------- 463 | " Readline-style key bindings in command-line (excerpt from rsi.vim) 464 | " ---------------------------------------------------------------------------- 465 | cnoremap 466 | cnoremap 467 | cnoremap getcmdpos()>strlen(getcmdline())?"\C-D>":"\Del>" 468 | cnoremap getcmdpos()>strlen(getcmdline())?&cedit:"\Right>" 469 | cnoremap 470 | cnoremap 471 | silent! exe "set =\b" 472 | silent! exe "set =\f" 473 | 474 | " ---------------------------------------------------------------------------- 475 | " #gi / #gpi | go to next/previous indentation level 476 | " ---------------------------------------------------------------------------- 477 | function! s:go_indent(times, dir) 478 | for _ in range(a:times) 479 | let l = line('.') 480 | let x = line('$') 481 | let i = s:indent_len(getline(l)) 482 | let e = empty(getline(l)) 483 | 484 | while l >= 1 && l <= x 485 | let line = getline(l + a:dir) 486 | let l += a:dir 487 | if s:indent_len(line) != i || empty(line) != e 488 | break 489 | endif 490 | endwhile 491 | let l = min([max([1, l]), x]) 492 | execute 'normal! '. l .'G^' 493 | endfor 494 | endfunction 495 | nnoremap gi :call go_indent(v:count1, 1) 496 | nnoremap gpi :call go_indent(v:count1, -1) 497 | 498 | " ---------------------------------------------------------------------------- 499 | " bs | buf-search 500 | " ---------------------------------------------------------------------------- 501 | nnoremap bs :cex []bufdo vimgrepadd @@g %cw 502 | 503 | " ---------------------------------------------------------------------------- 504 | " #!! | Shebang 505 | " ---------------------------------------------------------------------------- 506 | inoreabbrev #!! "#!/usr/bin/env" . (empty(&filetype) ? '' : ' '.&filetype) 507 | 508 | " ---------------------------------------------------------------------------- 509 | " ij | Open in IntelliJ 510 | " ---------------------------------------------------------------------------- 511 | if s:darwin 512 | nnoremap ij 513 | \ :call system('"/Applications/IntelliJ IDEA CE.app/Contents/MacOS/idea" '.expand('%:p')) 514 | endif 515 | 516 | " }}} 517 | " ============================================================================ 518 | " FUNCTIONS & COMMANDS {{{ 519 | " ============================================================================ 520 | 521 | " ---------------------------------------------------------------------------- 522 | " :CSBuild 523 | " ---------------------------------------------------------------------------- 524 | function! s:build_cscope_db(...) 525 | let git_dir = system('git rev-parse --git-dir') 526 | let chdired = 0 527 | if !v:shell_error 528 | let chdired = 1 529 | execute 'cd' substitute(fnamemodify(git_dir, ':p:h'), ' ', '\\ ', 'g') 530 | endif 531 | 532 | let exts = empty(a:000) ? 533 | \ ['java', 'c', 'h', 'cc', 'hh', 'cpp', 'hpp'] : a:000 534 | 535 | let cmd = "find . " . join(map(exts, "\"-name '*.\" . v:val . \"'\""), ' -o ') 536 | let tmp = tempname() 537 | try 538 | echon 'Building cscope.files' 539 | call system(cmd.' | grep -v /test/ > '.tmp) 540 | echon ' - cscoped db' 541 | call system('cscope -b -q -i'.tmp) 542 | echon ' - complete!' 543 | call s:add_cscope_db() 544 | finally 545 | silent! call delete(tmp) 546 | if chdired 547 | cd - 548 | endif 549 | endtry 550 | endfunction 551 | command! CSBuild call s:build_cscope_db() 552 | 553 | " ---------------------------------------------------------------------------- 554 | " :Chomp 555 | " ---------------------------------------------------------------------------- 556 | command! Chomp %s/\s\+$// | normal! `` 557 | 558 | " ---------------------------------------------------------------------------- 559 | " :Count 560 | " ---------------------------------------------------------------------------- 561 | command! -nargs=1 Count execute printf('%%s/%s//gn', escape(, '/')) | normal! `` 562 | 563 | " ---------------------------------------------------------------------------- 564 | " :CopyRTF 565 | " ---------------------------------------------------------------------------- 566 | function! s:colors(...) 567 | return filter(map(filter(split(globpath(&rtp, 'colors/*.vim'), "\n"), 568 | \ 'v:val !~ "^/usr/"'), 569 | \ 'fnamemodify(v:val, ":t:r")'), 570 | \ '!a:0 || stridx(v:val, a:1) >= 0') 571 | endfunction 572 | 573 | function! s:copy_rtf(line1, line2, ...) 574 | let [ft, cs, nu] = [&filetype, g:colors_name, &l:nu] 575 | let lines = getline(1, '$') 576 | 577 | tab new 578 | setlocal buftype=nofile bufhidden=wipe nonumber 579 | let &filetype = ft 580 | call setline(1, lines) 581 | 582 | execute 'colo' get(a:000, 0, 'seoul256-light') 583 | hi Normal ctermbg=NONE guibg=NONE 584 | 585 | let lines = getline(a:line1, a:line2) 586 | let indent = repeat(' ', min(map(filter(copy(lines), '!empty(v:val)'), 'len(matchstr(v:val, "^ *"))'))) 587 | call setline(a:line1, map(lines, 'substitute(v:val, indent, "", "")')) 588 | 589 | call tohtml#Convert2HTML(a:line1, a:line2) 590 | g/^\(pre\|body\) {/s/background-color: #[0-9]*; // 591 | silent %write !textutil -convert rtf -textsizemultiplier 1.3 -stdin -stdout | pbcopy 592 | 593 | bd! 594 | tabclose 595 | 596 | let &l:nu = nu 597 | execute 'colorscheme' cs 598 | endfunction 599 | 600 | if s:darwin 601 | command! -range=% -nargs=? -complete=customlist,s:colors CopyRTF call s:copy_rtf(, , ) 602 | endif 603 | 604 | " ---------------------------------------------------------------------------- 605 | " :Root | Change directory to the root of the Git repository 606 | " ---------------------------------------------------------------------------- 607 | function! s:root() 608 | let root = systemlist('git rev-parse --show-toplevel')[0] 609 | if v:shell_error 610 | echo 'Not in git repo' 611 | else 612 | execute 'lcd' root 613 | echo 'Changed directory to: '.root 614 | endif 615 | endfunction 616 | command! Root call s:root() 617 | 618 | " ---------------------------------------------------------------------------- 619 | " / | Run script 620 | " ---------------------------------------------------------------------------- 621 | function! s:run_this_script(output) 622 | let head = getline(1) 623 | let pos = stridx(head, '#!') 624 | let file = expand('%:p') 625 | let ofile = tempname() 626 | let rdr = " 2>&1 | tee ".ofile 627 | let win = winnr() 628 | let prefix = a:output ? 'silent !' : '!' 629 | " Shebang found 630 | if pos != -1 631 | execute prefix.strpart(head, pos + 2).' '.file.rdr 632 | " Shebang not found but executable 633 | elseif executable(file) 634 | execute prefix.file.rdr 635 | elseif &filetype == 'ruby' 636 | execute prefix.'/usr/bin/env ruby '.file.rdr 637 | elseif &filetype == 'tex' 638 | execute prefix.'latex '.file. '; [ $? -eq 0 ] && xdvi '. expand('%:r').rdr 639 | elseif &filetype == 'dot' 640 | let svg = expand('%:r') . '.svg' 641 | let png = expand('%:r') . '.png' 642 | " librsvg >> imagemagick + ghostscript 643 | execute 'silent !dot -Tsvg '.file.' -o '.svg.' && ' 644 | \ 'rsvg-convert -z 2 '.svg.' > '.png.' && open '.png.rdr 645 | else 646 | return 647 | end 648 | redraw! 649 | if !a:output | return | endif 650 | 651 | " Scratch buffer 652 | if exists('s:vim_exec_buf') && bufexists(s:vim_exec_buf) 653 | execute bufwinnr(s:vim_exec_buf).'wincmd w' 654 | %d 655 | else 656 | silent! bdelete [vim-exec-output] 657 | silent! vertical botright split new 658 | silent! file [vim-exec-output] 659 | setlocal buftype=nofile bufhidden=wipe noswapfile 660 | let s:vim_exec_buf = winnr() 661 | endif 662 | execute 'silent! read' ofile 663 | normal! gg"_dd 664 | execute win.'wincmd w' 665 | endfunction 666 | nnoremap :call run_this_script(0) 667 | nnoremap :call run_this_script(1) 668 | 669 | " ---------------------------------------------------------------------------- 670 | " | Color scheme selector 671 | " ---------------------------------------------------------------------------- 672 | function! s:rotate_colors() 673 | if !exists('s:colors') 674 | let s:colors = s:colors() 675 | endif 676 | let name = remove(s:colors, 0) 677 | call add(s:colors, name) 678 | execute 'colorscheme' name 679 | redraw 680 | echo name 681 | endfunction 682 | nnoremap :call rotate_colors() 683 | 684 | " ---------------------------------------------------------------------------- 685 | " :Shuffle | Shuffle selected lines 686 | " ---------------------------------------------------------------------------- 687 | function! s:shuffle() range 688 | ruby << RB 689 | first, last = %w[a:firstline a:lastline].map { |e| VIM::evaluate(e).to_i } 690 | (first..last).map { |l| $curbuf[l] }.shuffle.each_with_index do |line, i| 691 | $curbuf[first + i] = line 692 | end 693 | RB 694 | endfunction 695 | command! -range Shuffle ,call s:shuffle() 696 | 697 | " ---------------------------------------------------------------------------- 698 | " Syntax highlighting in code snippets 699 | " ---------------------------------------------------------------------------- 700 | function! s:syntax_include(lang, b, e, inclusive) 701 | let syns = split(globpath(&rtp, "syntax/".a:lang.".vim"), "\n") 702 | if empty(syns) 703 | return 704 | endif 705 | 706 | if exists('b:current_syntax') 707 | let csyn = b:current_syntax 708 | unlet b:current_syntax 709 | endif 710 | 711 | let z = "'" " Default 712 | for nr in range(char2nr('a'), char2nr('z')) 713 | let char = nr2char(nr) 714 | if a:b !~ char && a:e !~ char 715 | let z = char 716 | break 717 | endif 718 | endfor 719 | 720 | silent! exec printf("syntax include @%s %s", a:lang, syns[0]) 721 | if a:inclusive 722 | exec printf('syntax region %sSnip start=%s\(%s\)\@=%s ' . 723 | \ 'end=%s\(%s\)\@<=\(\)%s contains=@%s containedin=ALL', 724 | \ a:lang, z, a:b, z, z, a:e, z, a:lang) 725 | else 726 | exec printf('syntax region %sSnip matchgroup=Snip start=%s%s%s ' . 727 | \ 'end=%s%s%s contains=@%s containedin=ALL', 728 | \ a:lang, z, a:b, z, z, a:e, z, a:lang) 729 | endif 730 | 731 | if exists('csyn') 732 | let b:current_syntax = csyn 733 | endif 734 | endfunction 735 | 736 | function! s:file_type_handler() 737 | if &ft =~ 'jinja' && &ft != 'jinja' 738 | call s:syntax_include('jinja', '{{', '}}', 1) 739 | call s:syntax_include('jinja', '{%', '%}', 1) 740 | elseif &ft =~ 'mkd\|markdown' 741 | for lang in ['ruby', 'yaml', 'vim', 'sh', 'bash:sh', 'python', 'java', 'c', 742 | \ 'clojure', 'clj:clojure', 'scala', 'sql', 'gnuplot'] 743 | call s:syntax_include(split(lang, ':')[-1], '```'.split(lang, ':')[0], '```', 0) 744 | endfor 745 | 746 | highlight def link Snip Folded 747 | setlocal textwidth=78 748 | setlocal completefunc=emoji#complete 749 | elseif &ft == 'sh' 750 | call s:syntax_include('ruby', '#!ruby', '/\%$', 1) 751 | endif 752 | endfunction 753 | 754 | " ---------------------------------------------------------------------------- 755 | " SaveMacro / LoadMacro 756 | " ---------------------------------------------------------------------------- 757 | function! s:save_macro(name, file) 758 | let content = eval('@'.a:name) 759 | if !empty(content) 760 | call writefile(split(content, "\n"), a:file) 761 | echom len(content) . " bytes save to ". a:file 762 | endif 763 | endfunction 764 | command! -nargs=* SaveMacro call save_macro() 765 | 766 | function! s:load_macro(file, name) 767 | let data = join(readfile(a:file), "\n") 768 | call setreg(a:name, data, 'c') 769 | echom "Macro loaded to @". a:name 770 | endfunction 771 | command! -nargs=* LoadMacro call load_macro() 772 | 773 | " ---------------------------------------------------------------------------- 774 | " HL | Find out syntax group 775 | " ---------------------------------------------------------------------------- 776 | function! s:hl() 777 | " echo synIDattr(synID(line('.'), col('.'), 0), 'name') 778 | echo join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'), '/') 779 | endfunction 780 | command! HL call hl() 781 | 782 | " ---------------------------------------------------------------------------- 783 | " :A 784 | " ---------------------------------------------------------------------------- 785 | function! s:a() 786 | let name = expand('%:r') 787 | let ext = tolower(expand('%:e')) 788 | let sources = ['c', 'cc', 'cpp', 'cxx'] 789 | let headers = ['h', 'hh', 'hpp', 'hxx'] 790 | for pair in [[sources, headers], [headers, sources]] 791 | let [set1, set2] = pair 792 | if index(set1, ext) >= 0 793 | for h in set2 794 | let aname = name.'.'.h 795 | for a in [aname, toupper(aname)] 796 | if filereadable(a) 797 | execute 'e' a 798 | return 799 | end 800 | endfor 801 | endfor 802 | endif 803 | endfor 804 | endfunction 805 | command! A call s:a() 806 | 807 | " ---------------------------------------------------------------------------- 808 | " Todo 809 | " ---------------------------------------------------------------------------- 810 | function! s:todo() abort 811 | let entries = [] 812 | for cmd in ['git grep -n -e TODO -e FIXME -e XXX 2> /dev/null', 813 | \ 'grep -rn -e TODO -e FIXME -e XXX * 2> /dev/null'] 814 | let lines = split(system(cmd), '\n') 815 | if v:shell_error != 0 | continue | endif 816 | for line in lines 817 | let [fname, lno, text] = matchlist(line, '^\([^:]*\):\([^:]*\):\(.*\)')[1:3] 818 | call add(entries, { 'filename': fname, 'lnum': lno, 'text': text }) 819 | endfor 820 | break 821 | endfor 822 | 823 | if !empty(entries) 824 | call setqflist(entries) 825 | copen 826 | endif 827 | endfunction 828 | command! Todo call s:todo() 829 | 830 | " ---------------------------------------------------------------------------- 831 | " ConnectChrome 832 | " ---------------------------------------------------------------------------- 833 | if s:darwin 834 | function! s:connect_chrome(bang) 835 | augroup connect-chrome 836 | autocmd! 837 | if !a:bang 838 | autocmd BufWritePost call system(join([ 839 | \ "osascript -e 'tell application \"Google Chrome\"". 840 | \ "to tell the active tab of its first window\n", 841 | \ " reload", 842 | \ "end tell'"], "\n")) 843 | endif 844 | augroup END 845 | endfunction 846 | command! -bang ConnectChrome call s:connect_chrome(0) 847 | endif 848 | 849 | " ---------------------------------------------------------------------------- 850 | " AutoSave 851 | " ---------------------------------------------------------------------------- 852 | function! s:autosave(enable) 853 | augroup autosave 854 | autocmd! 855 | if a:enable 856 | autocmd TextChanged,InsertLeave 857 | \ if empty(&buftype) && !empty(bufname('')) 858 | \| silent! update 859 | \| endif 860 | endif 861 | augroup END 862 | endfunction 863 | 864 | command! -bang AutoSave call s:autosave(1) 865 | 866 | " ---------------------------------------------------------------------------- 867 | " TX 868 | " ---------------------------------------------------------------------------- 869 | command! -nargs=1 TX 870 | \ call system('tmux split-window -d -l 16 '.) 871 | cnoremap !! TX 872 | 873 | " ---------------------------------------------------------------------------- 874 | " EX | chmod +x 875 | " ---------------------------------------------------------------------------- 876 | command! EX if !empty(expand('%')) 877 | \| write 878 | \| call system('chmod +x '.expand('%')) 879 | \| silent e 880 | \| else 881 | \| echohl WarningMsg 882 | \| echo 'Save the file first' 883 | \| echohl None 884 | \| endif 885 | 886 | " ---------------------------------------------------------------------------- 887 | " Profile 888 | " ---------------------------------------------------------------------------- 889 | function! s:profile(bang) 890 | if a:bang 891 | profile pause 892 | noautocmd qall 893 | else 894 | profile start /tmp/profile.log 895 | profile func * 896 | profile file * 897 | endif 898 | endfunction 899 | command! -bang Profile call s:profile(0) 900 | 901 | " ---------------------------------------------------------------------------- 902 | " call LSD() 903 | " ---------------------------------------------------------------------------- 904 | function! LSD() 905 | syntax clear 906 | 907 | for i in range(16, 255) 908 | execute printf('highlight LSD%s ctermfg=%s', i - 16, i) 909 | endfor 910 | 911 | let block = 4 912 | for l in range(1, line('$')) 913 | let c = 1 914 | let max = len(getline(l)) 915 | while c < max 916 | let stride = 4 + reltime()[1] % 8 917 | execute printf('syntax region lsd%s_%s start=/\%%%sl\%%%sc/ end=/\%%%sl\%%%sc/ contains=ALL', l, c, l, c, l, min([c + stride, max])) 918 | let rand = abs(reltime()[1] % (256 - 16)) 919 | execute printf('hi def link lsd%s_%s LSD%s', l, c, rand) 920 | let c += stride 921 | endwhile 922 | endfor 923 | endfunction 924 | 925 | " ---------------------------------------------------------------------------- 926 | " co? : Toggle options (inspired by unimpaired.vim) 927 | " ---------------------------------------------------------------------------- 928 | function! s:map_change_option(...) 929 | let [key, opt] = a:000[0:1] 930 | let op = get(a:, 3, 'set '.opt.'!') 931 | execute printf("nnoremap co%s :%sset %s?", key, op, opt) 932 | endfunction 933 | 934 | call s:map_change_option('p', 'paste') 935 | call s:map_change_option('n', 'number') 936 | call s:map_change_option('w', 'wrap') 937 | call s:map_change_option('h', 'hlsearch') 938 | call s:map_change_option('m', 'mouse', 'let &mouse = &mouse == "" ? "a" : ""') 939 | call s:map_change_option('t', 'textwidth', 940 | \ 'let &textwidth = input("textwidth (". &textwidth ."): ")redraw') 941 | call s:map_change_option('b', 'background', 942 | \ 'let &background = &background == "dark" ? "light" : "dark"redraw') 943 | 944 | " ---------------------------------------------------------------------------- 945 | " ?/! | Google it / Feeling lucky 946 | " ---------------------------------------------------------------------------- 947 | function! s:goog(pat, lucky) 948 | let q = '"'.substitute(a:pat, '["\n]', ' ', 'g').'"' 949 | let q = substitute(q, '[[:punct:] ]', 950 | \ '\=printf("%%%02X", char2nr(submatch(0)))', 'g') 951 | call system(printf('open "https://www.google.com/search?%sq=%s"', 952 | \ a:lucky ? 'btnI&' : '', q)) 953 | endfunction 954 | 955 | nnoremap ? :call goog(expand(""), 0) 956 | nnoremap ! :call goog(expand(""), 1) 957 | xnoremap ? "gy:call goog(@g, 0)gv 958 | xnoremap ! "gy:call goog(@g, 1)gv 959 | 960 | 961 | " }}} 962 | " ============================================================================ 963 | " TEXT OBJECTS {{{ 964 | " ============================================================================ 965 | 966 | " ---------------------------------------------------------------------------- 967 | " Common 968 | " ---------------------------------------------------------------------------- 969 | function! s:textobj_cancel() 970 | if v:operator == 'c' 971 | augroup textobj_undo_empty_change 972 | autocmd InsertLeave execute 'normal! u' 973 | \| execute 'autocmd! textobj_undo_empty_change' 974 | \| execute 'augroup! textobj_undo_empty_change' 975 | augroup END 976 | endif 977 | endfunction 978 | 979 | noremap (TOC) 980 | inoremap (TOC) exists('#textobj_undo_empty_change')?"\":'' 981 | 982 | " ---------------------------------------------------------------------------- 983 | " ?ii / ?ai | indent-object 984 | " ?io | strictly-indent-object 985 | " ---------------------------------------------------------------------------- 986 | function! s:indent_len(str) 987 | return type(a:str) == 1 ? len(matchstr(a:str, '^\s*')) : 0 988 | endfunction 989 | 990 | function! s:indent_object(op, skip_blank, b, e, bd, ed) 991 | let i = min([s:indent_len(getline(a:b)), s:indent_len(getline(a:e))]) 992 | let x = line('$') 993 | let d = [a:b, a:e] 994 | 995 | if i == 0 && empty(getline(a:b)) && empty(getline(a:e)) 996 | let [b, e] = [a:b, a:e] 997 | while b > 0 && e <= line('$') 998 | let b -= 1 999 | let e += 1 1000 | let i = min(filter(map([b, e], 's:indent_len(getline(v:val))'), 'v:val != 0')) 1001 | if i > 0 1002 | break 1003 | endif 1004 | endwhile 1005 | endif 1006 | 1007 | for triple in [[0, 'd[o] > 1', -1], [1, 'd[o] < x', +1]] 1008 | let [o, ev, df] = triple 1009 | 1010 | while eval(ev) 1011 | let line = getline(d[o] + df) 1012 | let idt = s:indent_len(line) 1013 | 1014 | if eval('idt '.a:op.' i') && (a:skip_blank || !empty(line)) || (a:skip_blank && empty(line)) 1015 | let d[o] += df 1016 | else | break | end 1017 | endwhile 1018 | endfor 1019 | execute printf('normal! %dGV%dG', max([1, d[0] + a:bd]), min([x, d[1] + a:ed])) 1020 | endfunction 1021 | xnoremap ii :call indent_object('>=', 1, line("'<"), line("'>"), 0, 0) 1022 | onoremap ii :call indent_object('>=', 1, line('.'), line('.'), 0, 0) 1023 | xnoremap ai :call indent_object('>=', 1, line("'<"), line("'>"), -1, 1) 1024 | onoremap ai :call indent_object('>=', 1, line('.'), line('.'), -1, 1) 1025 | xnoremap io :call indent_object('==', 0, line("'<"), line("'>"), 0, 0) 1026 | onoremap io :call indent_object('==', 0, line('.'), line('.'), 0, 0) 1027 | 1028 | " ---------------------------------------------------------------------------- 1029 | " I/A | Prepend/Append to all adjacent lines with same indentation 1030 | " ---------------------------------------------------------------------------- 1031 | nmap I ^vioI 1032 | nmap A ^vio$A 1033 | 1034 | " ---------------------------------------------------------------------------- 1035 | " ?i_ ?a_ ?i. ?a. ?i, ?a, ?i/ 1036 | " ---------------------------------------------------------------------------- 1037 | function! s:between_the_chars(incll, inclr, char, vis) 1038 | let cursor = col('.') 1039 | let line = getline('.') 1040 | let before = line[0 : cursor - 1] 1041 | let after = line[cursor : -1] 1042 | let [b, e] = [cursor, cursor] 1043 | 1044 | try 1045 | let i = stridx(join(reverse(split(before, '\zs')), ''), a:char) 1046 | if i < 0 | throw 'exit' | end 1047 | let b = len(before) - i + (a:incll ? 0 : 1) 1048 | 1049 | let i = stridx(after, a:char) 1050 | if i < 0 | throw 'exit' | end 1051 | let e = cursor + i + 1 - (a:inclr ? 0 : 1) 1052 | 1053 | execute printf("normal! 0%dlhv0%dlh", b, e) 1054 | catch 'exit' 1055 | call s:textobj_cancel() 1056 | if a:vis 1057 | normal! gv 1058 | endif 1059 | finally 1060 | " Cleanup command history 1061 | if histget(':', -1) =~ '[0-9_]*between_the_chars(' 1062 | call histdel(':', -1) 1063 | endif 1064 | echo 1065 | endtry 1066 | endfunction 1067 | 1068 | for [s:c, s:l] in items({'_': 0, '.': 0, ',': 0, '/': 1, '-': 0}) 1069 | execute printf("xmap i%s :call between_the_chars(0, 0, '%s', 1)(TOC)", s:c, s:c) 1070 | execute printf("omap i%s :call between_the_chars(0, 0, '%s', 0)(TOC)", s:c, s:c) 1071 | execute printf("xmap a%s :call between_the_chars(%s, 1, '%s', 1)(TOC)", s:c, s:l, s:c) 1072 | execute printf("omap a%s :call between_the_chars(%s, 1, '%s', 0)(TOC)", s:c, s:l, s:c) 1073 | endfor 1074 | 1075 | " ---------------------------------------------------------------------------- 1076 | " ?ie | entire object 1077 | " ---------------------------------------------------------------------------- 1078 | xnoremap ie gg0oG$ 1079 | onoremap ie :execute "normal! m`"keepjumps normal! ggVG 1080 | 1081 | " ---------------------------------------------------------------------------- 1082 | " ?il | inner line 1083 | " ---------------------------------------------------------------------------- 1084 | xnoremap il ^vg_ 1085 | onoremap il :normal! ^vg_ 1086 | 1087 | " ---------------------------------------------------------------------------- 1088 | " ?i# | inner comment 1089 | " ---------------------------------------------------------------------------- 1090 | function! s:inner_comment(vis) 1091 | if synIDattr(synID(line('.'), col('.'), 0), 'name') !~? 'comment' 1092 | call s:textobj_cancel() 1093 | if a:vis 1094 | normal! gv 1095 | endif 1096 | return 1097 | endif 1098 | 1099 | let origin = line('.') 1100 | let lines = [] 1101 | for dir in [-1, 1] 1102 | let line = origin 1103 | let line += dir 1104 | while line >= 1 && line <= line('$') 1105 | execute 'normal!' line.'G^' 1106 | if synIDattr(synID(line('.'), col('.'), 0), 'name') !~? 'comment' 1107 | break 1108 | endif 1109 | let line += dir 1110 | endwhile 1111 | let line -= dir 1112 | call add(lines, line) 1113 | endfor 1114 | 1115 | execute 'normal!' lines[0].'GV'.lines[1].'G' 1116 | endfunction 1117 | xmap i# :call inner_comment(1)(TOC) 1118 | omap i# :call inner_comment(0)(TOC) 1119 | 1120 | " ---------------------------------------------------------------------------- 1121 | " ?ic / ?iC | Blockwise column object 1122 | " ---------------------------------------------------------------------------- 1123 | function! s:inner_blockwise_column(vmode, cmd) 1124 | if a:vmode == "\" 1125 | let [pvb, pve] = [getpos("'<"), getpos("'>")] 1126 | normal! `z 1127 | endif 1128 | 1129 | execute "normal! \".a:cmd."o\" 1130 | let [line, col] = [line('.'), col('.')] 1131 | let [cb, ce] = [col("'<"), col("'>")] 1132 | let [mn, mx] = [line, line] 1133 | 1134 | for dir in [1, -1] 1135 | let l = line + dir 1136 | while line('.') > 1 && line('.') < line('$') 1137 | execute "normal! ".l."G".col."|" 1138 | execute "normal! v".a:cmd."\" 1139 | if cb != col("'<") || ce != col("'>") 1140 | break 1141 | endif 1142 | let [mn, mx] = [min([line('.'), mn]), max([line('.'), mx])] 1143 | let l += dir 1144 | endwhile 1145 | endfor 1146 | 1147 | execute printf("normal! %dG%d|\%s%dG", mn, col, a:cmd, mx) 1148 | 1149 | if a:vmode == "\" 1150 | normal! o 1151 | if pvb[1] < line('.') | execute "normal! ".pvb[1]."G" | endif 1152 | if pvb[2] < col('.') | execute "normal! ".pvb[2]."|" | endif 1153 | normal! o 1154 | if pve[1] > line('.') | execute "normal! ".pve[1]."G" | endif 1155 | if pve[2] > col('.') | execute "normal! ".pve[2]."|" | endif 1156 | endif 1157 | endfunction 1158 | 1159 | xnoremap ic mz:call inner_blockwise_column(visualmode(), 'iw') 1160 | xnoremap iC mz:call inner_blockwise_column(visualmode(), 'iW') 1161 | xnoremap ac mz:call inner_blockwise_column(visualmode(), 'aw') 1162 | xnoremap aC mz:call inner_blockwise_column(visualmode(), 'aW') 1163 | onoremap ic :call inner_blockwise_column('', 'iw') 1164 | onoremap iC :call inner_blockwise_column('', 'iW') 1165 | onoremap ac :call inner_blockwise_column('', 'aw') 1166 | onoremap aC :call inner_blockwise_column('', 'aW') 1167 | 1168 | " ---------------------------------------------------------------------------- 1169 | " ?i-` | Inside ``` block 1170 | " ---------------------------------------------------------------------------- 1171 | xnoremap i~ g_?^```jo/^```kV:nohlgv 1172 | xnoremap a~ g_?^```o/^```V:nohlgv 1173 | onoremap i~ :execute "normal vi`" 1174 | onoremap a~ :execute "normal va`" 1175 | 1176 | 1177 | " }}} 1178 | " ============================================================================ 1179 | " PLUGINS {{{ 1180 | " ============================================================================ 1181 | 1182 | " ---------------------------------------------------------------------------- 1183 | " MatchParen delay 1184 | " ---------------------------------------------------------------------------- 1185 | let g:matchparen_insert_timeout=5 1186 | 1187 | " ---------------------------------------------------------------------------- 1188 | " vim-commentary 1189 | " ---------------------------------------------------------------------------- 1190 | map gc Commentary 1191 | nmap gcc CommentaryLine 1192 | 1193 | " ---------------------------------------------------------------------------- 1194 | " vim-fugitive 1195 | " ---------------------------------------------------------------------------- 1196 | nmap g :Gstatusgg 1197 | nnoremap d :Gdiff 1198 | 1199 | " ---------------------------------------------------------------------------- 1200 | " vim-ruby (https://github.com/vim-ruby/vim-ruby/issues/33) 1201 | " ---------------------------------------------------------------------------- 1202 | if !empty(matchstr($MY_RUBY_HOME, 'jruby')) 1203 | let g:ruby_path = join(split( 1204 | \ glob($MY_RUBY_HOME.'/lib/ruby/*.*')."\n". 1205 | \ glob($MY_RUBY_HOME.'/lib/rubysite_ruby/*'),"\n"), ',') 1206 | endif 1207 | let g:ruby_fold = 1 1208 | let g:ruby_no_expensive = 1 1209 | 1210 | " ---------------------------------------------------------------------------- 1211 | " matchit.vim 1212 | " ---------------------------------------------------------------------------- 1213 | runtime macros/matchit.vim 1214 | 1215 | " ---------------------------------------------------------------------------- 1216 | " ack.vim 1217 | " ---------------------------------------------------------------------------- 1218 | if executable('ag') 1219 | let &grepprg = 'ag --nogroup --nocolor --column' 1220 | else 1221 | let &grepprg = 'grep -rn $* *' 1222 | endif 1223 | command! -nargs=1 -bar Grep execute 'silent! grep! ' | redraw! | copen 1224 | 1225 | " ---------------------------------------------------------------------------- 1226 | " vim-after-object 1227 | " ---------------------------------------------------------------------------- 1228 | autocmd VimEnter * silent! call after_object#enable('=', ':', '#', ' ', '|') 1229 | 1230 | " ---------------------------------------------------------------------------- 1231 | " | vim-easy-align 1232 | " ---------------------------------------------------------------------------- 1233 | let g:easy_align_delimiters = { 1234 | \ '>': { 'pattern': '>>\|=>\|>' }, 1235 | \ '\': { 'pattern': '\\' }, 1236 | \ '/': { 'pattern': '//\+\|/\*\|\*/', 'delimiter_align': 'l', 'ignore_groups': ['!Comment'] }, 1237 | \ ']': { 1238 | \ 'pattern': '\]\zs', 1239 | \ 'left_margin': 0, 1240 | \ 'right_margin': 1, 1241 | \ 'stick_to_left': 0 1242 | \ }, 1243 | \ ')': { 1244 | \ 'pattern': ')\zs', 1245 | \ 'left_margin': 0, 1246 | \ 'right_margin': 1, 1247 | \ 'stick_to_left': 0 1248 | \ }, 1249 | \ 'f': { 1250 | \ 'pattern': ' \(\S\+(\)\@=', 1251 | \ 'left_margin': 0, 1252 | \ 'right_margin': 0 1253 | \ }, 1254 | \ 'd': { 1255 | \ 'pattern': ' \ze\S\+\s*[;=]', 1256 | \ 'left_margin': 0, 1257 | \ 'right_margin': 0 1258 | \ } 1259 | \ } 1260 | 1261 | " Start interactive EasyAlign in visual mode 1262 | xmap ga (EasyAlign) 1263 | 1264 | " Start interactive EasyAlign with a Vim movement 1265 | nmap ga (EasyAlign) 1266 | nmap gaa ga_ 1267 | 1268 | " xmap (LiveEasyAlign) 1269 | " nmap a (LiveEasyAlign) 1270 | 1271 | " inoremap => =>mzvip:EasyAlign/=>/`z$a 1272 | 1273 | " ---------------------------------------------------------------------------- 1274 | " vim-github-dashboard 1275 | " ---------------------------------------------------------------------------- 1276 | let g:github_dashboard = { 'username': 'junegunn' } 1277 | 1278 | " ---------------------------------------------------------------------------- 1279 | " t | vim-tbone 1280 | " ---------------------------------------------------------------------------- 1281 | function! s:tmux_send(dest) range 1282 | call inputsave() 1283 | let dest = empty(a:dest) ? input('To which pane? ') : a:dest 1284 | call inputrestore() 1285 | silent call tbone#write_command(0, a:firstline, a:lastline, 1, dest) 1286 | endfunction 1287 | unlet! m 1288 | for m in ['n', 'x'] 1289 | let gv = m == 'x' ? 'gv' : '' 1290 | execute m."noremap tt :call tmux_send('')".gv 1291 | execute m."noremap th :call tmux_send('.left')".gv 1292 | execute m."noremap tj :call tmux_send('.bottom')".gv 1293 | execute m."noremap tk :call tmux_send('.top')".gv 1294 | execute m."noremap tl :call tmux_send('.right')".gv 1295 | execute m."noremap ty :call tmux_send('.top-left')".gv 1296 | execute m."noremap to :call tmux_send('.top-right')".gv 1297 | execute m."noremap tn :call tmux_send('.bottom-left')".gv 1298 | execute m."noremap t. :call tmux_send('.bottom-right')".gv 1299 | endfor 1300 | unlet m 1301 | 1302 | " ---------------------------------------------------------------------------- 1303 | " indentLine 1304 | " ---------------------------------------------------------------------------- 1305 | let g:indentLine_enabled = 0 1306 | 1307 | " ---------------------------------------------------------------------------- 1308 | " vim-signify 1309 | " ---------------------------------------------------------------------------- 1310 | let g:signify_vcs_list = ['git'] 1311 | let g:signify_skip_filetype = { 'journal': 1 } 1312 | 1313 | " ---------------------------------------------------------------------------- 1314 | " vim-slash 1315 | " ---------------------------------------------------------------------------- 1316 | function! s:blink(times, delay) 1317 | let s:blink = { 'ticks': 2 * a:times, 'delay': a:delay } 1318 | 1319 | function! s:blink.tick(_) 1320 | let self.ticks -= 1 1321 | let active = self == s:blink && self.ticks > 0 1322 | 1323 | if !self.clear() && active && &hlsearch 1324 | let [line, col] = [line('.'), col('.')] 1325 | let w:blink_id = matchadd('IncSearch', 1326 | \ printf('\%%%dl\%%>%dc\%%<%dc', line, max([0, col-2]), col+2)) 1327 | endif 1328 | if active 1329 | call timer_start(self.delay, self.tick) 1330 | endif 1331 | endfunction 1332 | 1333 | function! s:blink.clear() 1334 | if exists('w:blink_id') 1335 | call matchdelete(w:blink_id) 1336 | unlet w:blink_id 1337 | return 1 1338 | endif 1339 | endfunction 1340 | 1341 | call s:blink.clear() 1342 | call s:blink.tick(0) 1343 | return '' 1344 | endfunction 1345 | 1346 | if has('timers') 1347 | noremap (slash-after) blink(2, 50) 1348 | endif 1349 | 1350 | " ---------------------------------------------------------------------------- 1351 | " vim-emoji :dog: :cat: :rabbit:! 1352 | " ---------------------------------------------------------------------------- 1353 | function! s:replace_emojis() range 1354 | for lnum in range(a:firstline, a:lastline) 1355 | let line = getline(lnum) 1356 | let subs = substitute(line, 1357 | \ ':\([^:]\+\):', '\=emoji#for(submatch(1), submatch(0))', 'g') 1358 | if line != subs 1359 | call setline(lnum, subs) 1360 | endif 1361 | endfor 1362 | endfunction 1363 | command! -range EmojiReplace ,call s:replace_emojis() 1364 | 1365 | " ---------------------------------------------------------------------------- 1366 | " goyo.vim + limelight.vim 1367 | " ---------------------------------------------------------------------------- 1368 | let g:limelight_paragraph_span = 1 1369 | let g:limelight_priority = -1 1370 | 1371 | function! s:goyo_enter() 1372 | if has('gui_running') 1373 | set fullscreen 1374 | set background=light 1375 | set linespace=7 1376 | elseif exists('$TMUX') 1377 | silent !tmux set status off 1378 | endif 1379 | " hi NonText ctermfg=101 1380 | Limelight 1381 | endfunction 1382 | 1383 | function! s:goyo_leave() 1384 | if has('gui_running') 1385 | set nofullscreen 1386 | set background=dark 1387 | set linespace=0 1388 | elseif exists('$TMUX') 1389 | silent !tmux set status on 1390 | endif 1391 | Limelight! 1392 | endfunction 1393 | 1394 | autocmd! User GoyoEnter nested call goyo_enter() 1395 | autocmd! User GoyoLeave nested call goyo_leave() 1396 | 1397 | nnoremap G :Goyo 1398 | 1399 | " ---------------------------------------------------------------------------- 1400 | " gv.vim / gl.vim 1401 | " ---------------------------------------------------------------------------- 1402 | function! s:gv_expand() 1403 | let line = getline('.') 1404 | GV --name-status 1405 | call search('\V'.line, 'c') 1406 | normal! zz 1407 | endfunction 1408 | 1409 | autocmd! FileType GV nnoremap + :call gv_expand() 1410 | 1411 | " ---------------------------------------------------------------------------- 1412 | " undotree 1413 | " ---------------------------------------------------------------------------- 1414 | let g:undotree_WindowLayout = 2 1415 | nnoremap U :UndotreeToggle 1416 | 1417 | " ---------------------------------------------------------------------------- 1418 | " clojure 1419 | " ---------------------------------------------------------------------------- 1420 | augroup vimrc 1421 | autocmd FileType lisp,clojure,scheme RainbowParentheses 1422 | autocmd FileType lisp,clojure,scheme 1423 | \ nnoremap a[ vi[$:EasyAlign\ g/^\S/gv= 1424 | autocmd FileType lisp,clojure,scheme 1425 | \ nnoremap a{ vi{$:EasyAlign\ g/^\S/gv= 1426 | autocmd FileType lisp,clojure,scheme 1427 | \ nnoremap a( vi($:EasyAlign\ g/^\S/gv= 1428 | autocmd FileType lisp,clojure,scheme 1429 | \ nnoremap rq :silent updateRequire! 1430 | autocmd FileType lisp,clojure,scheme 1431 | \ nnoremap rt :silent updateRunTests 1432 | augroup END 1433 | 1434 | let g:clojure_maxlines = 60 1435 | 1436 | let g:clojure_fuzzy_indent_patterns = ['^with', '^def', '^let', '^match$'] 1437 | 1438 | " let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}']] 1439 | let g:paredit_smartjump = 1 1440 | 1441 | " ---------------------------------------------------------------------------- 1442 | " vim-markdown 1443 | " ---------------------------------------------------------------------------- 1444 | " let g:markdown_fenced_languages = ['sh', 'ruby', 'clojure', 'vim', 'java', 'gnuplot'] 1445 | 1446 | " ---------------------------------------------------------------------------- 1447 | " syntastic 1448 | " ---------------------------------------------------------------------------- 1449 | let g:syntastic_javascript_checkers = ['standard'] 1450 | let g:syntastic_always_populate_loc_list = 1 1451 | let g:syntastic_auto_loc_list = 1 1452 | 1453 | " ---------------------------------------------------------------------------- 1454 | " splitjoin 1455 | " ---------------------------------------------------------------------------- 1456 | let g:splitjoin_split_mapping = '' 1457 | let g:splitjoin_join_mapping = '' 1458 | nnoremap gss :SplitjoinSplit 1459 | nnoremap gsj :SplitjoinJoin 1460 | 1461 | " ---------------------------------------------------------------------------- 1462 | " vimawesome.com 1463 | " ---------------------------------------------------------------------------- 1464 | function! VimAwesomeComplete() abort 1465 | let prefix = matchstr(strpart(getline('.'), 0, col('.') - 1), '[.a-zA-Z0-9_/-]*$') 1466 | echohl WarningMsg 1467 | echo 'Downloading plugin list from VimAwesome' 1468 | echohl None 1469 | ruby << EOF 1470 | require 'json' 1471 | require 'open-uri' 1472 | 1473 | query = VIM::evaluate('prefix').gsub('/', '%20') 1474 | items = 1.upto(max_pages = 3).map do |page| 1475 | Thread.new do 1476 | url = "http://vimawesome.com/api/plugins?page=#{page}&query=#{query}" 1477 | data = open(url).read 1478 | json = JSON.parse(data, symbolize_names: true) 1479 | json[:plugins].map do |info| 1480 | pair = info.values_at :github_owner, :github_repo_name 1481 | next if pair.any? { |e| e.nil? || e.empty? } 1482 | {word: pair.join('/'), 1483 | menu: info[:category].to_s, 1484 | info: info.values_at(:short_desc, :author).compact.join($/)} 1485 | end.compact 1486 | end 1487 | end.each(&:join).map(&:value).inject(:+) 1488 | VIM::command("let cands = #{JSON.dump items}") 1489 | EOF 1490 | if !empty(cands) 1491 | inoremap 1492 | augroup _VimAwesomeComplete 1493 | autocmd! 1494 | autocmd CursorMovedI,InsertLeave * iunmap 1495 | \| autocmd! _VimAwesomeComplete 1496 | augroup END 1497 | 1498 | call complete(col('.') - strchars(prefix), cands) 1499 | endif 1500 | return '' 1501 | endfunction 1502 | 1503 | autocmd vimrc FileType vim inoremap =VimAwesomeComplete() 1504 | 1505 | " }}} 1506 | " ============================================================================ 1507 | " FZF {{{ 1508 | " ============================================================================ 1509 | 1510 | if has('nvim') 1511 | let $FZF_DEFAULT_OPTS .= ' --inline-info' 1512 | " let $NVIM_TUI_ENABLE_TRUE_COLOR = 1 1513 | endif 1514 | 1515 | " File preview using Highlight (http://www.andre-simon.de/doku/highlight/en/highlight.php) 1516 | let g:fzf_files_options = 1517 | \ '--preview "(highlight -O ansi {} || cat {}) 2> /dev/null | head -'.&lines.'"' 1518 | 1519 | " nnoremap :Files 1520 | nnoremap (expand('%') =~ 'NERD_tree' ? "\\" : '').":Files\" 1521 | nnoremap C :Colors 1522 | nnoremap :Buffers 1523 | nnoremap ag :Ag 1524 | nnoremap AG :Ag 1525 | xnoremap ag y:Ag " 1526 | nnoremap ` :Marks 1527 | " nnoremap q: :History: 1528 | " nnoremap q/ :History/ 1529 | 1530 | inoremap fzf#complete('tmuxwords.rb --all-but-current --scroll 500 --min 5') 1531 | imap (fzf-complete-word) 1532 | imap (fzf-complete-path) 1533 | imap (fzf-complete-file-ag) 1534 | imap (fzf-complete-line) 1535 | 1536 | nmap (fzf-maps-n) 1537 | xmap (fzf-maps-x) 1538 | omap (fzf-maps-o) 1539 | 1540 | " }}} 1541 | " ============================================================================ 1542 | " AUTOCMD {{{ 1543 | " ============================================================================ 1544 | 1545 | augroup vimrc 1546 | au BufWritePost vimrc,.vimrc nested if expand('%') !~ 'fugitive' | source % | endif 1547 | 1548 | " IndentLines 1549 | au FileType slim IndentLinesEnable 1550 | 1551 | " File types 1552 | au BufNewFile,BufRead *.icc set filetype=cpp 1553 | au BufNewFile,BufRead *.pde set filetype=java 1554 | au BufNewFile,BufRead *.coffee-processing set filetype=coffee 1555 | au BufNewFile,BufRead Dockerfile* set filetype=dockerfile 1556 | 1557 | " Included syntax 1558 | au FileType,ColorScheme * call file_type_handler() 1559 | 1560 | " Clojure 1561 | au FileType clojure xnoremap :Eval 1562 | au FileType clojure nmap cpp 1563 | 1564 | " Fugitive 1565 | au FileType gitcommit nnoremap cA :Gcommit --amend --date="$(date)" 1566 | 1567 | " http://vim.wikia.com/wiki/Highlight_unwanted_spaces 1568 | au BufNewFile,BufRead,InsertLeave * silent! match ExtraWhitespace /\s\+$/ 1569 | au InsertEnter * silent! match ExtraWhitespace /\s\+\%#\@ q :q 1595 | endif 1596 | endfunction 1597 | autocmd vimrc BufEnter *.txt call s:helptab() 1598 | 1599 | 1600 | " }}} 1601 | " ============================================================================ 1602 | " LOCAL VIMRC {{{ 1603 | " ============================================================================ 1604 | let s:local_vimrc = fnamemodify(resolve(expand('')), ':p:h').'/vimrc-extra' 1605 | if filereadable(s:local_vimrc) 1606 | execute 'source' s:local_vimrc 1607 | endif 1608 | 1609 | " }}} 1610 | " ============================================================================ 1611 | --------------------------------------------------------------------------------