-
Notifications
You must be signed in to change notification settings - Fork 4
/
vimrc
1098 lines (983 loc) · 34.9 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
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" General {{{1
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,sjis,euc-jp,cp932,euc-cn,cp936,euc-tw,big5
set termencoding=utf-8
set fileformats=unix,dos
set mouse=a " 开启鼠标支持
set expandtab " TAB is soft
set tabstop=4 " TAB 的宽度
set shiftwidth=4 " 缩进的宽度
set softtabstop=4
set clipboard=unnamedplus " 使用系统剪贴板
set backspace=indent,eol,start " 退格
set foldmethod=marker
set ignorecase " 搜索忽略大小写
set autoindent " 自动缩进
set cindent
set number " 显示行数
set completeopt=preview,menu " 显示补全预览菜单
set smartcase
set hidden " 用隐藏代替关闭从而保留 undo 列表等私有信息
set nocompatible
set nohls " 不高亮匹配关键字
set noincsearch " 非渐进搜索
set nowrap " 不自动折行
set updatetime=1000
set matchpairs=(:),{:} " 避免TabBar的方括号被高亮
set showcmd " 右下方显示按键序列
set winaltkeys=no
set cinoptions=:0
set timeoutlen=1000
set ttimeoutlen=50
set timeout
"set ttimeout
set autoread
set autowrite
set wildignore=*/*.o,*/*.so,*/*.obj,*/*.orig,*/.git/*,*/.hg/*,*/.svn/*
set wildmenu
set wildmode=list:longest,full
set viminfo+=! " 为了 mark 能保存高亮信息
set listchars=tab:.\ ,trail:\ ,
set noswapfile " 内存大、禁用swapfile
set history=200 " 命令行历史记录
set laststatus=2 " 始终显示状态栏
set noshowmode " 忽略内置的模式显示功能
set undolevels=500
set diffopt=filler,iwhite
set rtp+=/usr/bin/fzf
set guicursor=a:blinkon100 " 让光标抖起来
" set inccommand=split " 好像是 NeoVim 特有的
set shortmess-=F " https://github.com/natebosch/vim-lsc
if has("gui_running")
set guioptions-=m
set guioptions-=T
endif
if has("win32") || has("win64")
au GUIEnter * simalt ~x
language messages zh_CN.UTF-8
set grepprg=findstr\ /n
" set guifont=Envy_Code_R_For_Powerline:h10
" set guifontwide=NSimsun:h10.5
set shell=cmd.exe
set directory=$TMP
else
" set guifont=Envy\ Code\ R\ For\ Powerline\ 10
" set guifontwide=WenQuanYi\ Micro\ Hei\ 10
set makeprg=make\ -j2
set grepprg=ag\ --vimgrep\ $*
set grepformat=%f:%l:%c:%m
set shell=bash\ -x\ -c
set directory=/tmp
endif
if &term =~ ".*256color" || &term == "nvim"
color light256
" 区别普通/插入模式的光标颜色
" # PowerLine 已实现
" let &t_SI = "\033]12;black\007"
" let &t_EI = "\033]12;red\007"
" autocmd VimLeave * :!echo -ne "\033]12;black\007"
else
color delek
endif
" 用全角显示『○』、『△』、『□』这样的特殊字符
" East Asian Ambiguous Width:
" http://www.unicode.org/reports/tr11/
" http://lists.debian.or.jp/debian-devel/200703/msg00038.html
" http://sakurapup.browserloadofcoolness.com/viewtopic.php?f=13&t=2027
" http://du1abadd.org/debian/UTF-8-EAW-FULLWIDTH.gz
" https://github.com/hamano/locale-eaw/blob/master/README.md
if exists('&ambw')
set ambiwidth=double
endif
" 不用设置为double也能全角显示,vim@rxvt-unicode
let mapleader=','
let maplocalleader='\'
let html_dynamic_folds=1
let c_space_errors=1
let sh_minlines = 100
syn enable " 语法高亮
filetype plugin indent on
if v:version >= 703
set undodir=~/.vimundo/
set undofile
endif
" }}}
" Function {{{1
" 中英文之间自动插入空格
" ref: https://github.com/yuweijun/vim-space
function! SpaceAddBetweenEnglishChinese() range
for linenum in range(line("'<"), line("'>"))
let oldline = getline(linenum)
let newline = substitute(oldline, '\([\u4e00-\u9fa5]\)\(\w\)', '\1 \2', 'g')
let newline = substitute(newline, '\(\w\)\([\u4e00-\u9fa5]\)', '\1 \2', 'g')
call setline(linenum, newline)
endfor
endfunction
" 打开/关闭/切换 Quickfix 窗口
" @forced:
" 1 always show qfix
" 0 always hide qfix
" -1 switch show/hide
" function! G_QFixToggle(forced)
" if bufname('%') == "[Command Line]"
" " leave the command-line window: <C-\><C-N> is better then :quit
" exec "normal \<C-\>\<C-N>"
" elseif a:forced == 1
" UniteResume
" elseif a:forced == 0
" UniteClose default
" else
" Unite -toggle quickfix
" endif
" endfunction
" P键 预览
" function! G_GoodP()
" if &buftype == "quickfix"
" exec "normal \<Return>"
" normal zz
" wincmd w
" else
" unmap p
" normal p
" nnor <silent> <unique> p :call G_GoodP()<CR>
" endif
" endfunction
" Space键 翻页/打开折叠
function! G_GoodSpace()
if foldclosed('.') != -1
normal zO
else
exec "normal \<C-D>"
endif
endfunction
" 0键在行首与行顶间交替
function! G_Good0()
if ! exists("b:is_pressed0")
normal ^
let b:is_pressed0 = 1
else
normal g0
unlet b:is_pressed0
endif
endfunction
" 跳转至文件编辑窗口
" 参照 tabbar.vim 插件的 <SID>Bf_CrSel() 函数
function! G_GotoEditor()
if &buftype != ''
wincmd w
if &buftype != ''
wincmd w
if &buftype != ''
wincmd w
if &buftype != ''
wincmd W
wincmd W
wincmd W
endif
endif
endif
endif
endfunction
" 关闭当前 Buffer
function! G_CloseBuffer()
call G_GotoEditor()
let name = fnamemodify(expand('%'), ':t')
"if bufname('%') != '-MiniBufExplorer-'
" wincmd k
" if bufname('%') != '-MiniBufExplorer-'
" wincmd k
" if bufname('%') != '-MiniBufExplorer-'
" wincmd k
" if bufname('%') != '-MiniBufExplorer-'
" return
" endif
" endif
" endif
"endif
exec "normal /" . name . "\<CR>"
normal d
call G_GotoEditor()
endfunction
" vim macro to jump to devhelp topics.
" ref: http://blog.csdn.net/ThinkHY/archive/2008/12/30/3655697.aspx
function! DevHelpCurrentWord()
let word = expand("<cword>")
exe "!devhelp -s " . word . " &"
endfunction
" jekyll blog
function! G_Jekyll()
endfunction
" Ranger file manager
" function Ranger()
" silent !ranger --choosefile=/tmp/chosen
" if filereadable('/tmp/chosen')
" exec 'edit ' . system('cat /tmp/chosen')
" call system('rm /tmp/chosen')
" endif
" redraw!
" endfunction
" }}}
" Key maps {{{1
" Mouse Bindings {{{2
"map <silent> <unique> <2-LeftMouse> :call G_GotoEditor()<CR><C-O>zz
"map <silent> <unique> <2-RightMouse> :call G_GotoEditor()<CR><C-I>g`"zz
map <silent> <unique> <MiddleMouse> <C-]>zz
map <silent> <unique> <LeftMouse><RightMouse> ZQ
" Function Key {{{2
nmap <silent> <unique> <F1> :let &colorcolumn=80-&colorcolumn<CR>:set list!<CR>
imap <silent> <unique> <F1> <ESC>:let &colorcolumn=80-&colorcolumn<CR>:set list!<CR>a
nmap <silent> <unique> <F2> :set nowrap!<CR>:set nowrap?<CR>
imap <silent> <unique> <F2> <ESC>:set nowrap!<CR>:set nowrap?<CR>a
nmap <silent> <unique> <F3> :set nohls!<CR>:set nohls?<CR>
imap <silent> <unique> <F3> <ESC>:set nohls!<CR>:set nohls?<CR>a
nmap <silent> <unique> <F4> :set nopaste!<CR>:set nopaste?<CR>
imap <silent> <unique> <F4> <ESC>:set nopaste!<CR>:set nopaste?<CR>a
set pastetoggle=<F4>
if has('nvim')
nmap <unique> <F5> :terminal git difftool --tool=nvimdiff -y HEAD -- %<LEFT><LEFT><LEFT><LEFT><LEFT>
else
nmap <unique> <F5> :!git difftool --tool=vimdiff -y HEAD -- %<LEFT><LEFT><LEFT><LEFT><LEFT>
endif
nmap <silent> <unique> <F6> :<CR>
nmap <unique> <F7> :set formatoptions+=12mnM<CR>
nmap <silent> <unique> <F8> :make!<CR>
nmap <silent> <unique> <F9> :History<CR>
nmap <silent> <unique> <F10> :<CR>
nmap <silent> <unique> <F11> <ESC>:tselect <C-R>=expand('<cword>')<CR><CR>
nmap <silent> <unique> <F12> <C-]>zz
" Single Key {{{2
nmap <silent> <unique> <Backspace> :call G_GotoEditor()<CR><C-O>zz
nmap <silent> <unique> \ :call G_GotoEditor()<CR><C-I>zz
nmap <silent> <unique> <Space> :call G_GoodSpace()<CR>
nmap <silent> <unique> - <C-U>
nmap <silent> <unique> ; zz
nmap <silent> <unique> ' $
vmap <silent> <unique> + :VisSum<CR>
nmap <silent> <unique> 0 :call G_Good0()<CR>
vmap <silent> <unique> ; :call SpaceAddBetweenEnglishChinese()<CR>
"nmap <silent> <unique> * :<C-u>DeniteCursorWord -buffer-name=search line<CR>
" Shift+ {{{2
nnor <silent> <unique> H :call DevHelpCurrentWord()<CR>
nmap <silent> W :exec "%s /\\s\\+$//ge"<CR>:w<CR>
nmap <silent> <unique> Q :qa!<CR>
nmap <unique> <S-F7> :set formatoptions-=2mn<CR>
nmap <unique> <S-F8> :SyntasticCheck<CR>
nmap <silent> <unique> <S-F9> q:<UP>
nmap <silent> <unique> <S-F11> <ESC>:ptselect <C-R>=expand('<cword>')<CR><CR>
imap <silent> <unique> <S-Space> <C-V><Space>
" Ctrl+ {{{2
nmap <silent> <unique> <C-Q> :q!<CR>
nmap <silent> <unique> <C-J> :call EasyMotion#JK(0, 0)<CR>
nmap <silent> <unique> <C-K> :call EasyMotion#JK(0, 1)<CR>
nmap <silent> <unique> <C-N> :call G_GotoEditor()<CR><Plug>AirlineSelectNextTab<CR>
nmap <silent> <unique> <C-P> :call G_GotoEditor()<CR><Plug>AirlineSelectPrevTab<CR>
imap <silent> <unique> <C-Q> <ESC><ESC>;
imap <silent> <unique> <C-E> <C-O>$
imap <silent> <unique> <C-A> <C-O>^
imap <silent> <unique> <C-D> <C-O>x
imap <silent> <unique> <C-K> <C-O>d$
imap <silent> <unique> <C-Y> <C-O>u<C-O>$
nmap <silent> <unique> <C-F8> :make! clean<CR>
nmap <silent> <unique> <C-F12> :!mkdir -p ~/__html__/%:h<CR>:TOhtml<CR>:w! ~/__html__/%<CR>:bw!<CR><C-L>
" Alt+ {{{2
if has("gui_running")
nmap <silent> <unique> <A-h> <C-W>h
nmap <silent> <unique> <A-j> <C-W>j
nmap <silent> <unique> <A-k> <C-W>k
nmap <silent> <unique> <A-l> <C-W>l
imap <silent> <unique> <A-b> <C-O>b
imap <silent> <unique> <A-f> <C-O>w
imap <silent> <unique> <A-d> <C-O>dw
elseif &term == "nvim"
nmap <silent> <unique> <M-Backspace> :call G_GotoEditor()<CR>:pop<CR>zz
nmap <silent> <unique> <M-\> :call G_GotoEditor()<CR>:tag<CR>zz
nmap <silent> <unique> <M-`> :call G_GotoEditor()<CR>:e #<CR>
imap <silent> <unique> <M-`> <ESC>:call G_GotoEditor()<CR>:e #<CR>a
nmap <silent> <unique> <M-h> <C-W>h
nmap <silent> <unique> <M-j> <C-W>j
nmap <silent> <unique> <M-k> <C-W>k
nmap <silent> <unique> <M-l> <C-W>l
imap <silent> <unique> <M-b> <C-O>b
imap <silent> <unique> <M-f> <C-O>w
imap <silent> <unique> <M-d> <C-O>dw
imap <silent> <unique> <M-l> <Right>
imap <silent> <unique> <M-h> <Left>
imap <silent> <unique> <M-j> <Down>
imap <silent> <unique> <M-k> <UP>
imap <silent> <unique> <M-0> <Home>
imap <silent> <unique> <M-'> <End>
else
nmap <silent> <unique> <Esc><Backspace> :call G_GotoEditor()<CR>:pop<CR>zz
nmap <silent> <unique> <Esc>\ :call G_GotoEditor()<CR>:tag<CR>zz
nmap <silent> <unique> <Esc>` :call G_GotoEditor()<CR>:e #<CR>
imap <silent> <unique> <Esc>` <ESC>:call G_GotoEditor()<CR>:e #<CR>a
nmap <silent> <unique> <Esc>h <C-W>h
nmap <silent> <unique> <Esc>j <C-W>j
nmap <silent> <unique> <Esc>k <C-W>k
nmap <silent> <unique> <Esc>l <C-W>l
imap <silent> <unique> <Esc>b <C-O>b
imap <silent> <unique> <Esc>f <C-O>w
imap <silent> <unique> <Esc>d <C-O>dw
endif
" Leader+ , Leader char is ',' {{{2
nmap <silent> <unique> <Leader>1 :.diffget BASE<CR>:diffupdate<CR>
nmap <silent> <unique> <Leader>2 :.diffget LOCAL<CR>:diffupdate<CR>
nmap <silent> <unique> <Leader>3 :.diffget REMOTE<CR>:diffupdate<CR>
nmap <silent> <unique> <Leader>d :call G_CloseBuffer()<CR>
nmap <silent> <unique> <Leader>l :call <SID>ShowTagbar()<CR>
nmap <silent> <unique> <Leader>s :call <SID>CscopeFind('s', 'y')<CR>
nmap <silent> <unique> <Leader>c :call <SID>CscopeFind('c', 'y')<CR>
nmap <silent> <unique> <Leader>S :call <SID>CscopeFind('s', 'n')<CR>
nmap <silent> <unique> <Leader>C :call <SID>CscopeFind('c', 'n')<CR>
nmap <silent> <unique> <Leader>a :GundoToggle<CR>
vmap <silent> <unique> <Leader>a <Plug>VimSumVisual
" Colon+, Colon char is ':' {{{2
command W :w !sudo tee %
command E :call Ranger()<CR>
command H :History:
command A :Ag
command F :Files
command PP :!paps --landscape --font='monospace 8' --header --columns=2 % | ps2pdf - - | zathura -
command PPP :!paps --landscape --font='monospace 8' --header --columns=2 % | lp -o landscape -o sites=two-sided-long-edge -
" }}}1
" Autocmd {{{1
if has("autocmd")
function! <SID>AC_ResetCursorPosition()
if line("'\"") > 1 && line("'\"") <= line("$")
exec "normal g`\"zz"
endif
endfunction
function! <SID>AC_HighlightDirtySpace()
highlight link wtfSpace SpellRare
match wtfSpace /[ ]/
endfunction
function! <SID>AC_ChmodExecutable()
if getline(1) =~ "^#!" && getline(1) =~ "/bin/"
silent !chmod u+x %
redraw!
endif
endfunction
autocmd VimResized *
\ redrawstatus!
" 自动关闭预览窗口
autocmd InsertLeave *
\ if pumvisible() == 0 | pclose | endif
" 这样加快输入法自动切换时的体感速度
autocmd InsertEnter * set timeoutlen=100
autocmd InsertLeave * set timeoutlen=1000
" 每次访问文件时都把光标放置在上次离开的位置
autocmd BufReadPost *
\ call <SID>AC_ResetCursorPosition()
" 每次加载文件时都把全角空格' '高亮显示出来
autocmd BufReadPost *
\ call <SID>AC_HighlightDirtySpace()
" 写测试脚本的时候自动更新为可执行格式
autocmd BufWritePost *
\ call <SID>AC_ChmodExecutable()
" 让 checkpath 找到相关文件,便于 [I 正常工作
autocmd BufEnter,WinEnter *.c,*.cc,*.cpp,*.cxx,*.h,*.hh,*.hpp
\ set path+=./,/usr/include/
autocmd BufRead *.tjp
\ set filetype=tjp
autocmd Filetype java
\ setlocal omnifunc=javacomplete#Complete
endif
" }}}
" Plugins {{{1
" Cscope : Interactively examine a C program source {{{2
" http://cscope.sourceforge.net/
autocmd Filetype java
\ set tag=.cscope/cscope_java.tags,~/.tags_android,~/.tags_java6;
autocmd Filetype c,cpp
\ set tag=.cscope/cscope_c.tags,.cscope/cscope_h.tags,~/.tags.c,~/.gtk-tags.c;
autocmd Filetype python
\ set tag=.cscope/cscope.tags,/tmp/.tags_python;
if has("cscope")
set csto=1
set nocsverb
set cspc=3
set cscopequickfix=s-,c-,d-,i-,t-,e-
autocmd BufNewFile,BufReadPost,FileReadPost *
\ let &path = getcwd()
" add any database in current working directory
if glob(getcwd() . '/.cscope') != ""
exec "cscope add ".getcwd()."/.cscope/cscope.out"
exec "cscope reset"
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
exec "cscope add $CSCOPE_DB"
exec "cscope reset"
endif
function! <SID>CscopeRefresh()
" 如果当前目录存在 .cscope/ 的话
if glob(getcwd() . '/.cscope') != ""
call system("cscope -kbq -i.cscope/cscope.files -f.cscope/cscope.out &")
" 由于频繁保存引发的多个 ctags 间的互斥,可能会导致以下错误:
" ctags: ".cscope/cscope.tags" doesn't look like a tag file; I refuse to overwrite it.
" http://www.lslnet.com/linux/dosc1/55/linux-369438.htm
call system("ps -e | grep ctags || ctags --c++-kinds=+p --fields=+iaS --extra=+q --tag-relative -L.cscope/cscope.files -f.cscope/cscope.tags &")
exec "cscope add .cscope/cscope.out"
exec "cscope reset"
endif
endfunction
" 在后台更新 tags | cscope*,便于在代码间正确的跳转
autocmd BufWritePost,FileWritePost *.c,*.cc,*.cpp,*.cxx,*.h,*.hh,*.hpp
\ call <SID>CscopeRefresh()
endif
" cscope 似乎不支持正则表达式,无法实现精确匹配
" https://bugzilla.redhat.com/show_bug.cgi?id=163330
function! <SID>CscopeFind(mask, quick)
call G_GotoEditor()
if a:quick == 'y'
let str = expand('<cword>')
elseif a:quick == 'n'
let str = input('Search Pattern('.a:mask.'): ')
if str == ""
echo ""
return
endif
endif
let @/ = "\\<".str."\\>"
exec ":cs find ".a:mask." ".str
" 显示搜索结果窗口
" Unite quickfix
endfunction
" OmniCppComplete 0.41 : C/C++ omni-completion with ctags database {{{2
" http://www.vim.org/scripts/script.php?script_id=1520
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_ShowAccess = 1 " show member access information
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
let OmniCpp_GlobalScopeSearch = 0 " 0 or 1
" pythoncomplete 0.9 : Python Omni Completion {{{2
" http://www.vim.org/scripts/script.php?script_id=1542
" nothing
" Mark 2.6.2 : Highlight several words in different colors simultaneously. {{{2
" http://www.vim.org/scripts/script.php?script_id=2666
let g:mwAutoLoadMarks = 1 " 自动加载高亮的 Mark
nmap <Plug>IgnoreMarkSearchAnyNext <Plug>MarkSearchAnyNext
nmap <Plug>IgnoreMarkSearchAnyPrev <Plug>MarkSearchAnyPrev
" autofmt 1.6 (2011-11-03): text formatting plugin {{{2
" http://www.vim.org/scripts/script.php?script_id=1939
" Use uax14
set formatexpr=autofmt#uax14#formatexpr()
"}}}1
" bundle {{{1
call plug#begin('~/.vim/bundle')
" ARCHIVED (fucked up) {{{
" }}}
Plug 'chrisbra/NrrwRgn'
Plug 'easymotion/vim-easymotion'
" 文档结构的导航窗口
Plug 'majutsushi/tagbar'
" 补全功能的增强
Plug 'ervandew/supertab'
" 撤销功能的可视化窗口
Plug 'sjl/gundo.vim'
" 自动补全括号引号
Plug 'jiangmiao/auto-pairs'
" 源代码语法检查
Plug 'scrooloose/syntastic'
" 语言(Markdown)
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
" 著名的 Powerline
Plug 'vim-airline/vim-airline' | Plug 'vim-airline/vim-airline-themes'
" 为什么我没这种需求
Plug 'tpope/vim-surround'
" 缩略语/段落模板
Plug 'Shougo/neosnippet.vim' | Plug 'Shougo/neosnippet-snippets'
" 在模式间切换输入法
Plug 'lilydjwg/fcitx.vim', {'branch': 'fcitx5'}
" Plug 'rlue/vim-barbaric'
" 数值的递增递减
Plug 'vim-scripts/VisIncr'
" 数值的求和
Plug 'emugel/vim-sum'
" 内容的验算
Plug 'javier-lopez/checksum.vim'
" 光标下的单词高亮
Plug 'RRethy/vim-illuminate'
" 增量的模糊查询 [o]fzf [x]denite
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" 多光标编辑
Plug 'mg979/vim-visual-multi', {'branch': 'master'}
" 预览窗的快捷键
Plug 'ronakg/quickr-preview.vim'
" 语言(Yaml)
Plug 'mrk21/yaml-vim' " yaml
Plug 'pearofducks/ansible-vim' " ansible
Plug 'stephpy/vim-yaml' " highlight
" 语言(Dart)
Plug 'dart-lang/dart-vim-plugin'
" 语言(Golang) [o]vim-go [x]govim
Plug 'fatih/vim-go'
" 语言(Python)
Plug 'davidhalter/jedi-vim'
" 语言(Abs-lang)
Plug 'sysread/abs.vim'
" 语言(Elvish)
Plug 'chlorm/vim-syntax-elvish'
" 语言(Elixir)
Plug 'elixir-editors/vim-elixir'
Plug 'slashmili/alchemist.vim', {'branch': 'main'}
au! BufRead,BufNewFile *.ex,*.exs set filetype=elixir
au! BufRead,BufNewFile *.eex set filetype=eelixir
" 代码框架 [o]natebosch/vim-lsc [x]prabirshrestha/vim-lsp
Plug 'natebosch/vim-lsc'
Plug 'natebosch/vim-lsc-dart'
" 代码补全 [o]asyncomplete [x]deoplete [x]YouCompleteMe [x]nvim-completion-manager(NCM2)
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/asyncomplete.vim'
" 补全语种(源码、片段、路径、缓存等)
Plug 'prabirshrestha/asyncomplete-neosnippet.vim'
Plug 'yami-beta/asyncomplete-omni.vim'
Plug 'prabirshrestha/asyncomplete-file.vim'
Plug 'utahta/asyncomplete-buffer.vim'
" 真(?)智能补全
" Plug 'tbodt/deoplete-tabnine', { 'do': './install.sh' }
call plug#end()
" async completion in pure vim script for vim8 and neovim {{{2
" https://github.com/prabirshrestha/asyncomplete.vim
function! Omni()
call asyncomplete#register_source(asyncomplete#sources#omni#get_source_options({
\ 'name': 'omni',
\ 'whitelist': ['go'],
\ 'completor': function('asyncomplete#sources#omni#completor')
\ }))
call asyncomplete#register_source(asyncomplete#sources#omni#get_source_options({
\ 'name': 'alchemist',
\ 'whitelist': ['elixir'],
\ 'completor': function('asyncomplete#sources#elixir#completor'),
\ }))
" call asyncomplete#register_source(asyncomplete#sources#neosnippet#get_source_options({
" \ 'name': 'neosnippet',
" \ 'allowlist': ['*'],
" \ 'completor': function('asyncomplete#sources#neosnippet#completor'),
" \ }))
" call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
" \ 'name': 'file',
" \ 'allowlist': ['*'],
" \ 'priority': 10,
" \ 'completor': function('asyncomplete#sources#file#completor')
" \ }))
" call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({
" \ 'name': 'buffer',
" \ 'whitelist': ['*'],
" \ 'blacklist': ['go'],
" \ 'completor': function('asyncomplete#sources#buffer#completor'),
" \ 'config': {
" \ 'max_buffer_size': 100000,
" \ 'clear_cache': 1,
" \ 'min_word_len': 3
" \ },
" \ }))
endfunction
au VimEnter * :call Omni()
" A vim plugin for communicating with a language server {{{2
" https://github.com/natebosch/vim-lsc
nmap <silent> <unique> ge :LSClientAllDiagnostics<CR>
let g:lsc_server_commands = {'dart': 'dart_language_server'}
let g:lsc_auto_map = {
\ 'GoToDefinition': '<C-]>',
\ 'GoToDefinitionSplit': ['<C-W>]', '<C-W><C-]>'],
\ 'FindReferences': 'gr',
\ 'NextReference': '<C-n>',
\ 'PreviousReference': '<C-p>',
\ 'FindImplementations': 'gI',
\ 'FindCodeActions': 'ga',
\ 'Rename': 'gR',
\ 'ShowHover': v:true,
\ 'DocumentSymbol': 'go',
\ 'WorkspaceSymbol': 'gS',
\ 'SignatureHelp': 'gm',
\ 'Completion': 'omnifunc',
\}
" \ 'Completion': 'completefunc', 回改后,用户自定义的提示(例如,缓存区补全)
" \ 'Completion': 'omnifunc', 回改后,保持服务器的提示
" Syntax highlighting for Dart in Vim {{{2
" https://github.com/dart-lang/dart-vim-plugin
let g:dart_style_guide = 2
let g:dart_format_on_save = v:false
" Quickly preview Quickfix results in vim without opening the file {{{2
" https://github.com/ronakg/quickr-preview.vim
let g:quickr_preview_keymaps = 0
let g:quickr_preview_exit_on_enter = 1
function! QuickfixMapping()
nmap <silent> <buffer> p <plug>(quickr_preview)
nmap <silent> <buffer> q <plug>(quickr_preview_qf_close)
endfunction
augroup quickfix_group
autocmd!
autocmd filetype qf call QuickfixMapping()
augroup END
" Insert or delete brackets, parens, quotes in pair.
let g:AutoPairsFlyMode = 0
let g:AutoPairsMultilineClose = 0
" Syntax highlighting, matching rules and mappings for the original Markdown and extensions. {{{2
" https://github.com/plasticboy/vim-markdown
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_folding_style_pythonic = 1
let g:vim_markdown_conceal_code_blocks = 0
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_toml_frontmatter = 1
let g:vim_markdown_json_frontmatter = 1
let g:vim_markdown_strikethrough = 1
" MiniBufExplorer 6.4.4: Elegant buffer explorer - takes very little screen space {{{2
" http://www.vim.org/scripts/script.php?script_id=159 (origin)
" https://github.com/fholgado/minibufexpl.vim (improved)
"
" ppa1: (过时的)
" 为了配合 Powerline 显示,修改了源文件
"
" 被 airline 的 extensions#tabline 替代
" --
"let g:miniBufExplShowBufNumbers = 1
"let g:miniBufExplModSelTarget = 1
"let g:miniBufExplCheckDupeBufs = 0
"let g:miniBufExplMapWindowNavVim = 0
" -- 2015/04/16
" Tagbar v2.4.1: Display tags of the current file ordered by scope {{{2
" http://www.vim.org/scripts/script.php?script_id=3465
" https://github.com/majutsushi/tagbar
let g:tagbar_width = 35
let g:tagbar_autofocus = 1
function! <SID>ShowTagbar()
call G_GotoEditor()
exec ":TagbarToggle"
endfunction
" superTab 1.6 : Do all your insert-mode completion with Tab {{{2
" http://www.vim.org/scripts/script.php?script_id=1643
" https://github.com/ervandew/supertab
let SuperTabCrMapping=0 " 该项和delimitMate的expand_cr选项冲突
let SuperTabRetainCompletionType=1
let SuperTabDefaultCompletionType="<C-X><C-N>" "配合neocomplcache使用时,单独使用时<C-X><C-N>局部补全
let SuperTabMappingForward="<Tab>"
let SuperTabMappingBackward="<S-Tab>"
" Gundo 2.4.0 : Visualize your undo tree {{{2
" http://www.vim.org/scripts/script.php?script_id=3304
" https://github.com/sjl/gundo.vim
let g:gundo_preview_height = 50
let g:gundo_preview_bottom = 0
let g:gundo_right = 0
" NrrwRgn 26 : A Narrow Region Plugin similar to Emacs {{{2
" http://www.vim.org/scripts/script.php?script_id=3075
" https://github.com/chrisbra/NrrwRgn
let g:nrrw_topbot_leftright = 'aboveleft'
let g:nrrw_rgn_wdth = 50
" Syntastic 2.3.0 : Automatic syntax checking {{{2
" http://www.vim.org/scripts/script.php?script_id=2736
let g:syntastic_check_on_open=1
let g:syntastic_auto_loc_list=2
let g:syntastic_quiet_messages = {'level': 'warnings'}
let g:syntastic_mode_map = { 'mode': 'passive',
\ 'active_filetypes': ['c', 'cpp'] }
let g:syntastic_c_remove_include_errors=1
let g:syntastic_cpp_remove_include_errors=1
" EasyMotion 1.3 : Vim motions on speed! {{{2
" www.vim.org/scripts/script.php?script_id=3526
" https://github.com/Lokaltog/vim-easymotion.git
let g:EasyMotion_leader_key = 'f'
let g:EasyMotion_grouping = 1
let g:EasyMotion_keys = "asdfghjklweruiomnFGHJKLUIOYPMN"
" ansible-vim : A vim plugin for syntax highlighting Ansible's common filetypes {{{2
let g:ansible_unindent_after_newline = 1
let g:ansible_yamlKeyName = 'yamlKey'
"let g:ansible_attribute_highlight = "ob"
let g:ansible_name_highlight = 'b'
" vim-go : Go development plugin for Vim {{{2
" vim-illuminate: Vim plugin for selectively illuminating other uses of the current word under the cursor {{{2
let g:Illuminate_delay = 750
" keep and restore fcitx state when leaving/re-entering insert mode {{{2
" fcitx5-remote 不工作,没时间搞,怀疑和 airline-xkblayout 有关
" let g:fcitx5_remote = "/usr/bin/fcitx5-remote"
" let g:fcitx5_rime = 1
" 3# about statusline: vim-powerline、powerline、vim-airline {{{2
" 1. vim-powerline: The ultimate vim statusline utility. XXX has been deprecated {{{3
" 旧版的 powerline 专为 vim 设计
" http://www.vim.org/scripts/script.php?script_id=3881
" https://github.com/Lokaltog/vim-powerline
"
" - 'fancy'符号依赖定制字体,详情参考
" let g:Powerline_symbols = 'fancy'
" https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts
"
" 2. powerline: The ultimate statusline/prompt utility. {{{3
" 新版的 powerline 完全使用 python 扩展了原有的设计
" 不仅支持 vim,还支持 bash/zsh、tmux、awesome
" https://github.com/Lokaltog/powerline
" https://powerline.readthedocs.org/en/latest/index.html
"
" # 在使用宽字符的情况下,状态栏右侧内容右对齐(冗余空格)的问题 @db80fc95ed
" https://powerline.readthedocs.org/en/latest/fontpatching.html
" - <UE0A0>...<UE0A2>
" - <UE0B0>...<UE0b3>
" # 在使用单字符的情况下,状态栏左侧编辑模式显示不完全的问题 @db80fc95ed
"
" 3. vim-airline @e31d5f3: lean & mean status/tabline for vim that's light as air {{{3
" 完全使用 vim-scripts 实现的旧版的 vim-powerline,易于跨平台
" https://github.com/bling/vim-airline
"
let g:airline_theme="angr"
" 因为新版存在的宽字符问题,所以这里使用的是旧版的 vim-powerline 制作的字符
" 旧版的 vim-powerline symbols 使用以下编码
" - <U2B60>
" - <U2B61>
" - <U2B64>
" - <U2B80>...<U2B83>
let g:airline_left_sep = '⮀'
let g:airline_left_alt_sep = '⮁'
let g:airline_right_sep = '⮂'
let g:airline_right_alt_sep = '⮃'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.space = ''
endif
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#hunks#non_zero_only = 1
let g:airline#extensions#hunks#hunk_symbols = ['+', '=', '-']
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = '⮀'
let g:airline#extensions#tabline#left_alt_sep = '⮁'
let g:airline#extensions#tabline#show_buffers = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#xkblayout#enabled = 0
let g:airline#extensions#xkblayout#short_codes = {'us': 'EN', 'cqkm_42': 'CN'}
if has("gui_running") || &term == "nvim"
nmap <M-1> <Plug>AirlineSelectTab1
nmap <M-2> <Plug>AirlineSelectTab2
nmap <M-3> <Plug>AirlineSelectTab3
nmap <M-4> <Plug>AirlineSelectTab4
nmap <M-5> <Plug>AirlineSelectTab5
nmap <M-6> <Plug>AirlineSelectTab6
nmap <M-7> <Plug>AirlineSelectTab7
nmap <M-8> <Plug>AirlineSelectTab8
nmap <M-9> <Plug>AirlineSelectTab9
nmap <M-,> <Plug>AirlineSelectPrevTab
nmap <M-.> <Plug>AirlineSelectNextTab
else
nmap <Esc>1 <Plug>AirlineSelectTab1
nmap <Esc>2 <Plug>AirlineSelectTab2
nmap <Esc>3 <Plug>AirlineSelectTab3
nmap <Esc>4 <Plug>AirlineSelectTab4
nmap <Esc>5 <Plug>AirlineSelectTab5
nmap <Esc>6 <Plug>AirlineSelectTab6
nmap <Esc>7 <Plug>AirlineSelectTab7
nmap <Esc>8 <Plug>AirlineSelectTab8
nmap <Esc>9 <Plug>AirlineSelectTab9
nmap <Esc>, <Plug>AirlineSelectPrevTab
nmap <Esc>. <Plug>AirlineSelectNextTab
endif
let g:airline#extensions#tabline#buffer_idx_format = {
\ '1': ' ①',
\ '2': ' ②',
\ '3': ' ③',
\ '4': ' ④',
\ '5': ' ⑤',
\ '6': ' ⑥',
\ '7': ' ⑦',
\ '8': ' ⑧',
\ '9': ' ⑨'
\}
let g:airline#extensions#whitespace#symbol = '※'
let g:airline#extensions#whitespace#trailing_format = '[T:%s]'
let g:airline#extensions#whitespace#mixed_indent_algo = 2
let g:airline#extensions#whitespace#mixed_indent_format = '[M:%s]'
" 4# Shougo's pack: https://github.com/Shougo/ {{{2
" vimproc 7.0 : Asynchronous execution plugin for Vim {{{3
" nothing
" neosnippet {{{3
let g:neosnippet#snippets_directory = "$HOME/.vim/snippets/"
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" Plugin key-mappings.
" imap <expr><Space> neosnippet#expandable() == 1 ? "\<Plug>(neosnippet_expand)" : "\<Space>"
" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" g:neosnippet#scope_aliases is a dictionary, initialize it if you haven't done it
let g:neosnippet#scope_aliases = {}
let g:neosnippet#scope_aliases['sls'] = 'sls-2014.1.13'
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" }}}2
" }}}1
" 3# keys ref: http://tinyurl.com/2cae5vw {{{1
if !has('nvim')
" xterm keys {{{2
map <Esc>[1;2P <S-F1>
map <Esc>[1;2Q <S-F2>
map <Esc>[1;2R <S-F3>
map <Esc>[1;2S <S-F4>
map <Esc>[15;2~ <S-F5>
map <Esc>[17;2~ <S-F6>
map <Esc>[18;2~ <S-F7>
map <Esc>[19;2~ <S-F8>
map <Esc>[20;2~ <S-F9>
map <Esc>[21;2~ <S-F10>
map <Esc>[23;2~ <S-F11>
map <Esc>[24;2~ <S-F12>
map <Esc>[1;5P <C-F1>
map <Esc>[1;5Q <C-F2>
map <Esc>[1;5R <C-F3>
map <Esc>[1;5S <C-F4>
map <Esc>[15;5~ <C-F5>
map <Esc>[17;5~ <C-F6>
map <Esc>[18;5~ <C-F7>
map <Esc>[19;5~ <C-F8>
map <Esc>[20;5~ <C-F9>
map <Esc>[21;5~ <C-F10>
map <Esc>[23;5~ <C-F11>
map <Esc>[24;5~ <C-F12>
map! <Esc>[1;2P <S-F1>
map! <Esc>[1;2Q <S-F2>
map! <Esc>[1;2R <S-F3>
map! <Esc>[1;2S <S-F4>
map! <Esc>[15;2~ <S-F5>
map! <Esc>[17;2~ <S-F6>
map! <Esc>[18;2~ <S-F7>
map! <Esc>[19;2~ <S-F8>
map! <Esc>[20;2~ <S-F9>
map! <Esc>[21;2~ <S-F10>
map! <Esc>[23;2~ <S-F11>
map! <Esc>[24;2~ <S-F12>
map! <Esc>[1;5P <C-F1>
map! <Esc>[1;5Q <C-F2>
map! <Esc>[1;5R <C-F3>
map! <Esc>[1;5S <C-F4>
map! <Esc>[15;5~ <C-F5>
map! <Esc>[17;5~ <C-F6>
map! <Esc>[18;5~ <C-F7>
map! <Esc>[19;5~ <C-F8>
map! <Esc>[20;5~ <C-F9>
map! <Esc>[21;5~ <C-F10>
map! <Esc>[23;5~ <C-F11>
map! <Esc>[24;5~ <C-F12>
" gnome-terminal keys {{{2
map <Esc>O1;2P <S-F1>
map <Esc>O1;2Q <S-F2>
map <Esc>O1;2R <S-F3>
map <Esc>O1;2S <S-F4>
map <Esc>[15;2~ <S-F5>
map <Esc>[17;2~ <S-F6>
map <Esc>[18;2~ <S-F7>
map <Esc>[19;2~ <S-F8>
map <Esc>[20;2~ <S-F9>
" not available <S-F10>
map <Esc>[23;2~ <S-F11>
map <Esc>[24;2~ <S-F12>
" not available <C-F1>
map <Esc>O1;5Q <C-F2>
map <Esc>O1;5R <C-F3>
map <Esc>O1;5S <C-F4>
map <Esc>[15;5~ <C-F5>
map <Esc>[17;5~ <C-F6>
map <Esc>[18;5~ <C-F7>
map <Esc>[19;5~ <C-F8>
map <Esc>[20;5~ <C-F9>
map <Esc>[21;5~ <C-F10>
map <Esc>[23;5~ <C-F11>