-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
3645 lines (3591 loc) · 121 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
scriptencoding utf-8
" Last Modified: 28 Oct 2019 09:56 +0800
" 其他文件 [[[1
" 引用 Example 设置 [[[2
if !exists("g:VimrcIsLoad")
runtime vimrc_example.vim
endif
"]]]
"]]]
" 我的设置
" 准备工作 [[[1
" 判定语句及定义变量 [[[2
" 判定当前操作系统类型 [[[3
if has("win32") || has("win95") || has("win64") || has("win16")
let s:isWindows=1
" For gVimPortable
let $VIMFILES = $VIM."/../../Data/settings/vimfiles"
else
let s:isWindows=0
let $VIMFILES = $HOME."/.vim"
endif
if (!s:isWindows
\ && (has('mac') || has('macunix') || has('gui_macvim') ||
\ (!executable('xdg-open') && system('uname') =~? '^darwin')))
let s:isMac=1
else
let s:isMac=0
endif
" ]]]
" 判定当前是否图形界面 [[[3
if has("gui_running")
let s:isGUI=1
else
let s:isGUI=0
endif
" ]]]
" 判定当前终端是否256色 [[[3
if (s:isWindows==0 && s:isGUI==0 &&
\ (&term =~ "256color" || &term =~ "xterm" || &term =~ "fbterm"))
let s:isColor=1
else
let s:isColor=0
endif
" ]]]
" 判定当前是否有 Ack/Ag [[[3
if executable('ack')
let s:hasAck=1
else
let s:hasAck=0
endif
if executable('ag')
let s:hasAg=1
else
let s:hasAg=0
endif
" ]]]
" 判定当前是否有 Cscope/Global [[[3
if has('cscope')
let s:hasCscope=1
if executable('cscope')
let s:hasCscopeExe=1
else
let s:hasCscopeExe=0
endif
if executable('ccglue')
let s:hasCCglueExe=1
else
let s:hasCCglueExe=0
endif
if executable('gtags-cscope')
let s:hasGtagsCscopeExe=1
else
let s:hasGtagsCscopeExe=0
endif
else
let s:hasCscope=0
let s:hasCscopeExe=0
let s:hasCcglueExe=0
let s:hasGtagsCscopeExe=0
endif
" ]]]
" 判定当前是否有 CTags [[[3
if executable('ctags')
let s:hasCTags=1
else
let s:hasCTags=0
endif
" ]]]
" 判定当前是否支持 gvimfullscreen.dll [[[3
if s:isGUI && has('gui_win32') && has('libcall')
let s:hasVFS=1
else
let s:hasVFS=0
endif
" ]]]
" 判定当前是否支持 Lua ,并设置自动完成使用的插件 [[[3
" NeoComplete 要求支持 Lua
if has('lua')
let s:hasLua=1
let s:autocomplete_method = 'neocomplete'
else
let s:hasLua=0
let s:autocomplete_method = 'neocomplcache'
endif
" ]]]
" 判定当前是否支持 Node.js [[[3
if has('node') || has('nodejs') || has('iojs')
let s:hasNode=1
else
let s:hasNode=0
endif
" ]]]
" 判定当前是否支持 Python 2或3 [[[3
if has('python') || has('python3')
let s:hasPython=1
else
let s:hasPython=0
endif
" ]]]
" 判定当前终端是否 Tmux [[[3
if exists('$TMUX')
let s:isTmux=1
else
let s:isTmux=0
endif
" ]]]
" 判定当前是否服务器环境 [[[3
if filereadable(expand("$VIMFILES/vimrc.isserver"))
let s:isServer=1
else
let s:isServer=0
endif
" ]]]
" ]]]
" 设置自动命令组 [[[2
" 特定文件类型自动命令组 [[[3
augroup Filetype_Specific
autocmd!
augroup END
" ]]]
" 默认自动命令组 [[[3
augroup MyAutoCmd
autocmd!
augroup END
" ]]]
" ]]]
" 设置缓存目录 [[[2
" (以下取自 https://github.com/bling/dotvim )
let s:cache_dir = $VIMFILES."/.cache"
" ]]]
" ]]]
" 定义函数 [[[1
" (以下取自 https://github.com/asins/vim ) [[[2
" 回车时前字符为{时自动换行补全 [[[3
function! <SID>OpenSpecial(ochar,cchar)
let line = getline('.')
let col = col('.') - 2
if(line[col] != a:ochar)
if(col > 0)
return "\<Esc>a\<CR>"
else
return "\<CR>"
endif
endif
if(line[col+1] != a:cchar)
call setline('.',line[:(col)].a:cchar.line[(col+1):])
else
call setline('.',line[:(col)].line[(col+1):])
endif
return "\<Esc>a\<CR>;\<CR>".a:cchar."\<Esc>\"_xk$\"_xa"
endfunction
" ]]]
" ]]]
" (以下取自 https://github.com/bling/dotvim ) [[[2
" 获取缓存目录 [[[3
function! s:get_cache_dir(suffix)
return resolve(expand(s:cache_dir . "/" . a:suffix))
endfunction
" ]]]
" 保证该目录存在,若不存在则新建目录 [[[3
function! EnsureExists(path)
if !isdirectory(expand(a:path))
call mkdir(expand(a:path))
endif
endfunction
" ]]]
" 执行特定命令并保留光标位置及搜索历史 [[[3
function! Preserve(command)
" preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" do the business:
execute a:command
" clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
" ]]]
" 格式化全文 [[[3
function! FullFormat()
call Preserve("normal gg=G")
endfunction
" ]]]
" ]]]
" (以下取自 https://github.com/lilydjwg/dotvim ) [[[2
" 删除所有未显示且无修改的缓冲区以减少内存占用 [[[3
function! s:cleanbufs()
for bufNr in filter(range(1, bufnr('$')),
\ 'buflisted(v:val) && !bufloaded(v:val)')
execute bufNr . 'bdelete'
endfor
endfunction
" ]]]
" 切换显示行号/相对行号/不显示 [[[3
function! s:toggle_number()
if &nu && &rnu
setlocal nornu
setlocal nonu
elseif &nu && !&rnu
setlocal rnu
else
setlocal nu
setlocal nornu
endif
endfunction
" ]]]
" 退格删除自动缩进 [[[3
function! Lilydjwg_checklist_bs(pat)
" 退格可清除自动出来的列表符号
if getline('.') =~ a:pat
let ind = indent(line('.')-1)
if !ind
let ind = indent(line('.')+1)
endif
call setline(line('.'), repeat(' ', ind))
return ""
else
return "\<BS>"
endif
endfunction
" ]]]
" 取得光标处的匹配 [[[3
function! GetPatternAtCursor(pat)
let col = col('.') - 1
let line = getline('.')
let ebeg = -1
let cont = match(line, a:pat, 0)
while (ebeg >= 0 || (0 <= cont) && (cont <= col))
let contn = matchend(line, a:pat, cont)
if (cont <= col) && (col < contn)
let ebeg = match(line, a:pat, cont)
let elen = contn - ebeg
break
else
let cont = match(line, a:pat, contn)
endif
endwhile
if ebeg >= 0
return strpart(line, ebeg, elen)
else
return ""
endif
endfunction
" ]]]
" 用火狐打开链接 [[[3
function! OpenURL()
let s:url = GetPatternAtCursor('\v%(https?|ftp)://[^]''" \t\r\n>*。,\`)]*')
if s:url == ""
echohl WarningMsg
echomsg '在光标处未发现URL!'
echohl None
else
echo '打开URL:' . s:url
if s:isWindows
" start 不是程序,所以无效。并且,cmd 只能使用双引号
" call system("cmd /q /c start \"" . s:url . "\"")
call system("E:\\PortableApps\\FirefoxPortable\\firefox\\firefox.exe \"" . s:url . "\"")
elseif s:isMac
call system("open -a \"/Applications/Google Chrome.app\" '" . s:url . "'")
else
" call system("gnome-open " . s:url)
call system("setsid firefox '" . s:url . "' &")
endif
endif
unlet s:url
endfunction
" ]]]
" %xx -> 对应的字符(到消息) [[[3
function! GetHexChar()
let chars = GetPatternAtCursor('\(%[[:xdigit:]]\{2}\)\+')
if chars == ''
echohl WarningMsg
echo '在光标处未发现%表示的十六进制字符串!'
echohl None
return
endif
let str = substitute(chars, '%', '\\x', 'g')
exe 'echo "'. str . '"'
endfunction
" ]]]
" 打开 NERDTree,使用当前文件目录或者当前目录 [[[3
function! NERDTreeOpen()
silent execute "TagbarClose"
if exists("t:NERDTreeBufName")
NERDTreeToggle
else
try
NERDTree `=expand('%:h')`
catch /E121/
NERDTree `=getcwd()`
endtry
endif
endfunction
" ]]]
" ]]]
" (以下取自 https://github.com/Shougo/shougo-s-github ) [[[2
" 切换选项开关 [[[3
function! ToggleOption(option_name)
execute 'setlocal' a:option_name.'!'
execute 'setlocal' a:option_name.'?'
endfunction
" ]]]
" 切换变量开关 [[[3
function! ToggleVariable(variable_name)
if eval(a:variable_name)
execute 'let' a:variable_name.' = 0'
else
execute 'let' a:variable_name.' = 1'
endif
echo printf('%s = %s', a:variable_name, eval(a:variable_name))
endfunction
" ]]]
" ]]]
" (以下取自 https://github.com/terryma/dotfiles ) [[[2
" 调整 Quickfix 窗口高度 [[[3
function! AdjustWindowHeight(minheight, maxheight)
execute max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _"
endfunction
" ]]]
" ]]]
" (以下取自 http://wyw.dcweb.cn/vim/_vimrc.html ) [[[2
" 设置文件编码 [[[3
function! s:SetFileEncodings(encodings)
let b:myfileencodingsbak=&fileencodings
let &fileencodings=a:encodings
endfunction
" ]]]
" 还原文件编码 [[[3
function! s:RestoreFileEncodings()
let &fileencodings=b:myfileencodingsbak
unlet b:myfileencodingsbak
endfunction
" ]]]
" ]]]
" 自己原创修改 [[[2
" 编译单个源文件 [[[3
function! Do_OneFileMake()
if expand("%:p:h")!=getcwd()
echohl WarningMsg
\| echo "Fail to make! This file is not in the current directory!"
\| echohl None
return
endif
let sourcefileename=expand("%:t")
if (sourcefileename=="" || (&filetype!="cpp" && &filetype!="c"))
echohl WarningMsg
\| echo "Fail to make! Please select the right file!"
\| echohl None
return
endif
let deletedspacefilename=substitute(sourcefileename,' ','','g')
if strlen(deletedspacefilename)!=strlen(sourcefileename)
echohl WarningMsg
\| echo "Fail to make! Please delete the spaces in the filename!"
\| echohl None
return
endif
if &filetype=="c"
if s:isWindows==1
setlocal makeprg=gcc\ -Wall\ -Wconversion\ -o\ %<.exe\ %
else
setlocal makeprg=gcc\ -Wall\ -Wconversion\ -o\ %<\ %
endif
elseif &filetype=="cpp"
if s:isWindows==1
setlocal makeprg=g++\ -o\ %<.exe\ %
else
setlocal makeprg=g++\ -o\ %<\ %
endif
" elseif &filetype=="cs"
" setlocal makeprg=csc\ \/nologo\ \/out:%<.exe\ %
endif
if(s:isWindows==1)
let outfilename=substitute(sourcefileename,'\(\.[^.]*\)' ,'.exe','g')
let toexename=outfilename
else
let outfilename=substitute(sourcefileename,'\(\.[^.]*\)' ,'','g')
let toexename=outfilename
endif
if filereadable(outfilename)
if(s:isWindows==1)
let outdeletedsuccess=delete(getcwd()."\\".outfilename)
else
let outdeletedsuccess=delete("./".outfilename)
endif
if(outdeletedsuccess!=0)
setlocal makeprg=make
echohl WarningMsg
\| echo "Fail to make! I cannot delete the ".outfilename
\| echohl None
return
endif
endif
" Use Dispatch Make
execute "Make"
setlocal makeprg=make
if getqflist() == [] "compile successfully and no warning
let l:flag = 0
silent execute "cclose"
execute "normal :"
if filereadable(outfilename)
if(s:isWindows==1)
execute "!".toexename
else
execute "!./".toexename
endif
endif
else
for l:inx in getqflist()
for l:val in values(l:inx)
if l:val =~ 'error'
let l:flag = 1
break
elseif l:val =~ 'warning'
let l:flag = 2
else
let l:flag = 0
endif
endfor
if l:val =~ 'error'
break
endif
endfor
endif
if l:flag == 1
" Use Dispatch Copen
execute "Copen"
elseif l:flag == 2
let l:select = input('There are warnings! [r]un or [s]olve? ')
if l:select == 'r'
execute "normal :"
if filereadable(outfilename)
if(s:isWindows==1)
execute "!".toexename
else
execute "!./".toexename
endif
endif
execute "cwindow"
elseif l:select == 's'
" Use Dispatch Copen
execute "Copen"
else
echohl WarningMsg
\| echo "Input error!"
\| echohl None
endif
else
execute "cwindow"
endif
endfunction
" ]]]
" 执行 make 的设置 [[[3
function! Do_make()
setlocal makeprg=make
" Use Dispatch Make
execute "Make"
execute "cwindow"
endfunction
" ]]]
" 关闭窗口或卸载缓冲区 [[[3
function! CloseWindowOrKillBuffer()
let number_of_windows_to_this_buffer =
\ len(filter(range(1, winnr('$')), "winbufnr(v:val) == bufnr('%')"))
" never bdelete a nerd tree
if matchstr(expand("%"), 'NERD') == 'NERD'
wincmd c
return
endif
" never bdelete a scratch buffer
if (bufname('') =~# '\[Scratch]')
ScratchClose
return
endif
if number_of_windows_to_this_buffer > 1
wincmd c
else
bdelete
endif
endfunction
" ]]]
" 切换左右缓冲区 [[[3
function! SwitchBuffer(direction)
if a:direction == 0
if bufnr("%") == 2
exe "buffer ".bufnr("$")
else
bprev
endif
else
if bufnr("%") == bufnr("$")
buffer2
else
bnext
endif
endif
endfunction
" ]]]
" ]]]
" ]]]
" NeoBundle.vim 插件管理器 [[[1
" 运行路径添加 NeoBundle 目录 [[[2
if has('vim_starting')
set runtimepath+=$VIMFILES/bundle/neobundle.vim/
endif
" ]]]
" 开始配置 NeoBundle [[[2
call neobundle#begin(expand("$VIMFILES/bundle"))
" set shellquote="\""
" set shellxquote="\""
" set noshellslash
" ]]]
" 载入 NeoBundle 缓存或配置 NeoBundle [[[2
if neobundle#load_cache()
" 使 NeoBundle 管理 NeoBundle [[[3
" required!
NeoBundleFetch 'Shougo/neobundle.vim'
" ]]]
" 初始化插件组设置 [[[3
let s:plugin_groups = []
call add(s:plugin_groups, 'core')
call add(s:plugin_groups, 'autocomplete')
call add(s:plugin_groups, 'editing')
call add(s:plugin_groups, 'lint')
if !s:isWindows
call add(s:plugin_groups, 'linux')
" FIXME Windows 下的 GitGutter 似乎有点问题
call add(s:plugin_groups, 'scm')
if s:isTmux
call add(s:plugin_groups, 'tmux')
endif
else
call add(s:plugin_groups, 'windows')
endif
call add(s:plugin_groups, 'misc')
call add(s:plugin_groups, 'navigation')
call add(s:plugin_groups, 'unite')
" 仅在非生产环境下载入开发插件
if !s:isServer
call add(s:plugin_groups, 'indent')
call add(s:plugin_groups, 'javascript')
if s:hasLua
call add(s:plugin_groups, 'lua')
endif
call add(s:plugin_groups, 'php')
call add(s:plugin_groups, 'web')
endif
" ]]]
" My bundles here:
" 核心 [[[3
if count(s:plugin_groups, 'core')
if !s:isServer
" vim-airline 是更轻巧的 vim-powerline 代替品
NeoBundle 'vim-airline/vim-airline'
NeoBundle 'vim-airline/vim-airline-themes'
endif
" MatchIt -- 扩展%的匹配功能,对%命令进行扩展使得能在嵌套标签和语句之间跳转
NeoBundleLazy '[email protected]:Firef0x/matchit.git',
\ {'autoload':{'mappings':[
\ ['nxo', '%', 'g%', '[%', ']%']
\ ]}}
NeoBundle 'Shougo/vimproc.vim',
\ {'build' : {
\ 'windows' : 'tools\\update-dll-mingw',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
" Repeat -- 支持普通模式使用"."来重复执行一些插件的命令
NeoBundle 'tpope/vim-repeat'
" VisualRepeat -- 支持可视模式使用"."来重复执行一些插件的命令
NeoBundle 'visualrepeat',
\ {'depends':'ingo-library'}
" 包含普遍使用的 Vim 的通用配置
NeoBundle 'tpope/vim-sensible'
" Surround -- 快速添加、替换、清除包围符号、标签
" 在 Visual Mode 内原来的 s 与 S(substitute)命令便不再有效
NeoBundle 'tpope/vim-surround'
NeoBundle 'tpope/vim-dispatch'
endif
" ]]]
" 自动完成 [[[3
if count(s:plugin_groups, 'autocomplete')
" 解决插入模式下自动补全会定住的问题
" 以下取自 https://github.com/bling/dotvim/pull/30
NeoBundle 'Konfekt/FastFold'
if s:autocomplete_method == 'neocomplcache'
NeoBundleLazy 'Shougo/neocomplcache.vim',
\ {'autoload':{'insert':1}}
elseif s:autocomplete_method == 'neocomplete'
NeoBundleLazy 'Shougo/neocomplete.vim',
\ {'autoload':{
\ 'depends':'Shougo/context_filetype.vim',
\ 'insert':1},
\ 'vim_version':'7.3.885'}
endif
NeoBundleLazy 'Shougo/neosnippet.vim',
\ {'autoload':{
\ 'insert':1,
\ 'filetypes':'snippet',
\ 'unite_sources':['neosnippet/runtime',
\ 'neosnippet/user',
\ 'snippet']},
\ 'depends': ['Shougo/context_filetype.vim',
\ 'Shougo/neosnippet-snippets']}
NeoBundle 'honza/vim-snippets'
" React 特定的代码片段
NeoBundle 'justinj/vim-react-snippets'
endif
" ]]]
" 文本编辑 [[[3
if count(s:plugin_groups, 'editing')
" 比较指定文本块
NeoBundleLazy 'AndrewRadev/linediff.vim',
\ {'autoload':{'commands':[
\ 'Linediff',
\ 'LinediffReset'
\ ]}}
" 打散合并单行语句
NeoBundleLazy 'AndrewRadev/splitjoin.vim',
\ {'autoload':{'commands':[
\ 'SplitjoinJoin',
\ 'SplitjoinSplit'
\ ]}}
NeoBundle 'chrisbra/NrrwRgn'
" 给各种 tags 标记不同的颜色,便于观看调试的插件
NeoBundle 'dimasg/vim-mark'
" tabular 比 Align 更简单,所以替换
NeoBundleLazy 'godlygeek/tabular',
\ {'autoload':{
\ 'commands':[
\ 'Tabularize',
\ 'AddTabularPipeline'
\ ]}}
NeoBundleLazy 'gorkunov/smartpairs.vim',
\ {'autoload':{
\ 'commands':[
\ 'SmartPairs',
\ 'SmartPairsI',
\ 'SmartPairsA'
\ ],
\ 'mappings':[
\ ['n', 'viv', 'vav', 'civ', 'cav', 'div', 'dav', 'yiv', 'yav'],
\ ['xv', 'v']
\ ]}}
NeoBundle 'jiangmiao/auto-pairs'
" 自动更新 Last Modified 字符串
NeoBundle 'jmcantrell/vim-lastmod'
" TODO vim-sneak 是 vim-easymotion 的代替品,考虑是否替换
" NeoBundle 'justinmk/vim-sneak'
NeoBundleLazy 'kana/vim-scratch',
\ {'autoload':{
\ 'commands':[
\ 'ScratchClose',
\ 'ScratchEvaluate',
\ 'ScratchOpen'
\ ]}}
" rainbow 是 rainbow_parentheses.vim 的改进版,所以替换
" NeoBundle 'kien/rainbow_parentheses.vim'
" EasyMotion -- 移动命令增强插件
NeoBundle 'Lokaltog/vim-easymotion'
NeoBundle 'luochen1990/rainbow'
" 连续按 j/k 时加速移动光标
NeoBundle 'rhysd/accelerated-jk'
NeoBundle 'rhysd/clever-f.vim'
NeoBundle 'terryma/vim-multiple-cursors'
" 在 Visual 模式下使用 */# 跳转
NeoBundleLazy 'thinca/vim-visualstar',
\ {'autoload':{'mappings':[
\ ['xv', '*', '#', 'g*', 'g#']
\ ]}}
" tcomment_vim 比 nerdcommenter 更智能,所以替换
" NeoBundle 'scrooloose/nerdcommenter'
NeoBundleLazy 'tomtom/tcomment_vim',
\ {'autoload':{'mappings':[
\ ['nx', 'gc', 'gcc', 'gC']
\ ]}}
endif
" ]]]
" 代码缩进 [[[3
if count(s:plugin_groups, 'indent')
" vim-indent-guides -- 显示缩进线
NeoBundle 'nathanaelkane/vim-indent-guides'
endif
" ]]]
" JavaScript [[[3
if count(s:plugin_groups, 'javascript')
" 以下3个插件以 vim-javascript 和 javascript-libraries-syntax.vim 取代
" NeoBundleLazy 'JavaScript-Indent',
" \ { 'autoload' : {'filetypes':['javascript']} }
" NeoBundleLazy 'jQuery',
" \ { 'autoload' : {'filetypes':['javascript']} }
" NeoBundleLazy 'jelera/vim-javascript-syntax',
" \ {'autoload':{'filetypes':['javascript']}}
NeoBundleLazy 'ohle/underscore-templates.vim',
\ {'autoload':{
\ 'filetypes':[
\ 'underscore_template'
\ ]}}
NeoBundleLazy 'mustache/vim-mustache-handlebars',
\ {'autoload':{
\ 'filetypes':[
\ 'mustache',
\ 'handlebars'
\ ]}}
NeoBundleLazy 'mxw/vim-jsx',
\ {'autoload':{'filetypes':['javascript.jsx']}}
" NeoBundleLazy 'pangloss/vim-javascript',
" \ {'autoload':{'filetypes':['javascript']}}
" NeoBundleLazy 'posva/vim-vue',
" \ {'autoload':{'filetypes':['vue']}}
NeoBundleLazy 'HerringtonDarkholme/yats.vim',
\ {'autoload':{'filetypes':['typescript']}}
NeoBundleLazy 'othree/yajs.vim',
\ {'autoload':{'filetypes':['javascript']}}
NeoBundleLazy 'othree/es.next.syntax.vim',
\ {'autoload':{'filetypes':['javascript', 'typescript']}}
NeoBundleLazy 'othree/javascript-libraries-syntax.vim',
\ {'autoload':{
\ 'filetypes':[
\ 'javascript',
\ 'coffee',
\ 'ls',
\ 'typescript'
\ ]}}
NeoBundleLazy 'leafgarland/typescript-vim',
\ {'autoload':{
\ 'filetypes':[
\ 'typescript'
\ ]}}
if s:hasNode
NeoBundleLazy 'maksimr/vim-jsbeautify',
\ {'autoload':{
\ 'commands':[
\ 'CSSBeautify',
\ 'JsBeautify',
\ 'HtmlBeautify'
\ ],
\ 'filetypes':[
\ 'css',
\ 'html',
\ 'javascript',
\ 'jinja',
\ 'json',
\ 'less',
\ 'mustache'
\ ]}}
" JavaScript 自动补全引擎
NeoBundleLazy 'ternjs/tern_for_vim',
\ {'autoload':{
\ 'commands':[
\ 'TernDef',
\ 'TernDoc',
\ 'TernType',
\ 'TernRefs',
\ 'TernRename'
\ ],
\ 'filetypes':[
\ 'javascript'
\ ]},
\ 'build':{
\ 'cygwin' : 'npm install',
\ 'mac' : 'npm install',
\ 'unix' : 'npm install',
\ 'windows' : 'npm install',
\ }}
endif
endif
" ]]]
" 代码检查 [[[3
if count(s:plugin_groups, 'lint')
" Syntastic -- 包含很多语言的语法与编码风格检查插件
NeoBundle 'scrooloose/syntastic'
NeoBundle 'syngan/vim-vimlint',
\ {'depends':'ynkdir/vim-vimlparser'}
endif
" ]]]
" Linux [[[3
if count(s:plugin_groups, 'linux')
" 以 root 权限打开文件,以 SudoEdit.vim 代替 sudo.vim
" 参见 http://vim.wikia.com/wiki/Su-write
NeoBundle 'chrisbra/SudoEdit.vim'
" 在终端下自动开启关闭 paste 选项
NeoBundle 'ConradIrwin/vim-bracketed-paste'
if s:hasPython && executable('fcitx')
NeoBundle 'fcitx.vim'
endif
endif
" ]]]
" Lua [[[3
if count(s:plugin_groups, 'lua')
" NeoBundleLazy 'luarefvim',
" \ {'autoload':{'filetypes':['lua']}}
endif
" ]]]
" 文本定位/纵览 [[[3
if count(s:plugin_groups, 'navigation')
if s:hasCTags
" CTags 语法高亮
NeoBundle 'bb:abudden/taghighlight'
" C Call-Tree Explorer 源码浏览工具
if s:hasCscope
NeoBundleLazy 'hari-rangarajan/CCTree',
\ {'autoload':{
\ 'commands':[
\ 'CCTreeLoadDB',
\ 'CCTreeLoadXRefDBFromDisk'
\ ]}}
endif
" Tagbar -- 提供单个源代码文件的函数列表之类的功能,强于 Taglist
NeoBundleLazy 'majutsushi/tagbar',
\ {'autoload':{'commands':[
\ 'TagbarClose',
\ 'TagbarToggle'
\ ]}}
" 增强源代码浏览
NeoBundleLazy 'wesleyche/SrcExpl',
\ {'autoload':{'commands':'SrcExplToggle'}}
endif
" 在同一文件名的.h与.c/.cpp之间切换
NeoBundleLazy 'a.vim',
\ {'autoload':{'filetypes':['c', 'cpp']}}
" 对三路合并时的<<< >>> === 标记语法高亮
NeoBundle 'ConflictDetection',
\ {'depends':'ingo-library'}
" 在三路合并时的<<< >>> === 代码块之间快速移动
NeoBundle 'ConflictMotions',
\ {'depends':['ingo-library','CountJump']}
" 模糊检索文件, 缓冲区, 最近最多使用, 标签等的 Vim 插件
" Unite 比 CtrlP 更强大,所以替换
" NeoBundle 'ctrlpvim/ctrlp.vim'
" 删除尾部多余空格
NeoBundle 'DeleteTrailingWhitespace'
NeoBundleLazy 'mbbill/undotree',
\ {'autoload':{'commands':'UndotreeToggle'}}
if s:hasAck || s:hasAg
NeoBundle 'mileszs/ack.vim'
" 在 NERDTree 中搜索目录
NeoBundle 'tyok/nerdtree-ack',
\ {'depends':['scrooloose/nerdtree','mileszs/ack.vim']}
endif
" NERDTree -- 树形的文件系统浏览器(替代 Netrw),功能比 Vim 自带的 Netrw 强大
NeoBundle 'scrooloose/nerdtree'
" 显示尾部多余空格
NeoBundle 'ShowTrailingWhitespace'
NeoBundle 'Xuyuanp/nerdtree-git-plugin',
\ {'depends':'scrooloose/nerdtree',
\ 'external_command':'git'}
endif
" ]]]
" PHP [[[3
if count(s:plugin_groups, 'php')
NeoBundleLazy '2072/PHP-Indenting-for-VIm',
\ {'autoload':{'filetypes':['php']}}
" 高亮与光标下变量相同名字的变量
NeoBundleLazy 'alexander-alzate/vawa.vim',
\ {'autoload':{'filetypes':['php']}}
NeoBundleLazy 'php_localvarcheck.vim',
\ {'autoload':{'filetypes':['php']}}
"press K on a function for full php manual
NeoBundleLazy 'spf13/PIV',
\ {'autoload':{'filetypes':['blade', 'php']}}
endif
" ]]]
" 代码管理 [[[3
if count(s:plugin_groups, 'scm')
NeoBundle 'airblade/vim-gitgutter',
\ {'autoload':{'insert':1},
\ 'disabled':!has('signs'),
\ 'external_command':'git'}
NeoBundleLazy 'gregsexton/gitv',
\ {'depends':['tpope/vim-fugitive'],
\ 'autoload':{'commands':'Gitv'},
\ 'external_command':'git'}
NeoBundle 'tpope/vim-fugitive',
\ {'augroup':'fugitive',
\ 'commands':[
\ 'Git',
\ 'Gdiff',
\ 'Gstatus',
\ 'Gwrite',
\ 'Gcd',
\ 'Glcd',
\ 'Ggrep',
\ 'Glog',
\ 'Gcommit',
\ 'Gblame',
\ 'Gbrowse'
\ ],
\ 'external_command':'git'}
endif
" ]]]
" TMux [[[3
if count(s:plugin_groups, 'tmux')
NeoBundle 'christoomey/vim-tmux-navigator'
endif
" Unite 插件组 [[[3
if count(s:plugin_groups, 'unite')
" Unite -- 全能查找插件,查找文件、寄存器、缓冲区、MRU 等
NeoBundleLazy 'Shougo/unite.vim',
\ {'autoload':{
\ 'commands':[{
\ 'name':'Unite',
\ 'complete':'customlist,unite#complete_source'
\ }],
\ 'depends':'Shougo/neomru.vim',
\ }}
NeoBundleLazy 'Shougo/neomru.vim',
\ {'autoload':{
\ 'filetypes':'all',
\ 'on_source':'unite.vim'}}
NeoBundleLazy 'Shougo/unite-help',
\ {'autoload':{'on_source':'unite.vim'}}
NeoBundleLazy 'Shougo/unite-outline',
\ {'autoload':{'on_source':'unite.vim'}}
NeoBundleLazy 'tsukkee/unite-tag',
\ {'autoload':{'on_source':'unite.vim'}}
endif
" ]]]
" Web 开发 [[[3
if count(s:plugin_groups, 'web')
NeoBundleLazy 'heracek/HTML-AutoCloseTag',
\ {'autoload':{'filetypes':['html', 'xml']}}
NeoBundleLazy 'ap/vim-css-color',
\ {'autoload':{'filetypes':[
\ 'css',
\ 'scss',
\ 'sass',
\ 'less'
\ ]}}
NeoBundleLazy 'ariutta/Css-Pretty',
\ {'autoload':{
\ 'commands':'Csspretty',
\ 'filetypes':['css']
\ }}
NeoBundleLazy 'cakebaker/scss-syntax.vim',
\ {'autoload':{'filetypes':[
\ 'sass',
\ 'scss'
\ ]}}
NeoBundleLazy 'chr4/nginx.vim',
\ {'autoload':{'filetypes':['nginx']}}
" 避免 CSS3 高亮问题
NeoBundleLazy 'hail2u/vim-css3-syntax',
\ {'autoload':{'filetypes':[
\ 'css',
\ 'sass',
\ 'scss'
\ ]}}
NeoBundleLazy 'gregsexton/MatchTag',
\ {'autoload':{'filetypes':[
\ 'html',
\ 'javascript.jsx',
\ 'xml',
\ 'xsl'
\ ]}}
" Emmet -- 用于快速编辑 HTML 文件
NeoBundleLazy 'mattn/emmet-vim',
\ {'autoload':{'filetypes':[
\ 'css',
\ 'handlebars',
\ 'html',
\ 'less',
\ 'mustache',
\ 'sass',
\ 'scss',
\ 'xml',
\ 'xsd',
\ 'xsl',
\ 'xslt'
\ ]}}
NeoBundleLazy 'othree/html5.vim',
\ {'autoload':{'filetypes':['html']}}
NeoBundleLazy 'othree/html5-syntax.vim',
\ {'autoload':{'filetypes':['html']}}