-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
executable file
·2343 lines (2005 loc) · 102 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
set nocompatible " disable backwards-compatible with vi
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>"
" autocmd TermOpen term://* startinsert
tnoremap <leader><Esc> <C-\><C-n><C-w><c-w>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" F1-F12 显示方式; 快捷键 F5编译/执行 <Leader>F5执行
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" F1-F12 快捷键
" 代码显示
" <leader>f1 :AsyncTaskLast<cr> <leader><F1> :call asyncrun#quickfix_toggle(6)<cr>
nnoremap <F2> :set nu! nu?<CR> " <leader>f2 :AsyncTaskEdit<cr> <leader><F2> :TagbarToggle<CR>
nnoremap <F3> :set list! list?<CR> " <leader>f3 :AsyncTask FZF-neigh-files<cr> <leader><F3> :NERDTreeRefreshRoot<CR>:NERDTreeToggle<CR>
nnoremap <F4> :set relativenumber! relativenumber?<CR> " <leader>f4 :AsyncTask FZF-root-files<cr> <leader><F4> :VimRegEdit y<CR><CR>
" ccompile <F5> <--> <leader>f5 :AsyncTask file-build<cr>
augroup ccompile
autocmd!
autocmd Filetype c nnoremap <F5> <Esc>:w<CR>:AsyncRun gcc -Wall -Wextra -Wconversion "$(VIM_FILEPATH)" -std=gnu99 -g -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" -pthread -lrt -lm -ljson-c -O1 <CR>
autocmd Filetype cpp nnoremap <F5> <Esc>:w<CR>:AsyncRun g++ "$(VIM_FILEPATH)" -std=c++11 -g -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" -pthread -lrt -lm -O1 -ljson-c <CR>
autocmd Filetype python nnoremap <F5> <Esc>:w<CR>:AsyncRun python "$(VIM_FILEPATH)" <CR>
autocmd Filetype java nnoremap <F5> <Esc>:w<CR>:AsyncRun javac "$(VIM_FILEPATH)" <CR>
autocmd Filetype sh nnoremap <F5> <Esc>:w<CR>:AsyncRun -raw bash "$(VIM_FILEPATH)" <CR>
autocmd Filetype perl nnoremap <F5> <Esc>:w<CR>:AsyncRun -raw perl "$(VIM_FILEPATH)" <CR>
autocmd Filetype lua nnoremap <F5> <Esc>:w<CR>:AsyncRun -raw lua "$(VIM_FILEPATH)" <CR>
autocmd Filetype javascript nnoremap <F5> <Esc>:w<CR>:AsyncRun -raw node "$(VIM_FILEPATH)" <CR>
autocmd Filetype vim nnoremap <F5> <Esc>:w<CR>:source %<CR>
augroup END
autocmd FocusLost * :wa | " 离开Vim编辑器时,自动保存文件
" crun <leader><F5> <--> <leader>f6 :AsyncTask file-run<cr>
augroup crun
autocmd!
autocmd Filetype c nnoremap <leader><F5> <Esc>:AsyncRun gcc -Wall -Wextra -Wconversion "$(VIM_FILEPATH)" -std=gnu99 -g -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" -pthread -lrt -lm -ljson-c -O1; "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" <CR>
autocmd Filetype cpp nnoremap <leader><F5> <Esc>:AsyncRun g++ "$(VIM_FILEPATH)" -std=c++11 -g -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" -pthread -lrt -lm -O1 -ljson-c <CR>
autocmd Filetype java nnoremap <leader><F5> <ESC>:AsyncRun javac %; java %< <CR>
autocmd Filetype sh nnoremap <leader><F5> <Esc>:w<CR>:AsyncRun -mode=term -pos=right bash "$(VIM_FILEPATH)" <CR>
autocmd Filetype perl nnoremap <leader><F5> <Esc>:w<CR>:AsyncRun -mode=term -pos=right perl "$(VIM_FILEPATH)" <CR>
autocmd Filetype lua nnoremap <leader><F5> <Esc>:w<CR>:AsyncRun -mode=term -pos=right lua "$(VIM_FILEPATH)" <CR>
autocmd Filetype javascript nnoremap <leader><F5> <Esc>:w<CR>:AsyncRun -mode=term -pos=right node "$(VIM_FILEPATH)" <CR>
autocmd Filetype vim nnoremap <leader><F5> <Esc>:w<CR>:source %<CR>
augroup END
" redefine F1-F12 hotkey
if filereadable(".vimenv")
source ./.vimenv
nnoremap <c-x><c-k> :CMakeHelpPopup <C-R>=expand("<cword>")<CR><CR> "<c-c> quit popup
endif
" 代码格式化 current buffer or all opened buffer
nnoremap <F6> :FixWhitespace<CR>:Autoformat<CR>:w!<CR>:!dos2unix %<CR>
" npm install --save-dev --save-exact prettier # https://prettier.io/docs/en/install.html
augroup format
autocmd!
autocmd Filetype c nnoremap <F6> :FixWhitespace<CR>:!dos2unix %<CR>:!indent -kr -i4 -ts4 -sob -ss -sc -npsl -pcs -bs -bad -bap --ignore-newlines -l96 -nut -npro -brf %<CR>:%s/\r//ga<CR>
autocmd Filetype perl nnoremap <F6> :FixWhitespace<CR>:!dos2unix %<CR>:!perltidy -i=4 -et=4 -ndsm -st -ce -bar -nola -l=220 %<CR>:%s/\r//ga<CR>
autocmd Filetype cpp nnoremap <F6> :FixWhitespace<CR>:!dos2unix %<CR>:%s/\r//ga<CR>
autocmd Filetype sh nnoremap <F6> :FixWhitespace<CR>:!dos2unix %<CR>:!shfmt -l -w -i 2 -ci %<CR>:%s/\r//ga<CR>
autocmd Filetype c nnoremap twfl :FixWhitespace<CR>:!dos2unix %<CR>:!indent -kr -i4 -ts4 -sob -ss -sc -npsl -pcs -bs --ignore-newlines -l96 -nut -npro -brf %<CR>:%s/\r//ga<CR>
autocmd Filetype perl nnoremap twfl :FixWhitespace<CR>:!dos2unix %<CR>:!perltidy -i=4 -et=4 -ndsm -st -ce -bar -nola -l=220 %<CR>:%s/\r//ga<CR>
autocmd Filetype cpp nnoremap twfl :FixWhitespace<CR>:!dos2unix %<CR>:%s/\r//ga<CR>
autocmd Filetype sh nnoremap twfl :FixWhitespace<CR>:!dos2unix %<CR>:!shfmt -l -w -i 2 -ci %<CR>:%s/\r//ga<CR>
augroup END
augroup format
autocmd!
autocmd Filetype c nnoremap <leader><F6> :bufdo FixWhitespace<CR>:!dos2unix %<CR>:!indent -kr -i4 -ts4 -sob -ss -sc -npsl -pcs -bs -bad -bap --ignore-newlines -l96 -nut -npro -brf %<CR>:%s/\r//ga<CR>
autocmd Filetype perl nnoremap <leader><F6> :bufdo FixWhitespace<CR>:!dos2unix %<CR>:!perltidy -i=4 -et=4 -ndsm -st -ce -bar -nola -l=220 %<CR>:%s/\r//ga<CR>
autocmd Filetype cpp nnoremap <leader><F6> :bufdo FixWhitespace<CR>:!dos2unix %<CR>:%s/\r//ga<CR>
autocmd Filetype sh nnoremap <leader><F6> :bufdo FixWhitespace<CR>:!dos2unix %<CR>:!shfmt -l -w -i 2 -ci %<CR>:%s/\r//ga<CR>
autocmd Filetype c nnoremap twfl :FixWhitespace<CR>:!dos2unix %<CR>:!indent -kr -i4 -ts4 -sob -ss -sc -npsl -pcs -bs --ignore-newlines -l96 -nut -npro -brf %<CR>:%s/\r//ga<CR>
autocmd Filetype perl nnoremap twfl :FixWhitespace<CR>:!dos2unix %<CR>:!perltidy -i=4 -et=4 -ndsm -st -ce -bar -nola -l=220 %<CR>:%s/\r//ga<CR>
autocmd Filetype cpp nnoremap twfl :FixWhitespace<CR>:!dos2unix %<CR>:%s/\r//ga<CR>
autocmd Filetype sh nnoremap twfl :FixWhitespace<CR>:!dos2unix %<CR>:!shfmt -l -w -i 2 -ci %<CR>:%s/\r//ga<CR>
augroup END
" 静态代码扫描 current buffer or all opened buffer
" nnoremap <leader><F7> :bufdo SyntasticToggleMode<CR><CR>
augroup format
autocmd!
autocmd Filetype c nnoremap <F7> :AsyncRun (cppcheck --std=c99 --enable=warning,style -v %)<CR>
autocmd Filetype sh nnoremap <F7> :AsyncRun shellcheck %<CR>
autocmd Filetype perl nnoremap <F7> :AsyncRun perlcritic %<CR>
augroup END
" nnoremap <F7> :SyntasticToggleMode<CR><CR>
augroup format
autocmd!
autocmd Filetype c nnoremap <leader><F7> :bufdo AsyncRun (cppcheck --std=c99 --enable=warning,style -v %)<CR>
autocmd Filetype sh nnoremap <leader><F7> :bufdo AsyncRun shellcheck %<CR>
autocmd Filetype perl nnoremap <leader><F7> :bufdo AsyncRun perlcritic %<CR>
augroup END
" MaximizerToggle Windows or FZF Windows
nnoremap <silent><F8> :MaximizerToggle<CR>
vnoremap <silent><F8> :MaximizerToggle<CR>gv
inoremap <silent><F8> <C-o>:MaximizerToggle<CR>
" FloatermNext or FloatermPrev
nnoremap <F9> :FloatermNext<CR>
tnoremap <F9> <C-\><C-n>:FloatermNext<CR>
nnoremap <leader><F9> :FloatermPrev<CR>
tnoremap <leader><F9> <C-\><C-n>:FloatermPrev<CR>
" FloatermToggle or vim-terminal-help
nnoremap <F10> :FloatermToggle<CR>
tnoremap <F10> <C-\><C-n>:FloatermToggle<CR>
nnoremap <leader><F10> :call TerminalToggle()<CR><CR>
tnoremap <leader><F10> :<c-\><c-n>:call TerminalToggle()<CR><CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" <Leader>F1-F12 插件窗口 快捷键 F5编译/执行 <Leader>F5执行
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 自说明帮助
nnoremap <leader><F1> :call asyncrun#quickfix_toggle(6)<cr>
" 扩展窗口
nnoremap <leader><F2> :TagbarToggle<CR> " :TagbarToggle; :TlistToggle
nnoremap <leader><F3> :NERDTreeRefreshRoot<CR>:NERDTreeToggle<CR> " :WMToggle; :ToggleBufExplorer; :NERDTreeToggle
nnoremap <leader><F4> :VimRegEdit y<CR><CR> " Edit register
" F5 AsyncRun run
" F6 bufdo: format
" F7 static-analysis
tnoremap <leader><F8> <C-\><C-n>:Windows<CR>
nnoremap <leader><F8> :Windows<CR>
" project tags or file tags
nnoremap <leader><F11> :call Gutentags()<cr>
function! g:CscopeDone()
exec "cs add ".fnameescape(g:asyncrun_text)
endfunc
function! g:CscopeUpdate(workdir, cscopeout)
let l:cscopeout = fnamemodify(a:cscopeout, ":p")
let l:cscopeout = fnameescape(l:cscopeout)
let l:workdir = (a:workdir == '')? '.' : a:workdir
try | exec "cs kill ".l:cscopeout | catch | endtry
exec "AsyncRun -post=call\\ g:CscopeDone() ".
\ "-text=".l:cscopeout." "
\ "-cwd=".fnameescape(l:workdir)." ".
\ "cscope -b -R -f -q ".l:cscopeout
endfunc
nnoremap <F11> <Esc>:w<CR>:!ctags --language-force=sh % <CR>:set ft=sh<CR>:set tags=./tags<CR>
" cscope generate
nnoremap <F12> <Esc>:!find . -name "*.h" -o -name "*.c" -o -name "*.cc" > cscope.files; cscope -bkq -i cscope.files<CR>:call g:CscopeUpdate(".", "cscope.out")<cr>
nnoremap <leader><F12> <Esc>:!find . -name "*.h" -o -name "*.c" -o -name "*.cc" > cscope.files; cscope -bkq -i cscope.files<CR>:call g:CscopeUpdate(".", "cscope.out")<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 跳转再优化
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 把下一个查找匹配项所在的行显示在屏幕的最中间
nnoremap <silent> n nzz " 正向重复上一次搜索并居中显示结果
nnoremap <silent> N Nzz " 反向重复上一次搜索并居中显示结果
nnoremap <silent> * *zz " 向后搜索光标所在的单词并居中显示结果
nnoremap <silent> # #zz " 向前搜索光标所在的单词并居中显示结果
nnoremap <silent> g* g*zz
" Format Jump
nnoremap <silent> g; g;zz
nnoremap <silent> g, g,zz
nnoremap } }zz " 向前移动一个段落并居中显示
nnoremap { {zz " 向后移动一个段落并居中显示
nnoremap ]] ]]zz " 跳转到下一个顶层函数并居中显示
nnoremap [[ [[zz " 跳转到上一个顶层函数并居中显示
nnoremap [] []zz " 跳转到上一个第一列的 } 并居中显示
nnoremap ][ ][zz " 跳转到下一个第一列的 } 并居中显示
" 代码跳转后居中 + 多选择跳转:nmap <c-]> g<c-]>
nnoremap <silent> <c-]> g<c-]>zz
nnoremap <silent> <c-o> g<c-o>zz
nnoremap <silent> <c-i> g<c-i>zz
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" cnoremap simulate readline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ctrl + p 和 Ctrl + n 来跳转到上一个/下一个条目
cnoremap <c-n> <down>
cnoremap <c-p> <up>
cnoremap <c-a> <Home>
cnoremap <c-e> <End>
cnoremap <c-b> <Left>
cnoremap <c-f> <Right>
cnoremap <c-d> <Del>
" %% for current buffer file name
" :: for current buffer file path
cnoremap %% <c-r>=expand('%')<cr>
cnoremap :: <c-r>=expand('%:p:h')<cr>/
cnoremap w!! w !sudo tee >/dev/null % " w! save changes even if file is read-only, provided user has appropriate permissions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" inoremap simulate readline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
inoremap <c-a> <home>
inoremap <c-e> <end>
inoremap <c-b> <left>
inoremap <c-f> <right>
inoremap <c-z> <Esc>zza
inoremap <c-_> <c-k> " insert mode as emacs
inoremap <c-x><c-a> <c-a> " insert mode as emacs
inoremap <c-x><c-b> <c-e> " insert mode as emacs
" Insert mode navigation similar to <C-g>j and <C-g>k
inoremap <silent> <C-g>l <right>
inoremap <silent> <C-g>h <left>
inoremap <silent> <C-g><C-l> <right>
inoremap <silent> <C-g><C-h> <left>
inoremap <C-^> <C-o><C-^> " movement in insert mode
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vimrc macros
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" /usr/share/vim/vim81/pack/dist/opt/matchit/autoload
packadd! matchit " 扩展了%命令的功能,支持if/else/endif语法结构;支持HTML标签.
set clipboard+=unnamed " 与windows共享剪切板
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has('autocmd')
" Remove ALL autocommands for the current group
au!
endif
let mapleader="\\"
let localleader="\\"
source $VIMRUNTIME/defaults.vim " vimrc defaults file
nnoremap ss :source $MYVIMRC<cr> " Fast reloading of the .vimrc
nnoremap ee :tabe $MYVIMRC<cr> " Fast editing of .vimrc
augroup enableAutoReloadVimrc
autocmd!
autocmd BufWritePost *vimrc source ${MYVIMRC} | set foldmethod=marker
autocmd BufWritePost *gvimrc if has('gui_running') source source ${MYVIMRC}
augroup END
" augroup enableAutoSaveSession
" autocmd!
" autocmd VimLeave * AsyncTask auto-vimleave-mksession
" autocmd VimEnter * AsyncTask auto-vimenter-sosession
" augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 基本配置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 关闭兼容模式
set nocompatible " disable backwards-compatible with vi
set shortmess=atI " 关闭乌干达儿童提示
set diffopt=filler,vertical " Keep files aligned, default to vsplit
set splitright " Open vertical splits on the right
" 高亮显示匹配的括号
set showmatch " set show matching parenthesis
" 启用鼠标
" set mouse=a
" set selection=exclusive
" set selectmode=mouse,key
" 设置编码utf-8
set fileencoding=utf-8
set encoding=utf-8
set tenc=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
language message en_US.UTF-8
set helplang=cn
" term 与 t_Co 有的颜色主题可能还与终端与终端色数量有关
set t_Co=256 " 启用256色
" 颜色主题 是放在运行时各路径的 colors/ 子目录的 *.vim 文件
" colorscheme这是个单独的命令,不是 set 选项.选择一个颜色主题
" :colorscheme + 主题名 -> :colorscheme helloworld -> colors/helloworld.vim
" colorscheme desert " darkblue
" background 背景是深色 dark 或浅色 light, 有的 colorscheme 只适于深色或 浅色背景,有的则分别为不同背景色定义不同的颜色主题
" set background=dark
set ttyfast " Faster redrawing.
set lazyredraw " Only redraw when necessary.
set splitbelow " Open new windows below the current window.
set splitright " Open new windows right of the current window.
set clipboard+=unnamed,unnamedplus " 复制到系统寄存器(*) 复制到系统寄存器(+)
set history=1000 " 最大历史记录 (default is 20)
" 开启语法高亮功能
syntax enable
" 允许用指定语法高亮配色方案替换默认方案 | " Enable syntax highlighting.
syntax on
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" 设置行号 + 行号的列宽
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
" set numberwidth=4
" set numberwidth?
" 突出显示当前行和当前列
" set cursorline
" set cursorcolumn
let g:indentLine_enabled = 1 " indentLine 开启代码对齐线
" 只想让这个效果出现在当前窗口,而且在插入模式中关闭这个效果
autocmd InsertLeave,WinEnter * set cursorline
autocmd InsertEnter,WinLeave * set nocursorline
" 关闭自动折行
set nowrap
set whichwrap-=<,>,h,l " 设置光标键不跨行
"set whichwrap=b,s,h,l,<,>,~,[,] " everything wraps
" | | | | | | | | |
" | | | | | | | | +-- "]" Insert and Replace
" | | | | | | | +-- "[" Insert and Replace
" | | | | | | +-- "~" Normal
" | | | | | +-- <Right> Normal and Visual
" | | | | +-- <Left> Normal and Visual
" | | | +-- "l" Normal and Visual (not recommended)
" | | +-- "h" Normal and Visual (not recommended)
" | +-- <leader> Normal and Visual
" +-- <BS> Normal and Visual
set virtualedit-=block,onemore " 不允许光标出现在最后一个字符的后面
set wrapscan " Searches wrap around end-of-file.
set report =0 " Always report changed lines.
set synmaxcol =200 " Only highlight the first 200 columns.
set shortmess-=S " display number of search matches & index of a current match
" 插入模式下在哪里允许 <BS> 删除光标前面的字符.逗号分隔的三个值分别指:行首的空白字符,换行符和插入模式开始处之前的字符。
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set confirm " Show confirm dialog
set hidden " Switch between buffers without having to save first
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" 显示状态栏
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set laststatus=2
" 底部显示
" 在底部显示当前模式
set showmode " Show current mode in command-line.
" 在底部显示当前指令
set showcmd " Show already typed keys when more are expected.
" 在状态栏中显示光标所在位置
set ruler
" |-- VISUAL -- 2f 43,8 17% |
" +-------------------------------------------------+
" ^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^
" 'showmode' 'showcmd' 'ruler'
" 状态行显示的内容
" 自定义状态行
set statusline=%1*\%<%.50F\ " 显示当前文件相对路径
set statusline+=%=%2*\%y%m%r%h%w\ " 显示文件类型和文件状态
set statusline+=%3*\%{&ff}\[%{&fenc}]\ " 显示文件编码类型
set statusline+=%4*\ row:%l/%L,col:%c\ " 显示光标所在行与列
set statusline+=%5*\%3p%%\ " 显示当前光标位置百分比
" :highlight 可以查看高亮显示组的颜色定义
hi User1 cterm=none ctermfg=25 ctermbg=0
hi User2 cterm=bold ctermfg=1 ctermbg=0
hi User3 cterm=bold ctermfg=1 ctermbg=0
hi User4 cterm=bold ctermfg=6 ctermbg=0
hi User5 cterm=bold ctermfg=green ctermbg=0
" 总是显示状态行
set laststatus=2 " Always show statusline.
set display=lastline " Show as much as possible of the last line.
" vim命令自动补全: 状态行上显示补全匹配, 按了 <Tab> 后有多于一个匹配的情况
set wildmenu " turn on command line completion wild style
set wildmode=longest:list,full
set wildignore=*.dll,*.exe,*.gif,*.jpg,*.mm ",*.png,*.snag,*.ssd,*.xmind " 影响 expand() globpath()和glob()的结果,这些函数被很多插件用来在系统中执行查找
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX
" set wildignore+=*\\.git\\*,*\\.hg\\*,*\\.svn\\* " Windows ('noshellslash')
set esckeys " Allow cursor keys in insert mode
set modeline " Respect modeline in files
set modelines=4
" 按 Esc 的生效更快速.通常 Vim 要等待一秒来看看 Esc 是否是转义序列的开始.如果你使用很慢的远程连接,增加此数值
" set timeout
" set timeoutlen=100
" 如果末行被截短,显示 @@@ 而不是隐藏整行
set display=truncate
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" 空格和tab键
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nolist
set listchars=tab:>-,trail:-
if has('multi_byte') && &encoding ==# 'utf-8'
let &listchars = 'tab:▸ ,extends:❯,precedes:❮,nbsp:±'
else
let &listchars = 'tab:> ,extends:>,precedes:<,nbsp:.'
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" 禁用错误报警声音和图标
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set noerrorbells
set novisualbell
set t_vb=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" 禁止生成临时文件
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nobackup
set noswapfile
" Put all temporary files under the same directory.
" https://github.com/mhinz/vim-galore#handling-backup-swap-undo-and-viminfo-files
" 如果文件夹不存在,则新建文件夹
if !isdirectory($HOME.'/.vim/files') && exists('*mkdir')
call mkdir($HOME.'/.vim/files')
endif
" 备份文件
set backup " make backup files
set backupdir =$HOME/.vim/files/backup/ " where to put backup files
set backupext =-vimbackup "
set backupskip =$HOME/.vim/files/backup/ " Don’t create backups when editing files in certain directories
" 交换文件
set directory =$HOME/.vim/files/swap/
set updatecount =100
" 撤销文件
set undofile
set undodir =$HOME/.vim/files/undo/
set undolevels =1000 " use many muchos levels of undo
" viminfo 文件
set viminfo ='100,n$HOME/.vim/files/info/viminfo
set viminfo=<100,'100,/50,:100,h,r$TEMP:,s10
" | | | | | | + 不保存超过10KB寄存器
" | | | | | + 不保存TEMP目录下文件的相关信息
" | | | | + 载入viminfo文件时关闭hlsearch高亮
" | | | + 保存命令历史条数
" | | + 保存搜索历史条数
" | + 保存最近100个文件中的标记
" + 每个寄存器中保存的行数
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" 格式控制
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" 自动探测
" 开启文件类型侦测
filetype on
" 根据侦测到的不同类型加载对应的插件
filetype plugin on
" 文件类型检查,自适应不同语言的智能缩进
filetype indent on
filetype plugin indent on " Load plugins according to detected filetype.
"文件自动检测外部更改
set autoread
set autowrite
"formatoptions(TODO) 控制自动格式化文本的许多选项
"""" 手动设置
"textwidth(TODO) 文本行宽度,超过该宽度(默认78)时自动加回车换回
" 按下回车键后,下一行的缩进会自动跟上一行的缩进保持一致(插入模式下回车自动缩进)
set autoindent " Indent according to previous line
set copyindent " copy the previous indentation on autoindenting
set smartindent
" 将制表符扩展为空格
set expandtab " Use spaces instead of tabs
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
" 设置格式化时制表符占用空格数
set shiftwidth=4 " >> indents by 4 spaces.
set shiftround " >> indents to next multiple of 'shiftwidth'.
" 设置编辑时制表符占用空格数
set tabstop=4 " 硬制表符宽度
" 让 vim 把连续数量的空格视为一个制表符
set softtabstop=4 " Tab key indents by 4 spaces.
set smarttab " insert tabs on the start of a line according to shiftwidth, not tabstop
"c文件自动缩进
set cindent
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" 拼写
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"拼写检查
set nospell
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""" 搜索
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 高亮搜索结果
set hlsearch " Keep matches highlighted.
" 自动跳转到第一个匹配的结果
set incsearch " show search matches as you type
" 搜索时只小写字母忽略大小写,有大写字母则大小写敏感
set ignorecase " ignore case when searching
set infercase " ignore case when auto-complete
set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
set ignorecase smartcase " 搜索词全部是小写时,进行大小写不敏感搜索;当搜索词 至少有1个大写字母时,进行大小写敏感搜索
" n 始终为向后搜索,N 始终为向前搜索
nnoremap <expr> n 'Nn'[v:searchforward]
nnoremap <expr> N 'nN'[v:searchforward]
""""""""""""""""""""""""""""""""""""""""
" 折叠 za:打开或关闭当前折叠/zM:关闭所有折叠/zR:打开所有折叠
""""""""""""""""""""""""""""""""""""""""
set nofoldenable "启动 vim 时关闭折叠代码
" set foldenable "允许折叠
set fdm=syntax "基于语法进行代码折叠
set fdm=manual "手动折叠
set foldmethod=indent "基于缩进进行代码折叠
set foldlevel=99
""""""""""""""""""""""""""""""""""""""""
"""" FZF config
""""""""""""""""""""""""""""""""""""""""
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -f -g ""'
" let $FZF_DEFAULT_COMMAND = 'fd --type f --color=always'
" let $FZF_DEFAULT_COMMAND = 'fd --type f --color=always' --exclude .git --ignore-file ~/.gitignore'
" CTRL-A CTRL-Q to select all and build quickfix list
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
copen
cc
endfunction
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
let $FZF_DEFAULT_OPTS='--bind ctrl-a:select-all --bind ctrl-d:deselect-all'
let $FZF_DEFAULT_OPTS='--no-height --no-reverse -m --bind="ctrl-a:select-all" --bind="ctrl-d:deselect-all" --bind "ctrl-/:toggle-preview" --bind "ctrl-\\:change-header(Type jump label)+jump,jump-cancel:change-header:Jump cancelled" --highlight-line --color gutter:-1,selected-bg:238,selected-fg:146,current-fg:189 --marker ▏ --pointer ▌ --prompt ▌ --bind "start:show-header"'
let g:fzf_layout = { 'window': { 'width': 1.0, 'height': 1.0 } }
" let g:fzf_vim.preview_window = ['right,50%', 'ctrl-/']
" let g:fzf_layout = { 'down': '40%' }
" let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.8 } }
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})
inoremap <expr> <c-x><c-f> fzf#vim#complete("find -print0 <Bar> xargs --null realpath --relative-to " . expand("%:h"))
inoremap <expr> <c-x><c-l> fzf#vim#complete#line()
" inoremap <c-x><c-k> <plug>(fzf-complete-word)
" inoremap <c-x><c-f> <plug>(fzf-complete-path)
" inoremap <c-x><c-l> <plug>(fzf-complete-line)
" show mapping on all modes with <leader><tab>
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
let g:fzf_history_dir = '~/.local/share/fzf-history'
""""""""""""""""""""""""""""""""""""""""
"""" FZF map
""""""""""""""""""""""""""""""""""""""""
" fzf
" :Ag [PATTERN] Ag! open fzf in fullscreen
" :Rg [PATTERN] Rg! open fzf in fullscreen
" Ag / Rg / Lines / BLines / Tags / BTags ==> fill the quickfix list when multiple entries are selected
nnoremap <leader>fa :Ag! <C-R><C-W><CR> | " :Ag [PATTERN] ag search result (ctrl-A to select all, ctrl-D to deselect all) word
nnoremap <leader>fA :Ag! <C-R><C-A><CR> | " :Ag [PATTERN] ag search result (ctrl-A to select all, ctrl-D to deselect all) WORD
nnoremap <leader>fr :Rg! <C-R><C-W><CR> | " :Rg [PATTERN] rg search result (ctrl-A to select all, ctrl-D to deselect all) word
nnoremap <leader>fR :Rg! <C-R><C-A><CR> | " :Rg [PATTERN] rg search result (ctrl-A to select all, ctrl-D to deselect all) WORD
" or xnoremap <Leader>* "sy:Rg! <C-r>s
xnoremap <leader>fa y:Ag! <C-R>"<CR>
xnoremap <leader>fA y:Ag! <C-R>"<CR>
xnoremap <leader>fr y:Rg! <C-R>"<CR>
xnoremap <leader>fR y:Rg! <C-R>"<CR>
" :FZF [fzf_options string] [path string] 1.:FZF ~ 2.:FZF --reverse --info=inline /tmp 3.:FZF!
nnoremap <leader>ff :execute 'Files! ' expand('%:h')<CR> | " Files (runs $FZF_DEFAULT_COMMAND if defined)
nnoremap <leader>fg :FZFFzm<CR> | " fzf-marks
nnoremap <leader>fG :GFiles?!<CR> | " Git files (git status)
nnoremap <leader>fb :Buffers!<CR> | " Open buffers
nnoremap <leader>fB :execute 'GFiles! ' expand('%:h')<CR> | " Git files (git ls-files)
nnoremap <leader>fl :BLines!<CR> | " Lines in the current buffer
nnoremap <leader>fL :Lines!<CR> | " Lines in loaded buffers
nnoremap <leader>ft :execute "Tags '" . expand('<cword>')<CR> | " Tags in the current buffer ; Tags and Helptags require Perl
nnoremap <leader>fT :execute "BTags '" . expand('<cword>')<CR> | " Tags in the project (ctags -R); Tags and Helptags require Perl
let g:fzf_tags_command = 'ctags -R --c++-kinds=+p+l+x+c+d+e+f+g+m+n+s+t+u+vI --c-kinds=+px --fields=+niazS --extra=+r'
nnoremap <leader>fm :Marks<CR> | " Marks
nnoremap <leader>fM :Maps<CR> | " Normal mode mappings
nnoremap <leader>fj :Jumps<CR> | " Jumps
nnoremap <leader>fw :Windows!<CR> | " Windows
nnoremap <leader>fh :History!<CR> | " Open buffers history
nnoremap <leader>H :execute ":help " . expand("<cword>")<cr>
nnoremap <leader>f: :History:<CR> | " Command history
nnoremap <leader>f/ :History/<CR> | " Search history
nnoremap <leader>f? :Helptags<CR> | " Help tags
nnoremap <leader>fs :Snippets<CR> | " Snippets (UltiSnips)
nnoremap <leader>fS :call fzf#sonictemplate#run()<CR> | " sonictemplate
nnoremap <leader>fc :Commits!<CR> | " Git commits (requires fugitive.vim)
nnoremap <leader>fC :BCommits!<CR> | " Git commits (requires fugitive.vim)
nnoremap <leader>f; :Commands<CR> | " Commands
nnoremap <leader>f' :FZFBookmarks<CR>
nnoremap <leader>f` :FZFBookmarks<CR>
" alias fzfy='ag -g "" -f ~/.local/share/yank_history | fzf -m --bind "enter:execute(vim {})" --bind "ctrl-e:execute(vim {})" --bind "ctrl-a:select-all" --preview "bat --style=numbers --color=always {} " '
function! s:fzf_yank_files()
let cwd = $HOME . "/.vim/registers/"
let command = 'ag -g "" -f ' . cwd . ' --depth 0'
call fzf#run({
\ 'source': command,
\ 'sink': 'e',
\ 'options': '-m -x +s',
\ 'window': 'enew' })
endfunction
command! FZFYankHistory call s:fzf_yank_files()
nnoremap <leader>fy :FZFYankHistory<CR> | " FZFYankHistory
let g:fzf_history_dir = '~/.local/share/fzf-history' " CTRL-N: next-history CTRL-P:previous-history instead of 'down' and 'up'
let g:vimreg_window_size_view = 15
let g:vimreg_window_size_edit = 15
let g:fzf_files_command = 'rg --color=never --hidden --files -g "!.git/"'
let g:fzf_afiles_command = 'rg --color=never --no-ignore --hidden --files'
nnoremap <leader>fF :AFiles<CR> | " include .git
nnoremap <leader>fu :Mru<CR> | " MRU files like History
nnoremap <leader>fU :MruCwd<CR> | " MRU files like History in current dir
" nnoremap <leader>fu :MruInCwd<CR> | " MRU files like History in current dir
nnoremap <leader>fo :BOutline<CR> | " Outline like BTag
nnoremap <Leader>fO :Messages<CR> | " :echomsg output
nnoremap <Leader>f" :Registers<CR> | " like junegunn/vim-peekaboo
nnoremap <Leader>fq :Quickfix<CR> | " getqflist
nnoremap <Leader>fQ :LocationList<CR> | " getloclist
nnoremap <Leader>f] :FzfFunky<Cr>
" narrow the list down with a word under cursor
nnoremap <Leader>f} :execute 'FzfFunky ' . expand('<cword>')<Cr>
" Tig revision
nnoremap <leader>fk :TigOpenCurrentFile<CR>
nnoremap <leader>fK :TigOpenProjectRootDir<CR>
" Floaterms
" nnoremap <Leader>fx :Floaterms<CR>
" nnoremap <Leader>fX :FloatermToggle<CR>
function! s:fzf_neighbouring_files()
let current_file =expand("%")
let cwd = fnamemodify(current_file, ':p:h')
let command = 'ag -g "" -f ' . cwd . ' --depth 0'
call fzf#run({
\ 'source': command,
\ 'sink': 'e',
\ 'options': '-m -x +s',
\ 'window': 'enew' })
endfunction
command! FZFNeigh call s:fzf_neighbouring_files()
nnoremap <leader>f. :FZFNeigh<CR> | " FZFNeigh
augroup fzf_commands
autocmd!
autocmd FileType fzf tnoremap <silent> <buffer> <c-j> <down>
autocmd FileType fzf tnoremap <silent> <buffer> <c-k> <up>
augroup end
nnoremap <leader>f] <Plug>(fzf_tags)
nnoremap <C-]> :Tgs<CR>
command! FzReadme call fzf#run(fzf#wrap(#{
\ source: values(map(copy(g:plugs), {k,v-> k.' '.get(split(globpath(get(v,'dir',''), '\creadme.*'), '\n'), 0, '')})),
\ options: ['--with-nth=1', '--preview', 'bat --color=always --plain {2}'],
\ sink: funcref('s:PlugReadmeFzf')}))
function s:PlugReadmeFzf(name_and_path) abort
execute 'PlugReadme' substitute(a:name_and_path, ' .*', '', '')
endfunction
nnoremap <Leader>fP :FzReadme<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" pechorin/any-jump.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:any_jump_window_width_ratio = 1.0
let g:any_jump_window_height_ratio = 1.0
let g:any_jump_window_top_offset = 10
let g:any_jump_max_search_results = 28
let g:any_jump_preview_lines_count = 10
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" .vim/autoload/plug.vim 自动载入脚本 PlugInstall/PlugUpdate/PlugClean/PlugUpgrade/
" :help packages
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Install vim-plug if it isn't already
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" mkdir -p ~/.vim/pack/plugins/start 创建一个存储插件的目录
packloadall "加载所有插件
silent! helptags ALL "为所有插件加载帮助文档
call plug#begin('~/.vim/plugged')
" Plug 'skywind3000/vim-dict' " VIM 词表收集
Plug 'skywind3000/asyncrun.vim' " hook (AsyncRunPre AsyncRunStart AsyncRunStop) cmd(AsyncRun AsyncStop AsyncReset)
Plug 'skywind3000/vim-terminal-help' " (toggle)\wt; drop abc.txt(bash -> vim); :H {shell command}; command H to send:(vim -> bash)
Plug 'skywind3000/asynctasks.vim' " :AsyncTaskMacro :AsyncTaskProfile :AsyncTask task1 -name=Batman -gender=boy :AsyncTaskList!(以点.开头的任务名在查询时会被隐藏) :AsyncTaskList
" :AsyncTask file-build ; noremap <silent><f5> :AsyncTask file-run<cr> ; <leader>fe :AsyncTaskFzf
" :AsyncTask file-run ; noremap <silent><f9> :AsyncTask file-build<cr> ; <leader>fe :AsyncTaskLast
" cmd(AsyncTask AsyncTaskEdit AsyncTaskList AsyncTaskMacro AsyncTaskProfile AsyncTaskLast AsyncTaskEnviron)
Plug 'skywind3000/vim-preview' " 预览tags中的函数
Plug 'skywind3000/vim-text-process' " Text Filter Manager for Vim/NeoVim !!
Plug 'voldikss/vim-floaterm' " cmd(FloatermNew, FloatermPrev, FloatermNext, FloatermFirst, FloatermLast, FloatermUpdate, FloatermToggle FloatermKill FloatermShow FloatermHide FloatermSend)
Plug 'jgdavey/tslime.vim' " <Plug>SendSelectionToTmux; <Plug>NormalModeSendToTmux; <Plug>SetTmuxVars(reset the session, window, and pane info)
Plug 'vim-scripts/vim-addon-mw-utils' " 代码片段提示/函数库
Plug 'tomtom/tlib_vim' " 代码片段提示/函数库
Plug 'SirVer/ultisnips' " 代码片段提示/替换引擎
Plug 'honza/vim-snippets' " 代码片段提示/各种各样的snippets
" Plug 'Valloric/YouCompleteMe' " 代码补全 sudo apt-get install build-essential cmake python-dev python3-dev; ./install.py --clang-completer
" YCM 的高性能 + coc.nvim 的富交互 + vim-lsp 的 API 设计 = EasyComplete 的极简和纯粹
" Plug 'nvie/vim-nox'
" Plug 'Shougo/neocomplete.vim'
Plug 'jayli/vim-easycomplete' " 余杭区最好用的vim补全插件(vim 8.2及以上,nvim 0.4.4 及以上版本) :EasyCompleteGotoDefinition :EasyCompleteCheck :EasyCompleteInstallServer ${Plugin_Name} set dictionary=${Your_Dictionary_File}
" Plug 'williamboman/nvim-lsp-installer' " :InstallLspServer lua
" Plug 'ervandew/supertab' "
" let g:SuperTabDefaultCompletionType = <c-n>
" let g:SuperTabContextDefaultCompletionType = <c-n>
Plug 'bronson/vim-trailing-whitespace' " 去除文档多余的空白符 ws
Plug 'vim-autoformat/vim-autoformat' " 代码格式化
Plug 'easymotion/vim-easymotion' " \\w (quick motion)
Plug 'junegunn/vim-easy-align' " ga gaip=; gaip*=
Plug 'vim-scripts/VisIncr' " :I [#]; :II [# [zfill]]; :IO [#]; :IIO [# [zfill]]; :IX [#]; :IIX [# [zfill]]; :IYMD [#]; :IMDY [#]; :IDMY [#]; :ID [#]
Plug 'tpope/vim-surround' " cs]{ ds{ds) ysiw<em>
Plug 'tpope/vim-commentary' " 注释 gcc {count}gc gcap
Plug 'tpope/vim-unimpaired' " ]b和[b循环遍历缓冲区; ]f和[f循环遍历同一目录中的文件,并打开为当前缓冲区; ]l和[l遍历位置列表; ]q和[q遍历快速修复列表; ]t和[t遍历标签列表; yos切换拼写检查,或yoc切换光标行高亮显示
Plug 'tpope/vim-rsi' " readline key
" Plug 'tpope/vim-endwise' helps to end certain structures automatically.
Plug 'tpope/vim-scriptease' " tool for script expert; :PP/:Runtime/:Disarm/:Scriptnames/:Messages/:Verbose/:Time
Plug 'tpope/vim-fugitive' " Git
Plug 'vim-scripts/DoxygenToolkit.vim', {'for': ['c', 'cpp']} " 注释DF DL DA DB
Plug 'gcmt/wildfire.vim' " in Visual mode, type k' to select all text in '', or type k) k] k} kp
Plug 'rhysd/clever-f.vim' " fFtT
Plug 'roxma/vim-paste-easy' " auto paste && nopaste
Plug 'christoomey/vim-system-copy' " cp for copying; cv for pasting; cP for line copying; cV for line pasting
" let g:system_copy#copy_command='xclip -sel clipboard'
" let g:system_copy#paste_command='xclip -sel clipboard -o'
Plug 'rjungemann/registers-everywhere' " ay(buffer->register a) \ca(register a -> tempfile a.txt) \va(tempfile a.txt -> register a) ap(register a -> buffer) \Ca \Va
Plug 'm6z/VimRegDeluxe' " vr(View) a 5; vre(Edit) a 5; vrc(Close) ab; vrs(Resize) 5 :vrr(Refresh)
Plug 'vim-scripts/tmpclip.vim' " TmpClipWrite TmpClipRead
Plug 'junegunn/vim-peekaboo' " \" Ctrl+R 显示寄存器内容
" Plug 'Yilin-Yang/vim-markbar' '` 显示mark的内容
Plug 'simnalamburt/vim-mundo' " 可视化管理内容变更历史记录的插件 :MundoToggle -> Gundo
Plug 'kshenoy/vim-signature' " mark 记录标注; m[a-zA-Z]:打标签,打两次就撤除/ m,:自动设定下一个可用书签名; mda:删除当前文件中所有独立书签
Plug 'MattesGroeger/vim-bookmarks' " bookmarks Ctrl-M
Plug 'tenfyzhong/fzf-bookmarks.vim' " bookmarks <leader>fo
Plug 'chengzeyi/fzf-preview.vim' "
Plug 'nmaiti/fzf_cscope.vim' "
Plug 'brookhong/cscope.vim' "
" 's' symbol: find all references to the token under cursor.
" 'g' global: find global definition(s) of the token under cursor
" 'c' calls: find all calls to the function name under cursor.
" 't' text: find all instances of the text under cursor.
" 'e' egrep: egrep search for the word under cursor.
" 'f' file: open the filename under cursor.
" 'i' includes: find files that include the filename under cursor.
" 'd' called: find functions that function under cursor calls.
" 'a' Assigned: Assigned to this symbol.
Plug 'tracyone/fzf-funky' "
Plug 'vim-scripts/autopreview' "
Plug 'ludovicchabant/vim-gutentags' " 管理tag文件 | ctags索引生成,方便变量,函数的跳转查询 ~/.cache/tags/mnt-d-cygwin64-home-wangfuli-openwrt-netifd-.tags
Plug 'vim-scripts/taglist.vim' " 浏览tags,文件内跳转 Tlist set tags=tags;
Plug 'preservim/tagbar' " 浏览tags,文件内跳转 Tagbar set tags=tags;
Plug 'vim-scripts/a.vim' " 源文件/头文件之间跳转 :A :AS :AV :AN
Plug 'vim-scripts/netrw.vim'
" netrw Ex/Sex/Vex/Lex 左右分割方式,当前Netrw窗口位于最左边,且高度占满整个屏幕 :Ex sftp://<domain>/<directory> 列出目录内容, :e scp://<domain>/<directory>/<file> 编辑文件
Plug 'vim-scripts/winmanager' " 文件系统管理 WMToggle/wm
Plug 'jlanzarotta/bufexplorer' " opened buffer管理 \bs \bv \bt \be
Plug 'preservim/nerdtree' " directory管理 NERDTreeToggle/tree; :Bookmark命令来收藏当前光标在NERDTree中选择的目录; B列出所以书签
Plug 'vim-scripts/ctrlp-funky' " nnoremap <Leader>fu :execute 'CtrlPFunky ' . expand('<cword>')<Cr>
" <Leader>vv 搜索光标所在单词,并匹配出所有结果 <Leader>vV 搜索光标所在单词,全词匹配
" <Leader>va vv结果添加到之前的搜索列表 <Leader>vA vV把结果添加到之前的搜索列表
" <Leader>vr 全局搜索光标所在单词,并替换想要的单词
" :Grep [arg] # 类似 <Leader>vv, 使用 ! 类似<Leader>vV
" :GrepAdd [arg] # 类似 <Leader>va, 使用 ! 类似<Leader>vA
" :Replace [target] [replacement] # 类似 <Leader>vr
" :ReplaceUndo # 撤销替换操作
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " 模糊搜索
Plug 'junegunn/fzf.vim'
Plug 'junegunn/limelight.vim'
" Color name (:help cterm-colors) or ANSI code
let g:limelight_conceal_ctermfg = 'gray'
let g:limelight_conceal_ctermfg = 240
" Color name (:help gui-colors) or RGB color
let g:limelight_conceal_guifg = 'DarkGray'
let g:limelight_conceal_guifg = '#777777'
Plug 'junegunn/seoul256.vim' " a low-contrast Vim color scheme based on Seoul Colors.
set background=dark " let g:seoul256_background = 236
Plug 'junegunn/vim-slash' " provides a set of mappings for enhancing in-buffer search experience in Vim.
Plug 'junegunn/gv.vim' " A git commit browser. # :GV; :GV!; :GV?; :GBrowse; [[; ]]; o|<cr>/O
Plug 'junegunn/goyo.vim' " :Goyo; :Goyo [dimension]; :Goyo! # Distraction-free writing in Vim.
Plug 'sunaku/vim-shortcut' " Shortcut!; Shortcut; :Shortcuts
Plug 'phongnh/fzf-settings.vim' " Quickfix/Registers/Messages/BOutline
" z= spelling suggestions via fzf https://github.com/junegunn/fzf/issues/2284
Plug 'tknightz/projectile.vim' " :AddProject; :ListProject; :RemoveProject
Plug 'relastle/vim-tgs' " :TgsList :Tgs
Plug 'fszymanski/fzf-quickfix', {'on': 'Quickfix'} " fq/fQ
Plug 'AndrewRadev/quickpeek.vim', {'on': 'Quickfix'} ":Quickpeek; :QuickpeekStop; :QuickpeekToggle
Plug 'mattn/vim-sonictemplate' " Template <TAB>
Plug 'voldikss/fzf-floaterm' " :Floaterms
Plug 'tenfyzhong/fzf-marks.vim' " fzf-marker
Plug 'pechorin/any-jump.vim' " <leader>j :AnyJump; <leader>ab :AnyJumpBack; <leader>al :AnyJumpLastResult
Plug '4513ECHO/vim-readme-viewer' " :PlugHelp or :FzReadme
Plug 'liuchengxu/vista.vim/' " Vista!! Toggle vista view window
Plug 'lambdalisue/fern.vim' " :Fern . ; :Fern {url} [-opener={opener}] [-reveal={reveal}] [-stay] [-wait]
Plug 'LumaKernel/fern-mapping-fzf.vim' " ff fzf-files;fd fzf-dirs;fa fzf-both;frf fzf-root-files;frd fzf-root-dirs;fra fzf-root-both; :help fern-mapping-fzf .
Plug 'azabiong/vim-highlighter' " HiSet = 'f<CR>'; HiErase = 'f<BS>'; HiFind = 'f<Tab>'; HiClear = 'f<C-L>'; # Default key mappings: f Enter, f Backspace, f Ctrl+L, f Tab and t Enter
Plug 'jiangmiao/auto-pairs' " 括号自动补全
Plug 'RRethy/vim-illuminate'
hi illuminatedWord cterm=underline gui=underline
Plug 'vim-airline/vim-airline' " 状态栏
Plug 'vim-airline/vim-airline-themes' " 状态栏主题
Plug 'asins/vimcdoc' " vim中文文档 help
Plug 'vim-utils/vim-man' " vim Man Vman帮助文档
Plug 'nanotee/nvim-lua-guide' " lua reference manual, :help lua.table
Plug 'hotchpotch/perldoc-vim' " apt-get install perl-doc; K hotkey
Plug 'bfrg/vim-cmake-help' " :CMakeHelp {arg} / :CMakeHelpPopup {arg} / :CMakeHelpOnline [{arg}]
Plug 'vim-syntastic/syntastic' " ALE 异步语法检查引擎
Plug 'iberianpig/tig-explorer.vim'
Plug 'dracula/vim', { 'as': 'dracula' } " Plug 'liuchengxu/space-vim-dark' + colorscheme space-vim-dark
Plug 'jacoborus/tender.vim' " colorscheme
Plug 'morhetz/gruvbox' " colorscheme
Plug 'will133/vim-dirdiff' " :DirDiff <dir1> <dir2>
Plug 'szw/vim-maximizer' " :MaximizerToggle
Plug 'lambdalisue/suda.vim' " sudo
call plug#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" colorscheme
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
colorscheme dracula
colorscheme gruvbox
colorscheme tender
let g:airline_theme = 'tender'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 'SirVer/ultisnips' + 'honza/vim-snippets'
" <c-j>展开 <c-tab>列出snippets <c-j>跳到下一个位置 <c-k>跳到上一个位置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - https://github.com/Valloric/YouCompleteMe
" - https://github.com/nvim-lua/completion-nvim
" let g:UltiSnipsExpandTrigger="<tab>"
" 使用 <c-b> 切换下一个触发点, <c-z>上一个触发点
" let g:UltiSnipsJumpForwardTrigger="<tab>"
" let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" 使用 UltiSnipsEdit 命令时垂直分割屏幕
let g:UltiSnipsEditSplit="vertical"
" 配置搜索snippets文件的文件夹
" set runtimepath+="/home/wangfuli/.vim/plugged/vim-mysnippet"
let g:UltiSnipsSnippetDirectories=["UltiSnips", "vim-mysnippet"]
" 定义自己的snippets文件放置的位置
" g:UltiSnipsSnippetsDir
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 'jayli/vim-easycomplete' :h easycomplete
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:easycomplete_tab_trigger="<tab>" " 唤醒补全按键:默认 Tab 键
let g:easycomplete_scheme="sharp" " 菜单样式可以使用插件自带的四种样式(dark, light, rider, sharp)
let g:easycomplete_diagnostics_next = "<C-n>"
let g:easycomplete_diagnostics_prev = "<C-p>"
let g:easycomplete_diagnostics_enable = 1
let g:easycomplete_lsp_checking = 0 " check LSP server 是否安装
let g:easycomplete_signature_enable = 0 " lsp signature checking
let g:easycomplete_tabnine_enable = 0 " disaable TabNine
let g:easycomplete_tabnine_config = {
\ 'line_limit': 1000,
\ 'max_num_result' : 3,
\ }
let g:easycomplete_cursor_word_hl = 0 " Highlight the symbol when holding the cursor
let g:easycomplete_nerd_font = 0 " Using nerdfont is highly recommended
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" supertab
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:SuperTabRetainCompletionType = 2 " 0 不记录上次的补全方式 1 记住上次的补全方式,直到用其他的补全命令改变它 2 记住上次的补全方式,直到按ESC退出插入模式为止
let g:SuperTabDefaultCompletionType = "context"
let g:SuperTabContextDefaultCompletionType = "<c-x><c-x>"
let g:SuperTabCompleteCase = 'match'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 'skywind3000/vim-dict'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-dict
let g:vim_dict_dict = [
\ '~/.vim/plugged/vim-dict/dict',
\ '~/.vim/vim-mydict',
\ ]
let g:vim_dict_config = {
\ 'html':'html,javascript,css,text',
\ 'markdown':'text',
\ }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 'bronson/vim-trailing-whitespace'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap tw :FixWhitespace<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 'tpope/vim-unimpaired'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 'vim-scripts/DoxygenToolkit.vim'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:load_doxygen_syntax = 1
let g:doxygen_enhanced_color = 1
let g:DoxygenToolkit_fileTag = "@file "
let g:DoxygenToolkit_briefTag_pre = "@brief "
let g:DoxygenToolkit_briefTag_funcName = "yes"
let g:DoxygenToolkit_briefTag_post = ""
let g:DoxygenToolkit_authorTag = "@author "
let g:DoxygenToolkit_authorName = "wangfuli<[email protected]>"
let g:DoxygenToolkit_versionTag = "@version "
let g:DoxygenToolkit_versionString = "1.0.0"
let g:DoxygenToolkit_dateTag = "@modify "
let g:DoxygenToolkit_classTag = "@class "
let g:DoxygenToolkit_paramTag_pre = "@param "
let g:DoxygenToolkit_returnTag = "@return "
let g:DoxygenToolkit_commentType = "C"
nnoremap <Leader>df :Dox<CR> | " 生成函数或者类声明
nnoremap <Leader>da :DoxAuthor<CR> | " 生成作者信息
nnoremap <Leader>db :DoxBlock<CR> | " 在后面的行中插入一个doxygen块
nnoremap <Leader>dl :DoxLic<CR> | " 生成授权说明
nnoremap <Leader>du :DoxUndoc(DEBUG)!<CR> | " 用于忽略代码块
let s:year = strftime("%Y")
let s:gplv3 = "\<enter>"
let s:gplv3 = s:gplv3 . "<one line to give the program's name and a brief idea of what it does.>\<enter>"
let s:gplv3 = s:gplv3 . "Copyright (C) " . s:year . " " . g:DoxygenToolkit_authorName . "\<enter>"
let s:gplv3 = s:gplv3 . "\<enter>"
let s:gplv3 = s:gplv3 . "This program is free software: you can redistribute it and/or modify\<enter>"
let s:gplv3 = s:gplv3 . "it under the terms of the GNU General Public License as published by\<enter>"
let s:gplv3 = s:gplv3 . "the Free Software Foundation, either version 3 of the License, or\<enter>"
let s:gplv3 = s:gplv3 . "(at your option) any later version.\<enter>"