-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.vimrc
More file actions
1950 lines (1671 loc) · 66.1 KB
/
.vimrc
File metadata and controls
1950 lines (1671 loc) · 66.1 KB
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
" User definitions ==========================================================
scriptencoding utf-8
"set encoding=utf-8
"set termencoding=utf-8
""设置中文环境
"if has("unix")
" lan zh_CN.UTF-8
"else
" lan Chinese_China
"endif
"lan mes zh_CN.UTF-8
if $TERM=='cygwin'
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
set encoding=utf8
set nobackup
set wildmenu
set expandtab
set tabstop=2
set shiftwidth=2
set scrolloff=5
set completeopt=menu
set tags+=/share/ctags/.tags
colorscheme desert256
let OmniCpp_MayCompleteScope = 1
let OmniCpp_ShowPrototypeInAbbr = 1
map <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
map <Esc>[7~ <Home>
map <Esc>[8~ <End>
imap <Esc>[7~ <Home>
imap <Esc>[8~ <End>
finish
endif
" Indert empty Line here
" http://stackoverflow.com/questions/598113/can-terminals-detect-shift-enter-or-control-enter
" 这里提到,可以先在终端中的vim,实验插入模式,实际插入的字符是上面(先按<C-V>转义)
" 然后,用实际输出字符,替换"失灵"快捷键设置即可;
if !has('gui_running')
vnoremap y "+y
endif
let mapleader = ","
" Vundle stuffes {{{1
" vundle 2015-04-29
set nocompatible " be iMproved, required
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle
" required!
Plugin 'sarrow104/Vundle.vim'
" Sample:
" Plugin 'L9' " plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'tpope/vim-fugitive' " plugin on GitHub repo
" Plugin 'git://git.wincent.com/command-t.git' " Git plugin not hosted on GitHub
" Plugin 'file:///home/gmarik/path/to/plugin' " git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} " The sparkup vim script is in a subdirectory of this repo called vim.
" " Pass the path to set the runtimepath properly.
" Plugin 'user/L9', {'name': 'newL9'} " Avoid a name conflict with L9
" sematic-utils
Plugin 'davidhalter/jedi-vim' " for python3
Plugin 'Valloric/YouCompleteMe' " for python2
Plugin 'Valloric/ListToggle'
Plugin 'scrooloose/syntastic'
Plugin 'valloric/MatchTagAlways'
Plugin 'majutsushi/tagbar'
" golang
Plugin 'fatih/vim-go.git' " https://github.com/fatih/vim-go.git
" Lua support
Plugin 'tbastos/vim-lua' " https://github.com/tbastos/vim-lua
Plugin 'xolox/vim-lua-ftplugin' " https://github.com/xolox/vim-lua-ftplugin
" Refactor for C, C++, Java, Pascal, VimL.
Plugin 'LucHermitte/lh-vim-lib'
Plugin 'LucHermitte/lh-tags'
Plugin 'LucHermitte/lh-dev'
"Plugin 'LucHermitte/lh-brackets' " NOTE: 定义了 '' 这种扩单引号的快捷键,与系统自带的回退编辑点功能冲突
Plugin 'LucHermitte/vim-refactor'
"" vimshell+vimproc
Plugin 'Shougo/vimshell.vim' " need 'Shougo/vimproc.vim'
" Emmet - zencoding
Plugin 'mattn/emmet-vim'
" Track the engine.
Plugin 'SirVer/ultisnips'
" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'
" gdb with vim
Plugin 'Shougo/vimproc.vim' " https://github.com/Shougo/vimproc.vim
Plugin 'idanarye/vim-vebugger' " https://github.com/idanarye/vim-vebugger
"Plugin 'myusuf3/numbers.vim' " https://github.com/myusuf3/numbers.vim
Plugin 'sarrow104/numbers.vim' " https://github.com/sarrow104/numbers.vim
" NOTE: 这是备份自
" https://github.com/lilydjwg/dotvim/blob/master/plugin/escalt.vim
Plugin 'WinterXMQ/escalt.vim' " https://github.com/WinterXMQ/escalt.vim
" text UML preview tool
Plugin 'scrooloose/vim-slumlord' " https://github.com/scrooloose/vim-slumlord
" my-scripts
Plugin 'sarrow104/util.vim.git' " util#MySys()
Plugin 'sarrow104/msg.vim.git' " msg#xxx()
Plugin 'sarrow104/font.vim'
Plugin 'sarrow104/include-complete.vim.git'
Plugin 'sarrow104/index.vim'
Plugin 'sarrow104/fencview.vim.git' "github上原本是vim-scripts管理,不知道为什么失效了,我只能自己创建一个了
Plugin 'sarrow104/toggle.vim.git'
Plugin 'sarrow104/txt.vim.git'
Plugin 'sarrow104/system.vim.git'
Plugin 'sarrow104/pairpunct.vim.git'
Plugin 'sarrow104/make.vim.git'
Plugin 'sarrow104/tags.vim.git'
Plugin 'sarrow104/gensketch.vim.git'
Plugin 'sarrow104/simple-cmake.vim.git'
Plugin 'sarrow104/vimlang_jump' " https://github.com/sarrow104/vimlang_jump
" colorscheme & syntax highlighting
Plugin 'kelan/gyp.vim' " https://github.com/kelan/gyp.vim
Plugin 'tomasr/molokai.git' " https://github.com/tomasr/molokai.git
Plugin 'mhartington/oceanic-next'
Plugin 'Yggdroot/indentLine' " 显示代码缩进级别的插件;需要随时计算,可能有些慢
Plugin 'Raimondi/delimitMate'
Plugin 'andrwb/vim-lapis256'
Plugin 'vim-jp/vim-cpp.git' " not so usefull. sad
Plugin 'ArkBriar/vim-qmake' " .pro
" Plugin 'jalcine/cmake.vim'
Plugin 'richq/vim-cmake-completion' " TODO 增加 CMAKE_xxx <c-x><c-k>补全
Plugin 'vim-scripts/JavaScript-Indent'
Plugin 'evanmiller/nginx-vim-syntax'
Plugin 'hail2u/vim-css3-syntax'
Plugin 'plasticboy/vim-markdown'
" NOTE:
" 下面这个插件,使用不当,容易系统卡死;所以……
"Plugin 'suan/vim-instant-markdown' " preview at realtime this need a globle nodejs plugin
" Plugin 'jansenm/vim-cmake' " depends on -> neocompletecache not so good
" utility tools
"Plugin 'Chiel92/vim-autoformat' " https://github.com/Chiel92/vim-autoformat
Plugin 'rhysd/vim-clang-format' " https://github.com/rhysd/vim-clang-format
Plugin 'vim-utils/vim-man' " https://github.com/vim-utils/vim-man
" NOTE: need SQL-workbench/J ultily
"Plugin 'cosminadrianpopescu/vim-sql-workbench' " https://github.com/cosminadrianpopescu/vim-sql-workbench
Plugin 'vim-scripts/dbext.vim' " https://github.com/vim-scripts/dbext.vim
Plugin 'vim-scripts/SQLComplete.vim' " https://github.com/vim-scripts/SQLComplete.vim
Plugin 'scrooloose/nerdtree'
Plugin 'Xuyuanp/nerdtree-git-plugin' " https://github.com/Xuyuanp/nerdtree-git-plugin
Plugin 'tpope/vim-fugitive' " https://github.com/tpope/vim-fugitive
Plugin 'Shougo/unite.vim' " needed by vimfiler
Plugin 'Shougo/vimfiler.vim' " :VimFiler vim-text style explorer
" Buffer and status line
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
"Plugin 'dyng/ctrlsf.vim' " Search tool; using ack, ag or pt
Plugin 'sarrow104/ctrlsf.vim' "https://github.com/sarrow104/ctrlsf.vim.git
Plugin 'hynek/vim-python-pep8-indent' " Pythonindent 2016-05-22
Plugin 'terryma/vim-multiple-cursors'
Plugin 'lilydjwg/fcitx.vim.git'
Plugin 'vim-scripts/mru.vim.git'
Plugin 'dimasg/vim-mark'
" needed by vim-session
Plugin 'xolox/vim-misc'
" 支持 NERDTree 恢复的session管理工具
Plugin 'xolox/vim-session'
Plugin 'junegunn/vim-easy-align.git'
Plugin 'godlygeek/tabular'
Plugin 'qpkorr/vim-renamer'
Plugin 'Kris2k/A.vim'
Plugin 'vim-scripts/doxygen-support.vim'
Plugin 'vim-scripts/DoxygenToolkit.vim'
Plugin 'edsono/vim-matchit' " enhenced noremap %
Plugin 'jlanzarotta/bufexplorer'
Plugin 'tpope/vim-speeddating' " https://github.com/tpope/vim-speeddating.git
Plugin 'aur-archive/vim-stlrefvim' " https://github.com/aur-archive/vim-stlrefvim
Plugin 'vim-scripts/CRefVim' " https://github.com/vim-scripts/CRefVim
Plugin 'easymotion/vim-easymotion' " 类似浏览器alt + 数字 调整到具体widget的快速跳转功能
Plugin 'will133/vim-dirdiff' " 目录比较工具
" https://github.com/Chiel92/vim-autoformat
" Unknown
Plugin 'ashisha/image.vim' " what for ?
"Plugin 'marijnh/tern_for_vim'
" ctrlp file serching tool
" Plugin 'kien/ctrlp.vim'
Plugin 'ctrlpvim/ctrlp.vim'
if has('gui_running') "|| 1
" utility tools devicons must the last!
Plugin 'ryanoasis/vim-devicons' " Powerline(air-line), Nerd Font
endif
" @ Plugin --- [ Code Sreach ]
Plugin 'rking/ag.vim'
"Plugin 'mileszs/ack.vim'
"Plugin 'junegunn/limelight.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"""""""""""""""""""""""""""""""""""""""""""""}}}
" 'vim-utils/vim-man' " https://github.com/vim-utils/vim-man {{{1
if globpath(&rtp, 'plugin/man.vim') != ""
" - open man page for word under cursor in a horizontal split
map <leader>M <Plug>(Man)
" - open man page for word under cursor in a vertical split
map <leader>V <Plug>(Vman)
endif
" 'Chiel92/vim-autoformat' " https://github.com/Chiel92/vim-autoformat {{{1
if globpath(&rtp, 'plugin/autoformat.vim') != ""
let g:formatterpath = ['/usr/bin/clang-format-3.8']
endif
" 'rhysd/vim-clang-format' "https://github.com/rhysd/vim-clang-format {{{1
if globpath(&rtp, 'plugin/clang_format.vim') != ""
let g:clang_format#command='/usr/bin/clang-format-3.8'
"let g:clang_format#extra_args=''
"let g:clang_format#detect_style_file='.clang-format'
let g:clang_format#auto_format=0
let g:clang_format#auto_format_on_insert_leave=0
let g:clang_format#auto_formatexpr=1
" When the value is 1, formatexpr option is set by vim-clang-format
" automatically in C, C++ and ObjC codes. Vim's format mappings (e.g. gq) get to
" use clang-format to format. This option is not comptabile with Vim's textwidth
" feature. You must set textwidth to 0 when the formatexpr is set.
set textwidth=0
" You must set textwidth to 0 when the formatexpr is set.
let g:clang_format#code_style='google' " possible value list [llvm, google, chromium, mozilla]
let g:clang_format#style_options = {
\ "AccessModifierOffset" : -4,
\ "AllowShortIfStatementsOnASingleLine" : "true",
\ "AlwaysBreakTemplateDeclarations" : "true",
\ "Standard" : "C++11",
\ "BreakBeforeBraces" : "Stroustrup"}
" map to <Leader>cf in C++ code
autocmd FileType c,cpp,objc nnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
autocmd FileType c,cpp,objc vnoremap <buffer><Leader>cf :ClangFormat<CR>
"autocmd FileType c,cpp,objc nnoremap <buffer>= :<C-u>ClangFormat<CR>
"autocmd FileType c,cpp,objc vnoremap <buffer>= :ClangFormat<CR>
" if you install vim-operator-user
"autocmd FileType c,cpp,objc map <buffer><Leader>x <Plug>(operator-clang-format)
" Toggle auto formatting:
"nmap <Leader>C :ClangFormatAutoToggle<CR>
endif
" dimasg/vim-mark " {{{1
if globpath(&rtp, 'plugin/ctrlsf.vim') != "" && !globpath(&rtp, 'plugin/mark.vim') != ""
nmap <unique> <Leader>m/ <Plug>MarkSearchAnyNext
nmap <unique> <Leader>m? <Plug>MarkSearchAnyPrev
endif
" dyng/ctrlsf.vim " Search tool; using ack, ag or pt {{{1
" NOTE: 不知道怎么回事,
" noremap <C-/> 竟然无法使用!(<C-1>也不行;<C-a>可行);执行 :normal <C-/>
" 也不行!
" 奇葩的是,execute "normal \<C-/>" 这样手动调用,就可以了?
" 调用的,竟然是 'easymotion/vim-easymotion' 的 / 动作!
" 注意 <A-/> 在终端,貌似是无法触发的……
"
" 原来,vim无法将 <C-/>用作快捷键;
" http://vim.1045645.n5.nabble.com/How-to-map-Ctrl-td1192843.html
"
" 另外一个印证:
" i_<C-V>_<C-/> 将得到的是 /;即,仍然触发 / 动作。
" 有解决办法不?
"
" https://groups.google.com/forum/#!topic/vim_use/ypPtU10KObA
"
" 另外,用<C-_>来替换 <C-/> 只在某些情况(终端)下有效。
" http://stackoverflow.com/questions/9051837/how-to-map-c-to-toggle-comments-in-vim
"
" TODO 应该对查找的发生位置,设定一个保险——避免在根目录、home目录进行查找!
if globpath(&rtp, 'plugin/ctrlsf.vim') != ""
noremap <leader>/ :silent execute("CtrlSF -w " . expand("<cword>"))<CR>
endif
" fatih/vim-go.git " https://github.com/fatih/vim-go.git {{{1
if globpath(&rtp, 'plugin/go.vim') != ""
let g:go_disable_autoinstall = 0
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
endif
" 'xolox/vim-lua-ftplugin' " {{{1
if globpath(&rtp, 'plugin/lua-ftplugin.vim') != ""
let g:lua_complete_omni = 1
" Here's the black list:
let g:lua_omni_blacklist = ['pl\.strict', 'lgi\..']
"" Here's the resulting regular expression pattern:
"'^\(pl\.strict\|lgi\..\)$'
endif
" 'majutsushi/tagbar' " {{{1
" ctags-exuberant
"let g:tagbar_type_go = {
" \ 'ctagstype': 'go',
" \ 'kinds' : [
" \'p:package',
" \'f:function',
" \'v:variables',
" \'t:type',
" \'c:const'
" \]
"\}
" gotags
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : '$GOPATH/bin/gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" 'myusuf3/numbers.vim' " {{{1
if globpath(&rtp, 'plugin/numbers.vim') != ""
let g:numbers_exclude = ['unite', 'tagbar', 'startify', 'gundo', 'vimshell', 'w3m', 'nerdtree', 'man', 'help', 'vim']
endif
" 'idanarye/vim-vebugger' {{{1
if globpath(&rtp, 'plugin/vebugger.vim') != ""
let g:vebugger_view_source_cmd='edit'
let g:vebugger_leader='<Leader>x'
command! -nargs=+ -complete=file GDB call vebugger#gdb#start([<f-args>][0], {'args':[<f-args>][1:]})
" i |:VBGstepIn|
" o |:VBGstepOver|
" O |:VBGstepOut|
" c |:VBGcontinue|
"
" b |:VBGtoggleBreakpointThisLine|
" B |:VBGclearBreakpoints|
"
" e |:VBGevalWordUnderCursor| in normal mode
" |:VBGevalSelectedText| in select mode
" E Prompt for an argument for |:VBGeval|
"
" x |:VBGexecute| current line in normal mode.
" |:VBGexecuteSelectedText| in select mode
" X Prompt for an argument for |:VBGexecute|
"
" t |:VBGtoggleTerminalBuffer|
" r Select mode only - |:VBGrawWriteSelectedText|
" R Prompt for an argument for |:VBGrawWrite|
endif
" 'davidhalter/jedi-vim' {{{1
if globpath(&rtp, 'plugin/jedi.vim') != ""
" disable auto-initialization
" let g:jedi#auto_initialization = 0
" disable VIM options auto-initialization
" let g:jedi#auto_vim_configuration = 0
" "left", "right", "top", "bottom" or "winwidth". It will decide the
" direction where the split open.
let g:jedi#use_splits_not_buffers = "left"
" disable ...
" let g:jedi#popup_on_dot = 0
" Jedi displays function call signatures in insert mode in real-time,
" highlighting the current argument. The call signatures can be displayed
" as a pop-up in the buffer (set to 1, the default), which has the
" advantage of being easier to refer to, or in Vim's command line aligned
" with the function call (set to 2), which can improve the integrity of
" Vim's undo history.
let g:jedi#show_call_signatures = "1"
" Here are a few more defaults for actions, read the docs (:help jedi-vim)
" to get more information. If you set them to "", they are not assigned.
"let g:jedi#goto_command = "<leader>d"
"let g:jedi#goto_assignments_command = "<leader>g"
"let g:jedi#goto_definitions_command = ""
"let g:jedi#documentation_command = "K"
"let g:jedi#usages_command = "<leader>n"
"let g:jedi#completions_command = "<C-Space>"
"let g:jedi#rename_command = "<leader>r"
endif
" YouCompleteMe {{{1
if globpath(&rtp, 'plugin/youcompleteme.vim') != ""
" FIXME
" ycm的跳转有bug!
" GoToDeclaration GoToDefinition
"
" 当同一个源文件,有两个类,并且有同名的方法的时候,上面的这种跳转可能会识别到不同类的方法名上面去!
nnoremap <C-F5> :YcmForceCompileAndDiagnostics<CR>
nnoremap <C-F4> :YcmDiags<CR>
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
" NOTE:,某些语言,比如golang,并不支持下面这个命令!(golang import
" 的是文件夹,而不是某特定的文件……)
nnoremap <leader>go :YcmCompleter GoToInclude<CR>
" NOTE: 仅支持 'c, cpp, objc, objcpp, cs, python, typescript, javascript'
" - The type or declaration of identifier,
" - Doxygen/javadoc comments,
" - Python docstrings,
nnoremap <leader>gd :YcmCompleter GetDoc<CR>
" NOTE: 以command-line message的方式,显示当前标识符的具体类型
nnoremap <leader>gt :YcmCompleter GetType<CR>
nnoremap <leader>gL :split<bar>YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gF :split<bar>YcmCompleter GoToDefinition<CR>
nnoremap <leader>gG :split<bar>YcmCompleter GoToDefinitionElseDeclaration<CR>
nnoremap <leader>gO :split<bar>YcmCompleter GoToInclude<CR>
" NOTE: 参考自 https://github.com/kun945/vim-ide-for-windows
" 2016-09-20
vnoremap <leader>gg y:YcmCompleter GoToDefinitionElseDeclaration <C-R>"<CR><CR>
vnoremap <leader>gG y:split<bar>YcmCompleter GoToDefinitionElseDeclaration <C-R>"<CR><CR>
" let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_global_ycm_extra_conf = '~/.vim/ycm/cpp/.ycm_extra_conf.py'
let g:ycm_error_symbol = '>>'
let g:ycm_warning_symbol = '>*'
let g:ycm_filetype_blacklist = {
\ 'tagbar' : 1,
\ 'qf' : 1,
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'unite' : 1,
\ 'text' : 1,
\ 'vimwiki' : 1,
\ 'pandoc' : 1,
\ 'infolog' : 1,
\ 'mail' : 1,
\ 'mundo': 1,
\ 'fzf': 1,
\ 'ctrlp' : 1,
\ 'vim' : 1,
\ 'make': 1,
\ 'ctrlsf': 1
\}
" 补全按键,YCM默认是'<C-Space>'
let g:ycm_key_invoke_completion = '<C-j>'
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
"Do not ask when starting vim
let g:ycm_confirm_extra_conf = 0
"let g:ycm_autoclose_preview_window_after_completion=1
let g:syntastic_always_populate_loc_list = 1
" make YCM read identifiers from my tags files
let g:ycm_collect_identifiers_from_tags_files = 1
command! -nargs=0 GenYcmConfig call writefile(readfile(expand(g:ycm_global_ycm_extra_conf), 'b'), getcwd()."/.ycm_extra_conf.py", 'b')
let g:ycm_python_binary_path = '/usr/bin/python3'
" This forces YCM to use Jedi with Python3 (default is to use Jedi with the
" same Python interpreter that is used by the ycmd server, which is Python2).
"
" This works no matter if your Vim is compiled with or without the +python3
" flag - you get Python3 autocompletion (and documentation look up and more).
" jedi-vim works fine for me now with +python3 support in vim. In added the following option to my .vimrc: let g:jedi#force_py_version = 3.
" http://vi.stackexchange.com/questions/2403/vim-code-completion-for-python-3
" $ pacman -S vim-jedi
" NOTE:
" 前后跳转,使用 <C-o> 和 <C-i>
" TODO
" 如何保证,在弹出补全窗口,或者无法补全的时候,<C-u>仍然可以删除之前的字符?
" exe 'inoremap <expr>' . key .
" \ ' pumvisible() ? "\<C-p>" : "\' . key .'"'
endif
" Yggdroot/indentLine ----------------------------------------------------------{{{1
if globpath(&rtp, 'plugin/indentLine.vim') != ""
" NOTE: 缩进级别计算的语言类型,最好限制为程序语言,特别是一行不长的
let g:indentLine_fileType = ['c', 'cpp', 'vim']
let g:indentLine_bufNameExclude = ['_.*', 'NERD_tree.*']
endif
" DoxygenToolkit ---------------------------------------------------------------{{{1
if globpath(&rtp, 'plugin/DoxygenToolkit.vim') != ""
let g:DoxygenToolkit_authorName="sarrow, 549506937@qq.com"
let s:licenseTag = "Copyright(C)\<enter>"
let s:licenseTag = s:licenseTag . "For free\<enter>"
let s:licenseTag = s:licenseTag . "All right reserved\<enter>"
let g:DoxygenToolkit_licenseTag = s:licenseTag
let g:DoxygenToolkit_briefTag_funcName="yes"
let g:doxygen_enhanced_color=1
let g:DoxygenToolkit_commentType="Qt"
endif
" vim-devicons -------------------------------------------{{{1
if globpath(&rtp, 'plugin/webdevicons.vim') != ""
"set guifont=Droid\ Sans\ Mono\ for\ Powerline\ Nerd\ Font\ Complete\ 11
"set guifont=Droid\ Sans\ Mono\ for\ Powerline\ Plus\ Nerd\ File\ Types\ 11
let g:WebDevIconsNerdTreeAfterGlyphPadding = ''
"let g:WebDevIconsUnicodeGlyphDoubleWidth = 1
"let g:webdevicons_conceal_nerdtree_brackets = 1
"let g:WebDevIconsNerdTreeGitPluginForceVAlign = 0
"set encoding=utf-8
endif
" vim-airline new 2016-07-14---------------------------------------------------------------{{{1
if globpath(&rtp, 'plugin/airline.vim') != ""
let g:airline_theme="badwolf"
let g:airline_powerline_fonts = 1
"let g:airline_section_b = '%{strftime("%c")}'
"let g:airline_section_y = 'BN: %{bufnr("%")}'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
" new 2016-07-14
endif
" vim-airline old 2016-07-14---------------------------------------------------------------{{{1
" let g:airline#extensions#tabline#enabled = 1
" set hidden
" let g:airline#extensions#tabline#fnamemod = ':t'
" let g:airline#extensions#tabline#show_tab_nr = 1
" "let g:airline_powerline_fonts = 1
" "let g:airline_theme='oceanicnext'
" cnoreabbrev <expr> x getcmdtype() == ":" && getcmdline() == 'x' ? 'Sayonara' : 'x'
" " tmap is not vim command?
" "tmap <leader>x <c-\><c-n>:bp! <BAR> bd! #<CR>
" nmap <leader>t :term<cr>
" nmap <leader>, :bnext<CR>
" "tmap <leader>, <C-\><C-n>:bnext<cr>
" nmap <leader>. :bprevious<CR>
" "tmap <leader>. <C-\><C-n>:bprevious<CR>
" let g:airline#extensions#tabline#buffer_idx_mode = 1
" nmap <leader>1 <Plug>AirlineSelectTab1
" nmap <leader>2 <Plug>AirlineSelectTab2
" nmap <leader>3 <Plug>AirlineSelectTab3
" nmap <leader>4 <Plug>AirlineSelectTab4
" nmap <leader>5 <Plug>AirlineSelectTab5
" nmap <leader>6 <Plug>AirlineSelectTab6
" nmap <leader>7 <Plug>AirlineSelectTab7
" nmap <leader>8 <Plug>AirlineSelectTab8
" nmap <leader>9 <Plug>AirlineSelectTab9
" old 2016-07-14
"if !exists('g:airline_symbols')
" let g:airline_symbols = {}
"endif
"" unicode symbols
"let g:airline_left_sep = '»'
"let g:airline_left_sep = '▶'
"let g:airline_right_sep = '«'
"let g:airline_right_sep = '◀'
"let g:airline_symbols.crypt = '🔒'
"let g:airline_symbols.linenr = '␊'
"let g:airline_symbols.linenr = ''
"let g:airline_symbols.linenr = '¶'
"let g:airline_symbols.branch = '⎇'
"let g:airline_symbols.paste = 'ρ'
"let g:airline_symbols.paste = 'Þ'
"let g:airline_symbols.paste = '∥'
"let g:airline_symbols.whitespace = 'Ξ'
" set statusline=%f%m\ \[%{&ff}:%{&fenc}:%Y]\ %{pathshorten(simplify(getcwd()))}%=(0x%B)(%L\|%c%V)%P%<
""}}}
" 'ctrlpvim/ctrlp.vim' {{{1
if globpath(&rtp, 'plugin/ctrlp.vim') != ""
noremap <leader>ct :CtrlPTag<CR>
endif
" UltiSnips " {{{1
if globpath(&rtp, 'plugin/UltiSnips.vim') != ""
"let g:UltiSnipsJumpForwardTrigger="<c-j>"
"let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsEditSplit="context"
let g:UltiSnipsSnippetsDir="~/.vim/UltiSnips"
let g:UltiSnipsListSnippets="<c-e>"
endif
" delimitMate " {{{1
if globpath(&rtp, 'plugin/delimitMate.vim') != ""
" disable delimitMate
let loaded_delimitMate = 1
au FileType text let b:loaded_delimitMate = 1
endif
" NERDTree ------------------------------------------------------------------{{{1
if globpath(&rtp, 'plugin/NERD_tree.vim') != ""
map <C-\> :NERDTreeToggle<CR>
noremap <F4> :NERDTreeFind<CR>
autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
"let NERDTreeShowHidden=1
let g:NERDTreeWinSize=24
let g:NERDTreeAutoDeleteBuffer=1
let g:NERDTreeCascadeOpenSingleChildDir=0
command -nargs=0 NERDTreeHere silent execute 'NERDTree '.expand("%:h")
"" NERDTress File highlighting
" function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
" exec 'autocmd FileType nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
" exec 'autocmd FileType nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
" endfunction
"
" call NERDTreeHighlightFile('jade', 'green', 'none', 'green', 'none')
" call NERDTreeHighlightFile('md', 'blue', 'none', '#6699CC', 'none')
" call NERDTreeHighlightFile('config', 'yellow', 'none', '#d8a235', 'none')
" call NERDTreeHighlightFile('conf', 'yellow', 'none', '#d8a235', 'none')
" call NERDTreeHighlightFile('json', 'green', 'none', '#d8a235', 'none')
" call NERDTreeHighlightFile('html', 'yellow', 'none', '#d8a235', 'none')
" call NERDTreeHighlightFile('css', 'cyan', 'none', '#5486C0', 'none')
" call NERDTreeHighlightFile('scss', 'cyan', 'none', '#5486C0', 'none')
" call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', 'none')
" call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', 'none')
" call NERDTreeHighlightFile('ts', 'Blue', 'none', '#6699cc', 'none')
" call NERDTreeHighlightFile('ds_store', 'Gray', 'none', '#686868', 'none')
" call NERDTreeHighlightFile('gitconfig', 'black', 'none', '#686868', 'none')
" call NERDTreeHighlightFile('gitignore', 'Gray', 'none', '#7F7F7F', 'none')
endif
" 'Xuyuanp/nerdtree-git-plugin' " {{{1
if globpath(&rtp, 'plugin/NERD_tree.vim') != "" && globpath(&rtp, 'nerdtree_plugin/git_status.vim') != ""
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ "Unknown" : "?"
\ }
endif
" 'tpope/vim-fugitive' " {{{1
if globpath(&rtp, 'plugin/fugitive.vim') != ""
" TODO
" Add %{fugitive#statusline()} to 'statusline' to get an indicator with the current branch in (surprise!) your statusline.
endif
" 'Shougo/vimfiler.vim' " {{{1
if globpath(&rtp, 'plugin/vimfiler.vim') != ""
let g:vimfiler_as_default_explorer = 1
endif
"suan/vim-instant-markdown {{{1
" let g:instant_markdown_slow = 1
"
" https://github.com/vim-scripts/doxygen-support.vim {{{1
if globpath(&rtp, 'plugin/doxygen-support.vim') != ""
let g:load_doxygen_syntax=1
endif
" MatchTagAlways {{{1
if globpath(&rtp, 'plugin/MatchTagAlways.vim') != ""
let g:mta_use_matchparen_group = 1 " default : 1
" default: { 'html' : 1, 'xhtml' : 1, 'xml' : 1, 'jinja' : 1 }
let g:mta_filetypes = {
\ 'html' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\ 'jinja' : 1,
\}
let g:mta_use_matchparen_group = 1 " default: 1
let g:mta_set_default_matchtag_color = 1 " default : 1
nnoremap <leader>% :MtaJumpToOtherTag<cr>
endif
" EasyMotion {{{1
if globpath(&rtp, 'plugin/EasyMotion.vim') != ""
let g:EasyMotion_skipfoldedline = 0
" https://github.com/easymotion/vim-easymotion/issues/223
" There are option named :h <Over>(em-openallfold) which open all fold when searching. I guess it helps this problem.
" 但是,上面这个选项,如何使用?
" <Leader>f{char} to move to {char}
map <Leader>f <Plug>(easymotion-bd-f)
nmap <Leader>f <Plug>(easymotion-overwin-f)
" s{char}{char} to move to {char}{char}
nmap <Leader>s <Plug>(easymotion-overwin-f2)
" Move to line
map <Leader>L <Plug>(easymotion-bd-jk)
nmap <Leader>L <Plug>(easymotion-overwin-line)
" Move to word
map <Leader>w <Plug>(easymotion-bd-w)
nmap <Leader>w <Plug>(easymotion-overwin-w)
" Gif config
"noremap / <Plug>(easymotion-sn)
"omap / <Plug>(easymotion-sn)
" Old:
" map / <Plug>(easymotion-sn)
" omap / <Plug>(easymotion-tn)
" " These `n` & `N` mappings are options. You do not have to map `n` & `N` to EasyMotion.
" " Without these mappings, `n` & `N` works fine. (These mappings just provide
" " different highlight method and have some other features )
" map n <Plug>(easymotion-next)
" map N <Plug>(easymotion-prev)
map <Leader>w <Plug>(easymotion-iskeyword-w)
map <Leader>b <Plug>(easymotion-iskeyword-b)
" Gif config
"map <Leader>l <Plug>(easymotion-lineforward) " 与ycm的语法错误列表冲突
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
map <Leader>h <Plug>(easymotion-linebackward)
"noremap ** :execute 'normal /'.expand("<cword>").'\<CR>\<CR>'
" NOTE: 为了 避免和 vim-mark 冲突,这里使用双写的办法……
"noremap ** /=expand("<cword>")<CR><CR>
"noremap ## ?=expand("<cword>")<CR><CR>
let g:EasyMotion_startofline = 0 " keep cursor column when JK motion
endif
" junegunn/vim-easy-align {{{1
if globpath(&rtp, 'plugin/easy_align.vim') != ""
"xmap <leader>ga <Plug>(EasyAlign)
vnoremap ga <Plug>(EasyAlign)
endif
" 'xolox/vim-session' {{{1
if globpath(&rtp, 'plugin/session.vim') != ""
if globpath(&rtp, 'plugin/NERD_tree.vim') != ""
command! -nargs=0 SessionList :NERDTree ~/.vim/sessions
endif
endif
" https://github.com/ArkBriar/vim-qmake .pro " {{{1
if globpath(&rtp, 'syntax/qmake.vim') != ""
au BufRead *.qrc setfiletype xml
au BufRead *.pro setfiletype qmake
endif
" doxygensupport {{{1
let g:Doxy_GlobalTemplateFile = '~/.vim/bundle/doxygen-support.vim/doxygen-support/templates/doxygen.templates'
"}}}
" Global setting {{{1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 2014-12-20 mksession ~/xxx.vim {{{2
set number
set relativenumber
set sessionoptions+=curdir
" NOTE: 2016-09-05
set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:p:~\")})%)%(\ %a%)\ -\ %{v:servername}\ %{v:this_session!=\"\"?fnamemodify(v:this_session,\":p:~\"):\"\"}
" NOTE mks 后面的字符串,不能以"括起来——mks会认为后面是注释,而使用
" Session.vim……
function MakeSession(session_name)
let l:session_name = (v:this_session == '' ? '~/last.vim' : v:this_session)
if a:session_name != ''
let l:session_name = '~/' . a:session_name . '.vim'
endif
" Sarrow: 2016-07-14
" 由于 mks 和 NERDTree 不搭:
"" https://github.com/jistr/vim-nerdtree-tabs/issues/65
tablast
while 1
silent execute ' NERDTreeClose'
if tabpagenr() == 1
break
endif
tabprevious
endwhile
silent execute ' mks! ' . l:session_name
endfunction
function MakeSesionInfo()
execute 'echomsg v:this_session'
endfunction
command! -nargs=? MKS call MakeSession(<q-args>)
" NOTE
" 参考 FontInfo
" ~/Sarrow104@github/vim/font.vim/autoload/font.vim|152
" 貌似只有包装进 function call 之后,echomsg的显示,才会保留在提示栏
"command! -nargs=0 MKSInfo echomsg v:this_session
command! -nargs=0 MKSInfo call MakeSesionInfo()
"command! -nargs=0 MKS silent execute ' mks! '. (v:this_session == '' ? '~/last.vim' : v:this_session) . ''
" mks d:\Program Files\vim\home\problem.vim
if globpath(&rtp, 'plugin/session.vim') != ""
command! -bar -bang -nargs=? -complete=customlist,xolox#session#complete_names_with_suggestions SS call xolox#session#save_cmd(<q-args>, <q-bang>, 'SaveSession')
command! -bar -bang -nargs=? -complete=customlist,xolox#session#complete_names OS call xolox#session#open_cmd(<q-args>, <q-bang>, 'OpenSession')
endif
" 使用英文菜单,工具条及消息提示
set langmenu=none
" NOTE: using :X for prompting to enter an encryption key
if v:version >= 703
set cryptmethod=blowfish
endif
" Sarrow:2011-12-29
set mouse=a " 让vim在终端中也能处理鼠标
" End:
set whichwrap+=<,>,h,l " 跨行首尾,移动光标
set fillchars=vert:\ ,stl:\ ,stlnc:\
set background=dark
set autoindent " Auto-indent on
set tabpagemax=15 " 最多15个标签
set showtabline=1 " 0: noshow tab line; 1: show when 2 or more tabs; 2: always
set hlsearch " High-Light Search on
set noswapfile " No swap file, use memory only
set display=lastline
set wildmode=longest,full " Cmd-line completion
set wildmenu
"" Browse Mode Setting
set nostartofline " Keep cursor column when moving
set showcmd " Show commond line
set cmdheight=1 " lines for command window
"" Status Bar Setting
set laststatus=2 " Always show status line
" Sarrow:2008-11-01,from:http://forum.ubuntu.org.cn/viewtopic.php?f=68&t=159467
"set statusline=%.30f%3m%r%h%w\ [%{&fileformat},%{&fileencoding}]\ [%Y]\ [HEX=\%04.4B]\ [%4l/%L,%3v][%2p%%]
"set statusline=%f%m\ \[%{&ff}:%{&fenc}:%Y]\ %{getcwd()}%=(%b,0x%B)(%l\/%L\|%c%V)%P%<
" 2010-10-31
"set statusline=%f%m\ \[%{&ff}:%{&fenc}:%Y]\ %{pathshorten(simplify(getcwd()))}%=(0x%B)(%L\|%c%V)%P%<
"" Howto Fold text default: start with {{{ end with }}}}
set nofoldenable
set foldmethod=marker " fold method to marker
" set foldmethod=syntax
" set foldlevel=1
"" Inner Search Mode
set incsearch " Increase search ON
"" The <Backspace> Behavior
set backspace=indent,eol,start " Backspace over everyting
"" Maxmum Commands to be saved
set history=50 " Save at most 50 commands
"" GUI Frame Setting
set guioptions-=L " No left hand scrollbars
set guioptions-=r " No right hand scrollbars
set guioptions-=T " No Toolbar
"set guioptions-=m " No menu bar
set autoread " 自动重新加载外部修改内容
"set autochdir " 自动切换当前目录为当前文件所在的目录
set noerrorbells " 去掉恼人的蜂鸣声
"set visualbell t_vb=
set novisualbell t_vb=
set winaltkeys=no
set hidden " allow to cycle and hide modified buffers
if !has('job')
set lazyredraw " [VIM5]; do not update screen while executing macros
endif
" visual-diff
set diffopt=filler,context:5,iwhite
set report=0 " show a report when N lines were changed.
" report=0 thus means "show all changes"!
" set showmatch " Show the matching bracket for the last ')'?
" Suffixes to ignore in file completion
set suffixes=.bak,~,.swp,.o ",.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.cmi,.cmo
"打开拼写检查:
":set spell
"
"关闭拼写检查:
":set nospell
"
"另外还有一些相关的命令:
" ]s : 将光标移到下一个拼写错误处
" [s : 将光标移到上一个拼写错误处
" zg : 将单词加入词典
" zug : 撤销将单词加入词典
" z= : 拼写建议
if &term == "win32" " terminal encoding {{{2
" this is for win32 console only!
set encoding=cp936
else
set encoding=utf-8
endif
"用于新建文件
setglobal fileencoding=chinese " {{{2
"" Multi-encoding setting, MUST BE IN THE BEGINNING OF .vimrc!
" on chinese system, default will expand to cp936 automaticly;
" to edit big5 code file, you must using:
"
" :edit ++enc=cp950 `filename`
"" Fileencodings Priority : ucs-bom, utf-8; 2cd, gbk;
"" NOTE: `bom` is short for Byte Order Mask'
set fileencodings=ucs-bom,utf-8,cp936
set ambiwidth=double
" set ambiwidth=single