forked from mhinz/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
821 lines (690 loc) · 25.6 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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
192
193
194
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
"
" ███████████████████████████
" ███████▀▀▀░░░░░░░▀▀▀███████
" ████▀░░░░░░░░░░░░░░░░░▀████
" ███│░░░░░░░░░░░░░░░░░░░│███
" ██▌│░░░░░░░░░░░░░░░░░░░│▐██
" ██░└┐░░░░░░░░░░░░░░░░░┌┘░██
" ██░░└┐░░░░░░░░░░░░░░░┌┘░░██
" ██░░┌┘▄▄▄▄▄░░░░░▄▄▄▄▄└┐░░██
" ██▌░│██████▌░░░▐██████│░▐██
" ███░│▐███▀▀░░▄░░▀▀███▌│░███
" ██▀─┘░░░░░░░▐█▌░░░░░░░└─▀██
" ██▄░░░▄▄▄▓░░▀█▀░░▓▄▄▄░░░▄██
" ████▄─┘██▌░░░░░░░▐██└─▄████
" █████░░▐█─┬┬┬┬┬┬┬─█▌░░█████
" ████▌░░░▀┬┼┼┼┼┼┼┼┬▀░░░▐████
" █████▄░░░└┴┴┴┴┴┴┴┘░░░▄█████
" ███████▄░░░░░░░░░░░▄███████
" ██████████▄▄▄▄▄▄▄██████████
" ███████████████████████████
"
" You are about to experience a potent dosage of Vim. Watch your steps.
"
" ╔══════════════════════════════════════════╗
" ║ ⎋ HERE BE VIMPIRES ⎋ ║
" ╚══════════════════════════════════════════╝
let s:is_win = has('win32')
let $v = $HOME.(s:is_win ? '\vimfiles' : '/.vim')
if s:is_win
set shell=cmd.exe
set shellcmdflag=/c
set encoding=utf-8
endif
" Plug {{{1
let s:bundle_dir = $v.'/bundle'
let g:plug_shallow = 0
let g:plug_window = 'enew'
let g:plug_pwindow = 'vertical rightbelow new'
call plug#begin(s:bundle_dir)
Plug 'jonathanfilip/vim-lucius'
Plug 'AndrewRadev/splitjoin.vim'
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
endif
Plug 'beloglazov/vim-online-thesaurus', { 'on': ['Thesaurus', 'OnlineThesaurusCurrentWord'] }
Plug 'chrisbra/unicode.vim', { 'on': ['<plug>(UnicodeComplete)', '<plug>(UnicodeGA)', 'UnicodeTable'] }
Plug 'easymotion/vim-easymotion', { 'on': '<plug>(easymotion-s2)' }
Plug 'godlygeek/csapprox', { 'for': 'fugitiveblame' }
if !has('win32')
Plug 'junegunn/fzf', { 'on': 'FZF', 'dir': '~/local/fzf', 'do': './install --bin' }
endif
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' }
Plug 'junegunn/gv.vim', { 'on': 'GV' }
Plug 'junegunn/vader.vim',
Plug 'junegunn/vim-easy-align', { 'on': '<plug>(LiveEasyAlign)' }
Plug 'justinmk/vim-dirvish'
Plug 'majutsushi/tagbar', { 'on': 'TagbarToggle' }
Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' }
Plug 'suan/vim-instant-markdown', { 'on': 'InstantMarkdownPreview' }
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-scriptease'
Plug 'tpope/vim-surround'
" Plug 'tweekmonster/helpful.vim', { 'for': 'help' }
Plug 'elixir-lang/vim-elixir', { 'for': 'elixir' }
Plug 'fatih/vim-go', { 'for': 'go' }
Plug 'tpope/vim-rails'
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }
Plug 'xolox/vim-lua-ftplugin', { 'for': 'lua' }
Plug 'xolox/vim-misc', { 'for': 'lua' }
Plug 'mhinz/vim-grepper'
Plug 'mhinz/vim-janah'
Plug 'mhinz/vim-randomtag', { 'on': 'Random' }
Plug 'mhinz/vim-rfc', { 'on': 'RFC' }
Plug 'mhinz/vim-sayonara', { 'on': 'Sayonara' }
Plug 'mhinz/vim-signify'
Plug 'mhinz/vim-startify'
" Testing phase.
" Plug 'mattn/emmet-vim', { 'for': 'html' }
" Plug 'tweekmonster/nvim-api-viewer'
" Plug 'tweekmonster/headlines.vim'
" Plug 'wellle/tmux-complete.vim'
call plug#end()
" }}}1
" Init {{{1
if has('nvim')
let g:python3_host_skip_check = 1
else
filetype plugin indent on
syntax on
packadd! matchit
endif
let mapleader = ';'
let g:vimsyn_folding = 'f'
let g:is_bash = 1
let g:lisp_rainbow = 1
let g:markdown_fenced_languages = ['vim']
let g:loaded_2html_plugin = 1
let g:loaded_getscriptPlugin = 1
let g:loaded_gzip = 1
let g:loaded_logipat = 1
" let g:loaded_matchparen = 1
let g:loaded_rrhelper = 1
let g:loaded_spellfile_plugin = 1
let g:loaded_tarPlugin = 1
let g:loaded_vimballPlugin = 1
let g:loaded_zipPlugin = 1
augroup vimrc
autocmd!
augroup END
" Option {{{1
" indent settings
set autoindent
set cinoptions =>4,l1,p0,)50,*50,t0
set expandtab
set smarttab
set softtabstop =4
set shiftwidth =4
set shiftround
" backup/swap/info/undo settings
set backup
set backupdir =$v/files/backup/
set backupext =-vimbackup
set backupskip =
set directory =$v/files/swap//
set undodir =$v/files/undo/
set undofile
set updatecount =100
if has('nvim')
set shada ='100
else
set viminfo ='100,n$v/files/info/viminfo
endif
" better navigation
set cursorline
set foldmethod =marker
set foldopen +=jump
set foldtext =mhi#foldy()
set hlsearch
set ignorecase
set incsearch
set mouse =
set scrolloff =4
set sidescroll =5
set smartcase
" misc settings
set autoread
set backspace =indent,eol,start
set clipboard =unnamed
set complete -=i
set completeopt +=noselect
set cpoptions -=e
set diffopt =filler,vertical,foldcolumn:0
set fileformats =unix,dos,mac
set hidden
set history =1000
set lazyredraw
set more
set mousemodel =popup
set noautowrite
set noautowriteall
set noequalalways
set noerrorbells
set nofsync
set nojoinspaces
set wrapscan
set nrformats =hex
set pastetoggle =<F5>
set norelativenumber
set report =0
set sessionoptions-=options
set showfulltag
set showtabline =1
set splitbelow
set splitright
set switchbuf =
set synmaxcol =200
set timeout
set timeoutlen =1000
set titlestring =VIM:\ %f
set ttimeout
set ttimeoutlen =10
set ttyfast
set virtualedit =onemore,block
set whichwrap =h,l
" wild stuff
set suffixes +=.a,.1,.class
set wildignore +=*.o,*.so,*.zip,*.png
set wildmenu
set wildmode =list:longest,full
set wildoptions =tagfile
" display settings
set display =lastline
set laststatus =2
set list
set modeline
set modelines =1
set nostartofline
set numberwidth =1
set ruler
set shortmess =aoOTI
set showcmd
set showmatch
set showmode
" spelling
set spellfile =~/.vim/spell/en.utf-8.add,~/.vim/spell/de.utf-8.add
set spelllang =en,de
" breaking
set wrap
set linebreak
set breakindent
set breakindentopt=min:40
"set highlight +=@:SpecialKey
set cpoptions =aABcefFqsZ
set formatoptions =tcrqnj
if has('multi_byte') && &encoding ==# 'utf-8'
let &listchars = 'tab:▸ ,extends:❯,precedes:❮,nbsp:±'
let &fillchars = 'diff:▚'
let &showbreak = '↪ '
highlight VertSplit ctermfg=242
augroup vimrc
autocmd InsertEnter * set listchars-=trail:⣿
autocmd InsertLeave * set listchars+=trail:⣿
augroup END
else
let &listchars = 'tab:> ,extends:>,precedes:<,nbsp:.'
let &fillchars = 'stlnc:#'
let &showbreak = '-> '
augroup vimrc
autocmd InsertEnter * set listchars-=trail:.
autocmd InsertLeave * set listchars+=trail:.
augroup END
endif
" Mapping {{{1
inoremap jf <esc>
inoremap <expr> <tab> mhi#tab_yeah("\<c-n>", "\<tab>")
inoremap <expr> <s-tab> mhi#tab_yeah("\<c-p>", "\<s-tab>")
nnoremap <c-i> <c-i>zvzz
nnoremap <c-o> <c-o>zvzz
inoremap <silent> <c-g><c-t> <c-r>=repeat(complete(col('.'), map(["%Y-%m-%d %H:%M:%S","%a, %d %b %Y %H:%M:%S %z","%Y %b %d","%d-%b-%y","%a %b %d %T %Z %Y"],'strftime(v:val)')+[localtime()]),0)<cr>
nnoremap \ ;
nnoremap <f12> :setlocal spell!<cr>
nnoremap <expr> n 'Nn'[v:searchforward].'zvzz'
nnoremap <expr> N 'nN'[v:searchforward].'zvzz'
nnoremap gg ggzv
nnoremap G Gzv
nnoremap [q :cprevious<cr>
nnoremap ]q :cnext<cr>
nnoremap [Q :cfirst<cr>
nnoremap ]Q :clast<cr>
nnoremap [l :lprevious<cr>
nnoremap ]l :lnext<cr>
nnoremap [L :lfirst<cr>
nnoremap ]L :llast<cr>
nnoremap [b :bprevious<cr>
nnoremap ]b :bnext<cr>
nnoremap [B :bfirst<cr>
nnoremap ]B :blast<cr>
nnoremap [t :tabprevious<cr>
nnoremap ]t :tabnext<cr>
nnoremap [T :tabfirst<cr>
nnoremap ]T :tablast<cr>
nnoremap [<space> :<c-u>put! =repeat(nr2char(10), v:count1)<cr>'[
nnoremap ]<space> :<c-u>put =repeat(nr2char(10), v:count1)<cr>
nnoremap [e :<c-u>execute 'move -1-'. v:count1<cr>
nnoremap ]e :<c-u>execute 'move +'. v:count1<cr>
" switch comma-separated arguments
nnoremap [w :normal F,h]w2w<cr>
nnoremap ]w :let s=&isk \| setl isk+=\",' \| exe "norm diwmmebgPdw'mP" \| let &isk=s<cr>
nnoremap } }zz
nnoremap { {zz
nnoremap ]] ]]zz
nnoremap [[ [[zz
nnoremap [] []zz
nnoremap ][ ][zz
nnoremap g; g;zvzz
nnoremap g, g,zvzz
nnoremap <left> <c-w>>
nnoremap <right> <c-w><
nnoremap <up> <c-w>-
nnoremap <down> <c-w>+
nnoremap <silent><a-h> :<c-u>call mhi#tmux_navigate('h')<cr>
nnoremap <silent><a-j> :<c-u>call mhi#tmux_navigate('j')<cr>
nnoremap <silent><a-k> :<c-u>call mhi#tmux_navigate('k')<cr>
nnoremap <silent><a-l> :<c-u>call mhi#tmux_navigate('l')<cr>
xnoremap < <gv
xnoremap > >gv
onoremap gv :<c-u>normal! gv<cr>
nnoremap Q gqap
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>si :echo mhi#syninfo()<cr>
nnoremap <leader>ss :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<cr>
nnoremap <leader>M :<c-u><c-r><c-r>='let @'. v:register .' = '. string(getreg(v:register))<cr><c-f><left>
nnoremap <leader>j <c-^>
nnoremap <leader>o :!echo `git url`/blob/`git rev-parse --abbrev-ref HEAD`/%\#L<C-R>=line('.')<cr> \| xargs open<cr><cr>
nnoremap <leader>v `[v`]
nnoremap <leader>w :update<cr>
nnoremap <leader>x :xit<cr>
nnoremap <leader>l :noh<cr>:diffupdate<cr>:syntax sync fromstart<cr><c-l>
nnoremap ' `
nnoremap ` '
nnoremap <bs> <c-t>
nnoremap <cr> :call mhi#jump()<cr>
cnoremap <c-n> <down>
cnoremap <c-p> <up>
cnoremap <leader>r $VIMRUNTIME/
cnoremap <leader>ft ~/.vim/after/ftplugin/
xnoremap * :<c-u>call mhi#search()<cr>//<cr>
xnoremap # :<c-u>call mhi#search()<cr>??<cr>
xnoremap <leader>* :<c-u>silent! execute mhi#search_all()<cr>
if has('nvim')
nnoremap <leader>t :vsplit +terminal<cr>
tnoremap <esc> <c-\><c-n>
tnoremap <silent><a-h> <c-\><c-n>:<c-u>call mhi#tmux_navigate('h')<cr>
tnoremap <silent><a-j> <c-\><c-n>:<c-u>call mhi#tmux_navigate('j')<cr>
tnoremap <silent><a-k> <c-\><c-n>:<c-u>call mhi#tmux_navigate('k')<cr>
tnoremap <silent><a-l> <c-\><c-n>:<c-u>call mhi#tmux_navigate('l')<cr>
endif
if has('nvim')
let $NVIM_TUI_ENABLE_CURSOR_SHAPE = 1
elseif empty($TMUX)
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
else
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
endif
" Autocmd {{{1
augroup vimrc
if has('nvim')
autocmd BufEnter term://* startinsert
endif
au BufEnter * call mhi#cd()
au BufEnter * if isdirectory(expand('<afile>')) | set nobuflisted | endif
au BufRead,BufNewFile *.[sS] let b:asmsyntax = 'gas'
au BufRead,BufNewFile *.adoc setfiletype asciidoc
au BufRead,BufNewFile /data/repo/neo{mutt,vim}/* setlocal et sts=2 sw=2 cino=>2,l1,p0,)50,*50,t0
au BufRead,BufNewFile /data/repo/vim/* setlocal noet
au BufRead,BufNewFile /data/repo/vim/src/*.[ch] setlocal sw=4 sts=4
" au BufRead,BufNewFile Makefile.*,local.mk setfiletype make | setl noet
au BufWritePost ~/.Xdefaults redraw | echo system('xrdb ' . expand('<amatch>'))
au CompleteDone * pclose
au BufReadPost * if &bin | silent! exe '%!xxd' | setlocal filetype=xxd | endif
au BufWritePre * if &bin | silent! exe '%!xxd -r' | endif
au BufWritePost * if &bin | silent! exe '%!xxd' | setlocal nomodified | endif
au WinEnter * set cursorline
au WinLeave * set nocursorline
au InsertEnter * set nocursorline
au InsertLeave * set cursorline
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe 'normal! g`"zvzz' | endif
au BufReadPost * if getline(1) =~ '^#!' | let b:start = '-wait=always '.getline(1)[2:].' %' | endif
augroup END
" Command {{{1
command! DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis | wincmd p | diffthis
command! -bar -nargs=* -complete=help H helpgrep <args>
" command! -bar Scriptnames call mhi#scratch('scriptnames') | sil keepp g/^$/d
command! -bar -nargs=1 -complete=command Scratch call mhi#scratch(<f-args>)
command! -bar CleanSpell runtime! spell/cleanadd.vim
" Color {{{1
function! s:colors_default() abort
highlight link User1 StatusLine " master branch
highlight link User2 StatusLine " other branch
highlight link User3 StatusLine " separators
highlight link User4 StatusLine " filename at beginning
highlight link User5 StatusLine " ~changes
highlight link SignifySignAdd DiffAdd
highlight link SignifySignDelete DiffDelete
highlight link SignifySignChange DiffChange
endfunction
function! s:colors_janah() abort
highlight Normal ctermbg=236
highlight User1 ctermfg=192 ctermbg=237 cterm=NONE
highlight User2 ctermfg=167 ctermbg=237 cterm=NONE
highlight User3 ctermfg=245 ctermbg=237 cterm=NONE
highlight User4 ctermfg=215 ctermbg=237 cterm=NONE
highlight User5 ctermfg=111 ctermbg=237 cterm=NONE
endfunction
function! s:colors_lucius() abort
let [fg, bg] = [synIDattr(hlID('StatusLine'), 'fg'),
\ synIDattr(hlID('StatusLine'), 'bg')]
if &background ==# 'light'
execute 'highlight User1 ctermfg=23 ctermbg=192 cterm=NONE'
execute 'highlight User2 ctermfg=20 ctermbg=195 cterm=NONE'
execute 'highlight User3 ctermfg='. (bg+5) 'ctermbg='. bg 'cterm=NONE'
endif
endfunction
augroup vimrc
autocmd ColorScheme * call s:colors_default()
autocmd ColorScheme janah call s:colors_janah()
autocmd ColorScheme lucius call s:colors_lucius()
augroup END
if has('gui_running')
set background=light
for scheme in ['gruvbox', 'railscasts']
try
execute 'colorscheme' scheme
break
catch
endtry
endfor
set gcr =a:blinkoff0
set mousehide
set guioptions =a
if has('gui_mac')
set nomacmeta
endif
" let &guifont = 'Bitstream Vera Sans Mono 9'
" let &guifont = 'DejaVu Sans Mono 9'
" let &guifont = 'Droid Sans Mono 9'
let &guifont = s:is_win ? 'Source_Code_Pro:h10' : 'foo Mono:h16'
command! Bigger :let &guifont = substitute(&guifont, '\d\+$', '\=submatch(0)+1', '')
command! Smaller :let &guifont = substitute(&guifont, '\d\+$', '\=submatch(0)-1', '')
else
if !exists('$ITERM_PROFILE') || $ITERM_PROFILE == 'Light'
set background=light
colorscheme lucius
else
set background=dark
colorscheme janah
endif
endif
" Statusline {{{1
command! -bar ToggleStatusline let b:stl_location = !get(b:, 'stl_location', 1)
command! -bar ToggleHighlight let b:stl_highlight = !get(b:, 'stl_highlight')
nnoremap <silent><f10> :ToggleStatusline<cr>
nnoremap <silent><f11> :ToggleHighlight<cr>
set statusline=%!SetStatusline()
function! SetStatusline()
let stl = ' %4*%<%f%*'
if exists('b:git_dir')
let stl .= '%3*:%*'
let branch = fugitive#head(8)
let stl .= (branch == 'master') ? '%1*master%*' : '%2*'. branch .'%*'
let stl .= mhi#sy_stats_wrapper()
endif
let stl .=
\ '%m%r%h%w'
\ . '%= '
\ . '%#ErrorMsg#%{&paste ? " paste " : ""}%*'
\ . '%#WarningMsg#%{&ff != "unix" ? " ".&ff." ":""}%* '
\ . '%#warningmsg#%{&fenc != "utf-8" && &fenc != "" ? " ".&fenc." " :""}%* '
if get(b:, 'stl_highlight')
let id = synID(line('.'), col('.'), 1)
let stl .=
\ '%#WarningMsg#['
\ . '%{synIDattr('.id.',"name")} as '
\ . '%{synIDattr(synIDtrans('.id.'),"name")}'
\ . ']%* '
endif
if get(b:, 'stl_location', 1)
let stl .=
\ '%3*[%*%v%3*,%*%l%3*/%*%L%3*]%* '
\ . '%p%3*%%%* '
endif
return stl
endfunction
" }}}1
" Plugin {{{1
" Plugin: deoplete {{{2
let g:deoplete#enable_at_startup = 0
let g:deoplete#enable_smart_case = 1
" Plugin: fzf {{{2
set runtimepath+=~/local/fzf
nnoremap <leader><leader> :Buffers<cr>
nnoremap <leader>C :Colorschemes<cr>
nnoremap <leader>P :Plugins<cr>
nnoremap <leader>S :Scriptnames<cr>
nnoremap <leader>f :FZF<cr>
function! s:buflist()
return map(filter(range(1, bufnr('$')),
\ 'bufloaded(v:val)'), 'printf("%s: %s", v:val, bufname(v:val))')
endfunction
function! s:bufopen(lines)
if len(a:lines) < 2 | return | endif
let cmd = get({
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit',
\ 'ctrl-t': 'tabedit'
\ }, a:lines[0], 'edit')
execute cmd '+b'.matchstr(a:lines[1], '^\d\+')
endfunction
function! s:plugopen(entry)
execute 'Dirvish' expand(s:bundle_dir) .'/'. a:entry
execute 'lcd' expand('%')
endfunction
command! Buffers let bl = reverse(s:buflist()) | call fzf#run({
\ 'source': bl,
\ 'sink*': function('<sid>bufopen'),
\ 'options': '+m --expect=ctrl-s,ctrl-v,ctrl-t',
\ 'down': len(bl) + 2,
\ }) | unlet bl
command! Plugins call fzf#run({
\ 'source': reverse(sort(map(globpath(s:bundle_dir, '*', 0, 1), 'fnamemodify(v:val, ":t")'))),
\ 'sink': function('<sid>plugopen'),
\ 'options': '+m',
\ 'left': 30
\ })
command! Colorschemes call fzf#run({
\ 'source': reverse(sort(map(globpath(&rtp, 'colors/*.vim', 0, 1), 'fnamemodify(v:val, ":t:r")'))),
\ 'sink': 'colorscheme',
\ 'options': '+m',
\ 'left': 30
\ })
" Plugin: netrw {{{2
" let g:loaded_netrwPlugin = 1
let g:netrw_banner = 0
let g:netrw_bufsettings = 'relativenumber'
let g:netrw_keepdir = 0
let g:netrw_liststyle = 1
let g:netrw_sort_options = 'i'
" Plugin: surround {{{2
let g:surround_indent = 1
let g:surround_{char2nr('k')} = "<kbd>\r</kbd>"
" Plugin: tagbar {{{2
nnoremap <f2> :TagbarToggle<cr>
let g:tagbar_width = 40
let g:tagbar_autoclose = 0
let g:tagbar_autofocus = 1
let g:tagbar_compact = 1
" Plugin: undotree {{{2
nnoremap <f3> :UndotreeToggle<cr>
" Plugin: vim-dirvish {{{2
autocmd FileType dirvish nmap <buffer> <c-o> -
nnoremap <f1> :vsplit +Dirvish<cr><c-w>H<c-w>40<bar>
" Plugin: vim-dispatch {{{2
nnoremap <leader>dd :Dispatch<cr>
nnoremap <leader>dm :Make<cr>
nnoremap <leader>ds :Start<cr>
nnoremap <leader>dc :Copen<cr>
" Plugin: vim-easy-align {{{2
xmap <cr> <plug>(LiveEasyAlign)
" Plugin: vim-easymotion {{{2
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_do_shade = 1
let g:EasyMotion_inc_highlight = 0
let g:EasyMotion_landing_highlight = 0
let g:EasyMotion_off_screen_search = 0
let g:EasyMotion_smartcase = 0
let g:EasyMotion_startofline = 0
let g:EasyMotion_use_smartsign_us = 1
let g:EasyMotion_use_upper = 0
let g:EasyMotion_skipfoldedline = 0
map <silent><space> <plug>(easymotion-s2)
" Plugin: vim-grepper {{{2
nnoremap <leader>g :Grepper -tool git<cr>
nnoremap <leader>G :Grepper -tool ag<cr>
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
" Plugin: vim-online-thesaurus {{{2
nnoremap <leader>k :OnlineThesaurusCurrentWord<cr>
nnoremap <leader>K :Thesaurus<space>
" Plugin: vim-sayonara {{{2
nnoremap <silent><leader>q :Sayonara<cr>
nnoremap <silent><leader>Q :Sayonara!<cr>
let g:sayonara_confirm_quit = 0
" Plugin: vim-startify {{{2
nnoremap <leader>st :Startify<cr>
let g:startify_list_order = [
\ [' MRU '. getcwd()], 'dir',
\ [' MRU'], 'files',
\ [' Sessions'], 'sessions',
\ [' Bookmarks'], 'bookmarks',
\ [' Commands'], 'commands',
\ ]
let g:startify_skiplist = [
\ 'COMMIT_EDITMSG',
\ 'bundle/.*/doc',
\ '/data/repo/neovim/runtime/doc',
\ '/Users/mhi/local/vim/share/vim/vim74/doc',
\ ]
let g:startify_bookmarks = [
\ { 'c': '~/.vim/vimrc' },
\ '~/.zsh/.zshrc',
\ ]
let g:startify_transformations = [
\ ['.*vimrc$', 'vimrc'],
\ ]
let g:startify_change_to_dir = 0
let g:startify_change_to_vcs_root = 0
let g:startify_enable_special = 0
let g:startify_files_number = 8
let g:startify_session_autoload = 0
let g:startify_session_delete_buffers = 1
let g:startify_session_persistence = 0
let g:startify_update_oldfiles = 1
let g:startify_use_env = 1
" Filetype {{{1
augroup vimrc
" Filetype: C {{{2
autocmd BufLeave *.{c,cpp} mark C
autocmd BufLeave *.h mark H
" Filetype: Erlang {{{2
autocmd FileType erlang setl com-=:%
" Filetype: Go {{{2
let g:go_def_mode = 'godef'
let g:go_fmt_command = 'goimports'
autocmd FileType go
\ setlocal noet sts& sw& com-=:// isk-=. mp=go\ install
\| let [b:dispatch, b:start] = [':GoBuild', ':GoRun']
\| nnoremap <buffer> <cr> :GoDef<cr>
\| nnoremap <buffer> <leader>b :GoBuild<cr>
\| nnoremap <buffer> <leader>c :GoCoverageToggle<cr>
\| nnoremap <buffer> <leader>i :GoInfo<cr>
\| nnoremap <buffer> <leader>r :GoReferrers<cr>
\| nnoremap <buffer> <leader>t :GoTest<cr>
\| command! -buffer -bang A call go#alternate#Switch(<bang>0, 'edit')
\| command! -buffer -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
\| command! -buffer -bang AS call go#alternate#Switch(<bang>0, 'split')
\| command! -buffer -bang AT call go#alternate#Switch(<bang>0, 'tabe')
" Filetype: Help {{{2
autocmd FileType help
\ setl noet
\| let b:helpful = 1
\| execute 'silent wincmd' 'TL'[winnr('$') == 2]
" Filetype: HTML {{{2
autocmd FileType html setl et sts=2 sw=2
" Filetype: Lua {{{2
let g:lua_complete_omni = 1 " vim-lua-ftplugin
autocmd FileType lua
\ setl com-=:# sts=2 sw=2
\| let [b:dispatch, b:start] = ['luac -p %', '-wait=always luajit %']
" Filetype: Perl {{{2
let perl_include_pod = 1
autocmd FileType perl
\ setlocal com-=:# kp=perldoc\ -f
\| compiler perl
" Filetype: Python {{{2
let python_highlight_all = 1
autocmd FileType python
\ setlocal kp=pydoc mp=./%
\| compiler pyunit
\| call deoplete#enable()
" Filetype: Ruby {{{2
let g:ruby_operators = 1
let g:ruby_space_errors = 1
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
autocmd FileType ruby setl com-=:# sts=2 sw=2
\| call deoplete#enable()
" Filetype: Sh, Zsh {{{2
autocmd FileType zsh,sh setl com-=:# mp=shellcheck\ -f\ gcc\ %
" Filetype: Text, Mail, Markdown {{{2
let g:instant_markdown_autostart = 0
let g:instant_markdown_slow = 1
autocmd FileType mail setl tw=72 wrap lbr
autocmd FileType markdown setl tw=80 mp=gomali\ %
autocmd FileType text setl tw=80 fo+=t
" Filetype: VCS {{{2
autocmd FileType git,gitcommit
\ setl tw=80 fo+=t
\| nnoremap <buffer> gh :call mhi#github_open_issue()<cr>
" fugitive
autocmd BufReadPost fugitive:// setlocal bufhidden=delete
autocmd User fugitive
\ if fugitive#buffer().type() =~# '\v^%(tree|blob)$'
\| nnoremap <buffer> .. :edit %:h<cr>
\| endif
" gv
autocmd FileType GV
\ set foldlevel=1
\| nnoremap <buffer> q :qa<cr>
\| nmap <buffer> j j<cr>
\| nmap <buffer> k k<cr>
highlight link diffAdded DiffAdd
highlight link diffRemoved DiffDelete
highlight link diffFile Directory
highlight link diffLine Comment
highlight link diffIndexLine Comment
highlight link diffSubname Comment
" signify
let g:signify_vcs_list = ['git', 'hg']
omap ic <plug>(signify-motion-inner-pending)
xmap ic <plug>(signify-motion-inner-visual)
omap ac <plug>(signify-motion-outer-pending)
xmap ac <plug>(signify-motion-outer-visual)
" Filetype: Vim {{{2
autocmd FileType vim
\ setl sts=2 sw=2 isk-=#
\| let [b:dispatch, b:start] = [':Runtime', ':Runtime|PP']
\| nnoremap <buffer><silent> <cr> :call mhi#lookup()<cr>zvzz:call mhi#pulse()<cr>
" }}}2
augroup END
" }}}1
" vim: sw=2 sts=2 tw=0 fdm=marker