-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc.plugged
1552 lines (1305 loc) · 54.9 KB
/
vimrc.plugged
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
" ==========================================
" plugged 插件管理和配置项
" ==========================================
"------------------------------------------- begin of configs --------------------------------------------
" ################### 包依赖 #####################
" package dependence: ctags, gtags, clangd(llvm), asytle, asytle, nodejs, yarn
" python dependence: pep8, pyflake, pynvim, pygments
" 非兼容vi模式。去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set nocompatible
filetype off " required! turn off
" ################### 插件管理 ###################
" inspired by spf13, 自定义需要的插件集合
if !exists('g:plugged_groups')
" let g:plugged_groups=['python', 'javascript', 'golang', 'php', 'ruby', 'shell', 'markdown', 'less', 'coffeescript', 'tmux', 'json', 'beta']
" ycm / coc 二选一, 否则会有冲突, vim>8 or neovim 推荐使用 coc
" ycm --> nerdtree + json
" cocnvim --> coc-explorer + vista + coc-json
let g:plugged_groups=['python', 'rust', 'markdown-preview', 'markdown-edit', 'tmux', 'shell', 'protobuf', 'coc', 'graphviz', 'bazel', 'beta']
endif
" ----------------------------------------------------------------------------
" 使用 vim-plug 管理插件
" ----------------------------------------------------------------------------
call plug#begin('~/.vim/plugged')
" 移动光标到插件名上, 使用'#'快速跳转到每个插件的配置处
" syntastic 语法检查
if v:version < 800
Plug 'scrooloose/syntastic'
" syntastic {{{
if has_key(g:plugs, 'syntastic')
" dependence
" 1. shellcheck `brew install shellcheck` https://github.com/koalaman/shellcheck
let g:syntastic_error_symbol='>>'
let g:syntastic_warning_symbol='>'
let g:syntastic_check_on_open=1
let g:syntastic_check_on_wq=0
let g:syntastic_enable_highlighting=1
" checkers
" python
" pip install flake8
let g:syntastic_python_checkers=['flake8', ] " 使用pyflakes,速度比pylint快
let g:syntastic_python_flake8_options='--ignore=E501,E225,E124,E712,E116,E131'
" javascript
" let g:syntastic_javascript_checkers = ['jsl', 'jshint']
" let g:syntastic_html_checkers=['tidy', 'jshint']
" npm install -g eslint eslint-plugin-standard eslint-plugin-promise eslint-config-standard
" npm install -g eslint-plugin-import eslint-plugin-node eslint-plugin-html babel-eslint
let g:syntastic_javascript_checkers = ['eslint']
" to see error location list
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_enable_signs = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_auto_jump = 0
let g:syntastic_loc_list_height = 5
function! ToggleErrors()
let old_last_winnr = winnr('$')
lclose
if old_last_winnr == winnr('$')
" Nothing was closed, open syntastic_error location panel
Errors
endif
endfunction
nnoremap <Leader>s :call ToggleErrors()<cr>
" ,en ,ep to jump between errors
function! <SID>LocationPrevious()
try
lprev
catch /^Vim\%((\a\+)\)\=:E553/
llast
endtry
endfunction
function! <SID>LocationNext()
try
lnext
catch /^Vim\%((\a\+)\)\=:E553/
lfirst
endtry
endfunction
nnoremap <silent> <Plug>LocationPrevious :<C-u>exe 'call <SID>LocationPrevious()'<CR>
nnoremap <silent> <Plug>LocationNext :<C-u>exe 'call <SID>LocationNext()'<CR>
nmap <silent> <Leader>ep <Plug>LocationPrevious
nmap <silent> <Leader>en <Plug>LocationNext
" 修改高亮的背景色, 适应主题
highlight SyntasticErrorSign guifg=white guibg=black
" 禁止插件检查java
" thanks to @marsqing, see https://github.com/wklken/k-vim/issues/164
let g:syntastic_mode_map = {'mode': 'active', 'passive_filetypes': ['java'] }
" 关闭syntastic语法检查, 鼠标复制代码时用到, 防止把错误标志给复制了
nnoremap <silent> <Leader>ec :SyntasticToggleMode<CR>
endif
" }}}
else
Plug 'w0rp/ale'
" ale {{{
if has_key(g:plugs, 'ale')
" pip install flake8 pylint?
" npm install -g eslint eslint-plugin-standard eslint-plugin-promise eslint-config-standard
" npm install -g eslint-plugin-import eslint-plugin-node eslint-plugin-html babel-eslint
let g:ale_linters = {
\ 'python': ['flake8'],
\ 'javascript': ['eslint'],
\ 'json': ['fixjson'],
\}
let g:ale_fixers = {
\ 'python': ['yapf'],
\ 'json': ['fixjson'],
\ 'scala': ['scalafmt'],
\}
let g:ale_fix_on_save = 1
let g:ale_python_flake8_options="--ignore=E121,E123,E126,E226,E24,E704,W503 --max-line-length=120"
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
let b:ale_warn_about_trailing_whitespace = 0
let g:ale_sign_column_always = 1
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ ok']
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
nmap <silent> <Leader>ep <Plug>(ale_previous_wrap)
nmap <silent> <Leader>en <Plug>(ale_next_wrap)
nnoremap <silent> <Leader>ec :ALEToggle<CR>
" troggle quickfix list
function! ToggleErrors()
let old_last_winnr = winnr('$')
lclose
if old_last_winnr == winnr('$')
" Nothing was closed, open syntastic_error location panel
lopen
endif
endfunction
nnoremap <Leader>s :call ToggleErrors()<cr>
let g:ale_set_highlights = 1
highlight clear ALEErrorSign
highlight clear ALEWarningSign
endif
" }}}
endif
" Group dependencies, vim-snippets depends on ultisnips
" 代码片段快速插入 (snippets中,是代码片段资源,需要学习)
" Snippets are separated from the engine. Add this if you want them:
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" 自动补全括号
Plug 'jiangmiao/auto-pairs'
" beancount
Plug 'nathangrigg/vim-beancount'
if count(g:plugged_groups, 'ycm')
" auto complete
" 代码自动补全
" 迄今为止用到的最好的自动VIM自动补全插件
" 重启 :YcmRestartServer
Plug 'Valloric/YouCompleteMe', { 'do': '/usr/local/bin/python3 install.py --clang-completer --go-completer --rust-completer' }
" YouCompleteMe {{{
"youcompleteme 默认tab s-tab 和自动补全冲突
"let g:ycm_key_list_select_completion=['<C-n>']
let g:ycm_key_list_select_completion = ['<Down>']
"let g:ycm_key_list_previous_completion=['<C-p>']
let g:ycm_key_list_previous_completion = ['<Up>']
let g:ycm_complete_in_comments = 1 "在注释输入中也能补全
let g:ycm_complete_in_strings = 1 "在字符串输入中也能补全
let g:ycm_use_ultisnips_completer = 1 "提示UltiSnips
let g:ycm_collect_identifiers_from_comments_and_strings = 1 "注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_tags_files = 1
" 开启语法关键字补全
let g:ycm_seed_identifiers_with_syntax=1
" 回车作为选中
let g:ycm_key_list_stop_completion = ['<CR>']
"let g:ycm_seed_identifiers_with_syntax=1 "语言关键字补全, 不过python关键字都很短,所以,需要的自己打开
" python semantic completion
let g:ycm_python_binary_path='/usr/local/bin/python3'
" 跳转到定义处, 分屏打开
let g:ycm_goto_buffer_command = 'horizontal-split'
let g:ycm_register_as_syntastic_checker = 0
" nnoremap <leader>jd :YcmCompleter GoToDefinition<CR>
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>
nnoremap <leader>gd :YcmCompleter GoToDeclaration<CR>
nnoremap <C-]> :YcmCompleter GoTo<CR>
" 引入,可以补全系统,以及python的第三方包 针对新老版本YCM做了兼容
" old version
if !empty(glob("~/.vim/plugged/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py"))
let g:ycm_global_ycm_extra_conf = "~/.vim/plugged/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py"
endif
" new version
if !empty(glob("~/.vim/plugged/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py"))
let g:ycm_global_ycm_extra_conf = "~/.vim/plugged/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py"
endif
" new version
if !empty(glob("~/.vim/plugged/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py"))
let g:ycm_global_ycm_extra_conf = "~/.vim/plugged/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py"
endif
let g:ycm_filepath_completion_use_working_dir = 1
let g:ycm_add_preview_to_completeopt = 0
let g:ycm_show_diagnostics_ui = 0
" let g:ycm_server_log_level = 'info'
let g:ycm_min_num_identifier_candidate_chars = 2
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_semantic_triggers = {
\ 'c,cpp,cc,python,java,go,erlang,perl': ['re!\w{2}'],
\ 'cs,lua,javascript': ['re!\w{2}'],
\ }
" 白名单
" let g:ycm_filetype_whitelist = {
" \ "c":1,
" \ "cpp":1,
" \ "go":1,
" \ "py":1,
" \ "java":1,
" \ "sh":1,
" \ "zsh":1,
" \ }
" 直接触发自动补全 insert模式下
" let g:ycm_key_invoke_completion = '<C-Space>'
" 黑名单,不启用
let g:ycm_filetype_blacklist = {
\ 'tagbar' : 1,
\ 'gitcommit' : 1,
\}
" }}}
" nerdtree
Plug 'scrooloose/nerdtree'
" nerdtree {{{
let g:NERDChristmasTree=0
let g:NERDTreeWinSize=30
let g:NERDTreeChDirMode=2
let g:NERDTreeShowBookmarks=1
" 列出当前目录文件
map <F6> :NERDTreeToggle<CR>
imap <F6> <ESC> :NERDTreeToggle<CR>
let NERDTreeHighlightCursorline=1
let NERDTreeIgnore=[ '\.pyc$', '\.pyo$', '\.obj$', '\.o$', '\.so$', '\.egg$', '^\.git$', '^\.svn$', '^\.hg$', '\~$', '\.swp$' ]
" s/v 分屏打开文件
let g:NERDTreeMapOpenSplit = 's'
let g:NERDTreeMapOpenVSplit = 'v'
" fix Nerdtree ^G before folder and file names OSX terminal vim
let g:NERDTreeNodeDelimiter = "\u00a0"
" nerdtreetabs
map <Leader>n <plug>NERDTreeTabsToggle<CR>
" 关闭同步
" let g:nerdtree_tabs_synchronize_view=0
" let g:nerdtree_tabs_synchronize_focus=0
" 是否自动开启nerdtree
" thank to @ListenerRi, see https://github.com/wklken/k-vim/issues/165
let g:nerdtree_tabs_open_on_console_startup=0
let g:nerdtree_tabs_open_on_gui_startup=0
let g:NERDTreeWinPos = "left"
"当打开vim且没有文件时自动打开NERDTree
autocmd vimenter * if !argc() | NERDTree | endif
" 只剩 NERDTree时自动关闭
autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" json
Plug 'elzr/vim-json', {'for': 'json'}
" json {{{
let g:vim_json_syntax_conceal = 0
" }}}
endif
if count(g:plugged_groups, 'bazel')
" https://github.com/bazelbuild/vim-bazel
" Add maktaba and bazel to the runtimepath.
" (The latter must be installed before it can be used.)
" vim-bazel is a plugin for only invoking bazel and interacting with bazel artifacts.
" .bzl file syntax and filetype setting already in vim-core
Plug 'google/vim-maktaba'
Plug 'bazelbuild/vim-bazel'
endif
if count(g:plugged_groups, 'graphviz')
Plug 'liuchengxu/graphviz.vim'
" How to open the generated output file.
" If does not exist, graphviz.vim will automatically choose the right way depending on the platform.
" let g:graphviz_viewer = 'open'
" Default output format. Default is 'pdf'.
" let g:graphviz_output_format = 'pdf'
" Options passed on to dot. Default is ''.
" let g:graphviz_shell_option = ''
endif
if count(g:plugged_groups, 'coc')
" cocnvim smart engine
" Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" cocnvim {{{
" 启动coc.nvim自动安装的插件
" coc-clang-format-style-options 辅助写 .clang-format
" coc-clangd clangd的前端, 方便配置
let g:coc_global_extensions = ['coc-yaml', 'coc-json', 'coc-explorer', 'coc-clang-format-style-options', 'coc-clangd' ]
let g:coc_config_home = "$HOME/.vim/"
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
if exists('*complete_info')
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif
" Use `[g` and `]g` to navigate diagnostics
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nmap tt :CocCommand explorer<CR>
" Use K to show documentation in preview window.
" nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>fo <Plug>(coc-format-selected)
nmap <leader>fo <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current line.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Introduce function text object
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap if <Plug>(coc-funcobj-i)
omap af <Plug>(coc-funcobj-a)
" Use <TAB> for selections ranges.
" NOTE: Requires 'textDocument/selectionRange' support from the language server.
" coc-tsserver, coc-python are the examples of servers that support it.
" nmap <silent> <TAB> <Plug>(coc-range-select)
" xmap <silent> <TAB> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Mappings using CoCList:
" Show all diagnostics.
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
" }}}
" coc-explorer {{{
let g:coc_explorer_global_presets = {
\ '.vim': {
\ 'root-uri': '~/.vim',
\ },
\ 'floating': {
\ 'position': 'floating',
\ },
\ 'floatingLeftside': {
\ 'position': 'floating',
\ 'floating-position': 'left-center',
\ 'floating-width': 30,
\ },
\ 'floatingRightside': {
\ 'position': 'floating',
\ 'floating-position': 'left-center',
\ 'floating-width': 30,
\ },
\ 'simplify': {
\ 'file.child.template': '[selection | clip | 1] [indent][icon | 1] [filename omitCenter 1]'
\ }
\ }
autocmd BufEnter * if (winnr("$") == 1 && &filetype == 'coc-explorer') | q | endif
map <F6> :CocCommand explorer <CR>
function! AuCocExplorerAutoOpen()
if @% == '' || @% == '.'
exe ':CocCommand explorer'
endif
endfunction
" if want to open explore when no buf, disable the annotation
" autocmd User CocNvimInit call AuCocExplorerAutoOpen()
" Use preset argument to open it
" nmap <space>ed :CocCommand explorer --preset .vim<CR>
" nmap <space>ef :CocCommand explorer --preset floating<CR>
" }}}
" vista
Plug 'liuchengxu/vista.vim'
" vista {{{
" How each level is indented and what to prepend.
" This could make the display more compact or more spacious.
" e.g., more compact: ["▸ ", ""]
" Note: this option only works the LSP executives, doesn't work for `:Vista ctags`.
let g:vista_icon_indent = ["╰─▸ ", "├─▸ "]
let g:vista_sidebar_width = 30
let g:vista_echo_cursor_strategy = 'floating_win'
" 设置为0,以禁用光标移动时的回显.
let g:vista_echo_cursor = 1
" Executive used when opening vista sidebar without specifying it.
" See all the avaliable executives via `:echo g:vista#executives`.
let g:vista_default_executive = 'coc'
" Map F9 to toggle sidebar
nnoremap <F9> :Vista!!<CR>
" nnoremap <leader>bt :Vista finder<CR>
" Set the executive for some filetypes explicitly. Use the explicit executive
" instead of the default one for these filetypes when using `:Vista` without
" specifying the executive.
let g:vista_executive_for = {
\ 'cpp': 'coc',
\ 'go': 'coc',
\ 'c': 'coc',
\ 'rust': 'coc',
\ }
" 跳转到标记后闪烁光标2次,间隔100ms.
let g:vista_blink = [2, 100]
" To enable fzf's preview window set g:vista_fzf_preview.
" The elements of g:vista_fzf_preview will be passed as arguments to fzf#vim#with_preview()
" For example:
" let g:vista_fzf_preview = ['right:50%']
" 图标美化
let g:vista#renderer#enable_icon = 1
let g:vista#renderer#icons = {
\ "function": "\uf30b",
\ "variable": "\uf5c0",
\ }
let g:vista_finder_alternative_executives = ['coc']
" }}}
Plug 'jackguo380/vim-lsp-cxx-highlight'
" cxx-highlight {{{
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_class_decl_highlight = 1
" }}}
endif
" tagbar
Plug 'preservim/tagbar'
" 标签导航
" tagbar {{{
nmap <F12> :TagbarToggle<CR>
" let g:tagbar_left=1
let g:tagbar_width=30
let g:tagbar_autofocus = 1
let g:tagbar_sort = 0
let g:tagbar_compact = 1
let g:tagbar_autofocus = 1
" let g:tagbar_autoshowtag = 1
" let g:tagbar_show_visibility = 1
" " for ruby
" let g:tagbar_type_ruby = {
" \ 'kinds' : [
" \ 'm:modules',
" \ 'c:classes',
" \ 'd:describes',
" \ 'C:contexts',
" \ 'f:methods',
" \ 'F:singleton methods'
" \ ]
" \ }
" " go语言的tagbar配置
" " 1. install gotags 'go get -u github.com/jstemmer/gotags'
" " 2. make sure `gotags` in you shell PATH, you can call check it with `which gotags`
" " for gotags. work with tagbar
" 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' : 'gotags',
" \ 'ctagsargs' : '-sort -silent'
" \ }
" }}}
" 快速加入修改环绕字符
" for repeat -> enhance surround.vim, . to repeat command
Plug 'tpope/vim-repeat' | Plug 'tpope/vim-surround'
" trailingwhitespace
" 快速去行尾空格 [, + <Space>]
Plug 'bronson/vim-trailing-whitespace'
" easyalign
" 快速赋值语句对齐
Plug 'junegunn/vim-easy-align'
" quick movement
" easymotion
"更高效的移动 [,, + w/fx/h/j/k/l]
Plug 'Lokaltog/vim-easymotion'
" 更高效的行内移动, f/F/t/T, 才触发
" quickscope
Plug 'unblevable/quick-scope'
" highlight selected word
Plug 'lfv89/vim-interestingwords'
" gutentags
Plug 'ludovicchabant/vim-gutentags'
Plug 'skywind3000/gutentags_plus'
Plug 'skywind3000/vim-preview'
Plug 'vim-scripts/matchit.zip'
" signature
" 显示marks - 方便自己进行标记和跳转
" m[a-zA-Z] add mark
" '[a-zA-Z] go to mark
" m<Space> del all marks
" m/ list all marks
" m. add new mark just follow previous mark
Plug 'kshenoy/vim-signature'
" quick selection and edit
" expandregion
" 选中区块
Plug 'terryma/vim-expand-region'
" 多光标选中编辑
" visualmulti
Plug 'mg979/vim-visual-multi', { 'branch': 'master' }
" On-demand lazy load
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
" git
" fugitive
Plug 'tpope/vim-fugitive'
" git-blame
Plug 'zivyangll/git-blame.vim'
" gundo
" edit history, 可以查看回到某个历史状态
Plug 'sjl/gundo.vim'
" view
" 状态栏增强展示
" airline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" lightline
" Plug 'itchyny/lightline.vim'
" rainbow_parentheses
" 括号显示增强
" Plug 'kien/rainbow_parentheses.vim'
" rainbow 基于 rainbow_parentheses方便配置
Plug 'luochen1990/rainbow'
" molokai
" 主题 molokai
Plug 'tomasr/molokai'
Plug 'patstockwell/vim-monokai-tasty'
" ctrlspace
Plug 'vim-ctrlspace/vim-ctrlspace'
"" 模糊搜索
" leaderf
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
" vim-clap
" The bang version will try to download the prebuilt binary if cargo does not exist.
Plug 'liuchengxu/vim-clap', { 'do': ':Clap install-binary!' }
" :Clap install-binary[!] will always try to compile the binary locally,
" if you do care about the disk used for the compilation, try using the force download way,
" which will download the prebuilt binary even you have installed cargo.
" Plug 'liuchengxu/vim-clap', { 'do': { -> clap#installer#force_download() } }
" fzf.vim
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
"" quick edit
"" 快速注释
Plug 'scrooloose/nerdcommenter'
" vim-clang-format
Plug 'rhysd/vim-clang-format'
" text object
" 支持自定义文本对象
Plug 'kana/vim-textobj-user'
" 增加行文本对象: l dal yal cil
Plug 'kana/vim-textobj-line'
" 增加文件文本对象: e dae yae cie
Plug 'kana/vim-textobj-entire'
" 增加缩进文本对象: i dai yai cii - 相同缩进属于同一块
Plug 'kana/vim-textobj-indent'
if count(g:plugged_groups, 'tmux')
" tmux
" For tmux navigator Ctrl-hjkl
Plug 'christoomey/vim-tmux-navigator'
" tmux {{{
" for tmux
if exists('$TMUX')
" set term=xterm-256color
endif
" }}}
endif
if count(g:plugged_groups, 'markdown-edit')
" see: https://github.com/plasticboy/vim-markdown
Plug 'godlygeek/tabular' | Plug 'plasticboy/vim-markdown'
" vim-markdown {{{
let g:vim_markdown_conceal = 0
let g:vim_markdown_folding_level = 6
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_math = 1
let g:tex_conceal = ""
let g:vim_markdown_json_frontmatter = 1
let g:vim_markdown_toc_autofit = 1
" }}}
" https://github.com/mzlogin/vim-markdown-toc
" Plug 'mzlogin/vim-markdown-toc'
endif
if count(g:plugged_groups, 'markdown-preview')
" If you don't have nodejs and yarn
" use pre build, add 'vim-plug' to the filetype list so vim-plug can update this plugin
" see: https://github.com/iamcco/markdown-preview.nvim/issues/50
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" If you have nodejs and yarn
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
" markdown-preview {{{
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 0
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
" disable_filename: if disable filename header for preview page, default: 0
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false,
\ 'disable_filename': 0
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
" recognized filetypes
" these filetypes will have MarkdownPreview... commands
let g:mkdp_filetypes = ['markdown']
" Mappings:
" normal/insert
" <Plug>MarkdownPreview
" <Plug>MarkdownPreviewStop
" <Plug>MarkdownPreviewToggle
" example
nmap <C-m> <Plug>MarkdownPreview
"nmap <M-s> <Plug>MarkdownPreviewStop
"nmap <C-p> <Plug>MarkdownPreviewToggle
" Command
" :MarkdownPreview
" :MarkdownPreviewStop
" }}}
endif
if count(g:plugged_groups, 'golang')
" 1. vim a.go
" 2. :GoInstallBinaries
" vimgo https://github.com/fatih/vim-go
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" vimgo {{{
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_function_parameters = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_fmt_command = "goimports"
let g:go_def_mode = 'gopls'
let g:go_info_mode='gopls'
let g:go_fmt_fail_silently = 1
" format with goimports instead of gofmt
let g:go_fmt_command = "goimports"
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go', 'java'] }
" }}}
endif
if count(g:plugged_groups, 'python')
" for python.vim syntax highlight
" pythonsyntax
Plug 'hdima/python-syntax'
Plug 'hynek/vim-python-pep8-indent'
Plug 'Glench/Vim-Jinja2-Syntax'
" pythonsyntax {{{
let python_highlight_all = 1
" }}}
" isort https://github.com/timothycrosley/isort#readme + https://github.com/fisadev/vim-isort#installation
" pip install isort
" Plug 'fisadev/vim-isort'
" Shift-V 上下选中, ctrl + i 规范化
" let g:vim_isort_map = '<C-i>'
endif
if count(g:plugged_groups, 'php')
" piv
" shift-v可以查看函数手册 / leader-pd生成注释
Plug 'spf13/PIV'
" piv {{{
let g:DisableAutoPHPFolding = 1
" }}}
endif
if count(g:plugged_groups, 'ruby')
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-rails'
" dir / dar
Plug 'nelstrom/vim-textobj-rubyblock'
" 有bug, 和当前有冲突, 尚未解决, 不要打开 => TODO: solve this problem
" Plug 'tpope/vim-endwise'
endif
if count(g:plugged_groups, 'javascript')
" javascript
" 注意: syntax这个插件要放前面
Plug 'othree/yajs.vim' | Plug 'pangloss/vim-javascript'
" Plug 'jelera/vim-javascript-syntax' | Plug 'pangloss/vim-javascript'
" TODO: jquery? for, remove or keep
Plug 'othree/javascript-libraries-syntax.vim'
let g:used_javascript_libs = 'jquery,underscore,backbone'
" for javascript 自动补全, 配合YCM, 需要安装全局环境的(非nvm中) node.js&npm
" 安装完成后还需要在 bundle/tern_for_vim 下执行 npm install 安装依赖 `cd ~/.vim/plugged/tern_for_vim && npm install`
" see https://github.com/marijnh/tern_for_vim
" Plug 'marijnh/tern_for_vim', {'do': 'npm install'}
" javascript {{{
" pangloss/vim-javascript
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
" }}}
endif
if count(g:plugged_groups, 'rust')
" https://github.com/rust-lang/rust.vim
Plug 'rust-lang/rust.vim'
" rust {{{
" let g:rustfmt_autosave = 1
" }}}
endif
if count(g:plugged_groups, 'coffeescript')
Plug 'kchmck/vim-coffee-script'
endif
" if count(g:plugged_groups, 'shell')
" Plug 'Shougo/vimshell.vim'
" endif
if count(g:plugged_groups, 'less')
" ###### vim.less : less 自动更新##########