-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc.plugins
991 lines (851 loc) · 34.4 KB
/
vimrc.plugins
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
scriptencoding utf-8
"""""""""""""""""""""""""""""""""""
" Plugin Settings {{{1
"""""""""""""""""""""""""""""""""""
" syntax-checkers {{{2
if isdirectory(expand('~/.vim/plugged/ale'))
let g:ale_linters = {
\ 'sh' : ['shellcheck'],
\ 'vim' : ['vint'],
\ 'html' : ['tidy'],
\ 'python' : ['flake8'],
\ 'markdown' : ['mdl'],
\ 'javascript' : ['eslint'],
\}
" If emoji not loaded, use default sign
try
let g:ale_sign_error = emoji#for('boom')
let g:ale_sign_warning = emoji#for('small_orange_diamond')
catch
" Use same sign and distinguish error and warning via different color
let g:ale_sign_error = '•'
let g:ale_sign_warning = '•'
endtry
let g:ale_echo_msg_format = '[#%linter%#] %s [%severity%]'
if has('gui_running')
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_statusline_format = [' E•%d', 'W•%d ', ' ⬥ OK ']
else
let g:ale_echo_msg_error_str = '✹ Error'
let g:ale_echo_msg_warning_str = '⚠ Warning'
let g:ale_statusline_format = ['X•%d ', '!•%d ', ' ✔ •OK ']
endif
augroup SPCACEVIM_ALELINT
autocmd!
autocmd User ALELint call lightline#update()
augroup END
else
" syntastic
"let g:syntastic_error_symbol = '✘'
let g:syntastic_error_symbol = 'X'
"let g:syntastic_warning_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
" error code: http://pep8.readthedocs.org/en/latest/intro.html#error-codes
let g:syntastic_python_checkers = ['flake8'] " use flake8 as checker, :help syntastic-checkers for more options
let g:syntastic_python_flake8_args = '--ignore=E501,E225,E124,E712'
" VimL
if executable('vint')
let g:syntastic_vim_checkers = ['vint'] " use vim-vint as VimL
endif
" Shell
if executable('bashate')
let g:syntastic_shell_checkers = ['bashate'] " use shellcheck as bash script checker
elseif executable('shellcheck')
let g:syntastic_shell_checkers = ['shellcheck'] " use shellcheck as bash script checker
endif
" 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 l:old_last_winnr = winnr('$')
lclose
if l:old_last_winnr == winnr('$')
" Nothing was closed, open syntastic_error location panel
Errors
endif
endfunction
" <leader>ep and <leader>en go up and down the location list and wrap around
nnoremap <silent> <Leader>ec <Plug>SyntasticReset
nnoremap <silent> <Leader>eh <Plug>SyntasticInfo
nnoremap <Leader>ee :call ToggleErrors()<CR>
nnoremap <silent> <Leader>tS <Plug>SyntasticToggleMode
" disable java checking
" thanks to @marsqing, see https://github.com/wklken/k-vim/issues/164
let g:syntastic_mode_map = {'mode': 'active', 'passive_filetypes': ['java'] }
endif
" wrap :cnext/:cprevious and :lnext/:lprevious
" from
" :http://stackoverflow.com/questions/27198612/vim-location-list-how-to-go-to-first-location-if-at-last-location/27204000#27204000
function! WrapCommand(direction, prefix)
if a:direction ==? 'up'
try
execute a:prefix . 'previous'
catch /^Vim\%((\a\+)\)\=:E553/
execute a:prefix . 'last'
catch /^Vim\%((\a\+)\)\=:E\%(776\|42\):/
endtry
elseif a:direction ==? 'down'
try
execute a:prefix . 'next'
catch /^Vim\%((\a\+)\)\=:E553/
execute a:prefix . 'first'
catch /^Vim\%((\a\+)\)\=:E\%(776\|42\):/
endtry
endif
endfunction
nnoremap <silent> <leader>ep :call WrapCommand('up', 'l')<CR>
nnoremap <silent> <leader>en :call WrapCommand('down', 'l')<CR>
" }}}
" YouCompleteMe {{{2
if count(g:bundle_groups, 'ycm')
" make YCM work with UltiSnips
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:ycm_complete_in_comments = 1 " show the completion menu even when typing inside comments
let g:ycm_complete_in_strings = 1 " show the completion menu even when typing inside strings
let g:ycm_use_ultisnips_completer = 1 " query the UltiSnips plugin for possible completions
" of snippet triggers. Default is 1, just ensure.
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " collect identifiers from
" strings and comments
let g:ycm_collect_identifiers_from_tags_files = 1 " collect identifiers from tags files
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_goto_buffer_command = 'horizontal-split' " goto the definition, open buffer horizontally
nnoremap <leader>jd :YcmCompleter GoTo<CR>
nnoremap <leader>jD :YcmCompleter GoToDeclaration<CR>
" old version
if !empty(glob('~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'))
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'
endif
" new version
if !empty(glob('~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'))
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
endif
let g:ycm_filetype_blacklist = {
\ 'tagbar' : 1,
\ 'gitcommit' : 1,
\}
" }}}
" ultisnips {{{2
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
let g:UltiSnipsSnippetDirectories = ['UltiSnips']
let g:UltiSnipsSnippetsDir = '~/.vim/UltiSnips'
" 定义存放代码片段的文件夹 .vim/UltiSnips下,使用自定义和默认的,将会的到全局,有冲突的会提示
" 进入对应filetype的snippets进行编辑
map <leader>aua :UltiSnipsAddFiletypes<CR>
map <leader>aue :UltiSnipsEdit<CR>
endif
" }}}
" neocomplete {{{2
if count(g:bundle_groups, 'neocomplete') && !exists('g:oob_in_nvim')
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
" do not select automaticlly
let g:neocomplete#enable_auto_select = 0
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return (pumvisible() ? "\<C-y>" : '' ) . "\<CR>"
" For no inserting <CR> key.
"return pumvisible() ? "\<C-y>" : "\<CR>"
endfunction
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
" Enable omni completion.
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
let g:neocomplete#sources#omni#input_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::'
endif
elseif count(g:bundle_groups, 'neocomplete') && exists('g:oob_in_nvim')
let g:deoplete#enable_at_startup = 1
endif
" Normal Vim omni-completion {{{2
" To enable omni complete, add the following to your .vimrc.before.local file:
" let g:oob_no_omni_complete = 1
if !exists('g:oob_no_omni_complete')
" Enable omni-completion.
augroup omnicomplete
autocmd!
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
augroup END
endif
" }}}
" Snippets {
" Plugin key-mappings.
if count(g:bundle_groups, 'neocomplete')
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
xmap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" Use honza's snippets.
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
" Enable neosnippet snipmate compatibility mode
let g:neosnippet#enable_snipmate_compatibility = 1
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
" Enable neosnippets when using go
let g:go_snippet_engine = 'neosnippet'
" Disable the neosnippet preview candidate window
" When enabled, there can be too much visual noise
" especially when splits are used.
set completeopt-=preview
endif
" }
" delimitMate {{{2
augroup filetype_python
autocmd FileType python let b:delimitMate_nesting_quotes = ['"']
augroup END
augroup filetype_php
autocmd FileType php let delimitMate_matchpairs = "(:),[:],{:}"
augroup END
" }}}
" closetag {{{2
let g:closetag_html_style=1
" }}}
" ################### Editing ###################
" nerdcommenter {{{2
let g:NERDSpaceDelims=1
let g:NERDAltDelims_python = 1
" }}}
" vim-easy-align {{{2
" " disabling &foldmethod during alignment
" let g:easy_align_bypass_fold = 1
"
" if !exists('g:easy_align_delimiters')
" let g:easy_align_delimiters = {}
" endif
" let g:easy_align_delimiters['#'] = { 'pattern': '#', 'ignore_groups': ['String'] }
" let g:easy_align_delimiter_align = 1
"
" map <leader>xa<Space>: EasyAlign*<Space><CR>
" map <leader>xa= :EasyAlign*=<CR>
" map <leader>xa<Bar> :EasyAlign*<Bar><CR>
" map <leader>xa\: :EasyAlign*:<CR>
" map <leader>xa" :EasyAlign*"<CR>
" map <leader>xa# :EasyAlign#"<CR>
" nmap <leader>xaa <Plug>(EasyAlign)
" xmap <leader>xaa <Plug>(EasyAlign)
" }}}
" tabular
if exists(':Tabularize')
nmap <Leader>xa<Space> :Tabularize /:\zs<CR>
vmap <Leader>xa<Space> :Tabularize /:\zs<CR>
nmap <Leader>xaa <Plug>(Tabularize)
vmap <Leader>xaa <Plug>(Tabularize)
nmap <Leader>xa= :Tabularize /^[^=]*\zs=<CR>
vmap <Leader>xa= :Tabularize /^[^=]*\zs=<CR>
nmap <Leader>xa: :Tabularize /:\zs<CR>
vmap <Leader>xa: :Tabularize /:\zs<CR>
nmap <Leader>xa<Bar>: :Tabularize /<Bar><CR>
vmap <Leader>xa<Bar>: :Tabularize /<Bar><CR>
nmap <Leader>xa" :Tabularize /"\zs<CR>
nmap <Leader>xa" :Tabularize /"\zs<CR>
vmap <Leader>xa# :Tabularize /#\zs<CR>
vmap <Leader>xa# :Tabularize /#\zs<CR>
nmap <Leader>xa, :Tabularize /,<CR>
vmap <Leader>xa, :Tabularize /,<CR>
endif
" auto align tables
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let l:p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# l:p || getline(line('.')+1) =~# l:p)
let l:column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let l:position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',l:column).'\s\{-\}'.repeat('.',l:position),'ce',line('.'))
endif
endfunction
"" vim-indent-guides {{{2
"nmap <silent> <Leader>ti <Plug>IndentGuidesToggle
" indentLine {{{2
let g:indentLine_color_term = 239
let g:indentLine_color_gui = '#09AA08'
let g:indentLine_char = '¦'
let g:indentLine_concealcursor = 'niv' " (default 'inc')
let g:indentLine_conceallevel = 2 " (default 2)
let g:indentLine_fileTypeExclude = ['help', 'startify', 'vimfiler']
nmap <silent> <Leader>ti <Plug>IndentLinesToggle
" }}}
"the percent at which the highlight colors will be lightened or darkened.
let g:indent_guides_color_change_percent = 30
let g:indent_guides_guide_size = 1
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_default_mapping = 0
"}}}
" ################### Motion ###################
" easymotion {{{2
let g:EasyMotion_smartcase = 1
"let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
"map <Leader><space>h <Plug>(easymotion-linebackward)
"map <Leader><space>j <Plug>(easymotion-j)
"map <Leader><space>k <Plug>(easymotion-k)
"map <Leader><space>l <Plug>(easymotion-lineforward)
map <Leader> <Plug>(easymotion-prefix)
" <Leader>f{char} to move to {char}
map <Leader>mf <Plug>(easymotion-s)
nmap <Leader>mf <Plug>(easymotion-overwin-f)
" s{char}{char} to move to {char}{char}
nmap <leader>ms <Plug>(easymotion-overwin-f2)
nmap s <Plug>(easymotion-overwin-f2)
" Move to line
map <Leader>ml <Plug>(easymotion-bd-jk)
nmap <Leader>ml <Plug>(easymotion-overwin-line)
" Move to word
map <Leader>mw <Plug>(easymotion-bd-w)
nmap <Leader>mw <Plug>(easymotion-overwin-w)
" repeat
map <Leader>m. <Plug>(easymotion-repeat)
" }}}
" quickscope {{{2
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
" macvim/gvim会有问题, 暂时注解
if has('gui_running')
let g:qs_first_occurrence_highlight_color = '#afff5f' " gui vim
else
let g:qs_first_occurrence_highlight_color = 154 " terminal vim
endif
if has('gui_running')
let g:qs_second_occurrence_highlight_color = '#5fffff' " gui vim
else
let g:qs_second_occurrence_highlight_color = 51 " terminal vim
endif
" }}}
" ################### Selection ###################
" multiplecursors {{{2
let g:multi_cursor_use_default_mapping=0
" Default mapping
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
" }}}
" ################### 功能相关 ###################
" ctrlp ctrlpfunky{{{2
let g:ctrlp_map = '<leader>jp'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn|rvm)$',
\ 'file': '\v\.(exe|so|dll|zip|tar|tar.gz|pyc)$',
\ }
let g:ctrlp_working_path_mode=0
let g:ctrlp_match_window = 'order:ttb,max:20'
let g:ctrlp_max_height=15
let g:ctrlp_mruf_max=500
let g:ctrlp_follow_symlinks=1
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
if executable('ag')
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
" ctrlpfunky
" ctrlp插件1 - 不用ctag进行函数快速跳转
nnoremap <Leader>jf :CtrlPFunky<Cr>
" narrow the list down with a word under cursor
nnoremap <Leader>jF :execute 'CtrlPFunky ' . expand('<cword>')<Cr>
map <leader>jm :CtrlPMRU<CR>
nnoremap <leader>jb :CtrlPBuffer<CR>
nnoremap <leader>jp :CtrlP<CR>
nnoremap <leader>jT :CtrlPClearCache<CR>:CtrlP<CR>
let g:ctrlp_funky_syntax_highlight = 1
let g:ctrlp_extensions = ['funky']
" }}}
" ctrlsf {{{2
nmap \ <Plug>CtrlSFCwordPath<CR>
" let g:ctrlsf_position = 'below'
" let g:ctrlsf_winsize = '30%'
let g:ctrlsf_auto_close = 0
let g:ctrlsf_confirm_save = 0
" Note: cannot use <CR> or <C-m> for open
" Use : <sapce> or <tab>
let g:ctrlsf_mapping = {
\ 'open' : '<Space>',
\ 'openb' : 'O',
\ 'tab' : 't',
\ 'tabb' : 'T',
\ 'prevw' : 'p',
\ 'quit' : 'q',
\ 'next' : '<C-J>',
\ 'prev' : '<C-K>',
\ 'pquit' : 'q',
\ }
" }}}
" fugitive {{{2
" :Gdiff :Gstatus :Gvsplit
" not ready to open
nnoremap <leader>gb :Gblame<CR>
nnoremap <leader>gc :Gcommit<CR>
nnoremap <leader>gd :Gdiff<CR>
nnoremap <leader>gl :Glog<CR>
nnoremap <leader>gp :Gpush<CR>
nnoremap <leader>gs :Gstatus<CR>
" }}}
" gitgutter {{{2
" 同git diff,实时展示文件中修改的行
" 只是不喜欢除了行号多一列, 默认关闭,gs时打开
let g:gitgutter_map_keys = 0
let g:gitgutter_enabled = 0
let g:gitgutter_highlight_lines = 1
nnoremap <leader>gg :GitGutterToggle<CR>
" }}}
" gundo {{{2
let s:has_supported_python = 0
if has('python3')"
let g:gundo_prefer_python3 = 1
elseif has('python')"
let g:gundo_prefer_python3 = 1
endif
noremap <leader>tu :GundoToggle<CR>
" }}}
" ack ( default use ag if exists ) {{{2
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" }}}
" ################### UX/UI ###################
" airline & lightline {{{2
if count(g:bundle_groups, 'airline')
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 = '〈'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
" 是否打开tabline
" let g:airline#extensions#tabline#enabled = 1
else
let g:lightline = {
\ 'active': {
\ 'colorscheme': g:colors_name,
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], ['ctrlpmark'] ],
\ 'right': [ [ 'syntastic', 'ale', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename',
\ 'fileformat': 'LightlineFileformat',
\ 'filetype': 'LightlineFiletype',
\ 'fileencoding': 'LightlineFileencoding',
\ 'mode': 'LightlineMode',
\ 'ctrlpmark': 'CtrlPMark',
\ },
\ 'component_expand': {
\ 'syntastic': 'SyntasticStatuslineFlag',
\ 'ale': 'ALEGetStatusLine',
\ },
\ 'component_type': {
\ 'syntastic': 'error',
\ 'ale': 'error',
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '〉', 'right': '〈' }
\ }
""\ 'separator': { 'left': '❯', 'right': '❮' },
""\ 'subseparator': { 'left': '〉', 'right': '〈' }
"based on https://github.com/itchyny/lightline.vim/issues/104
function! LightlineSwitchTheme(theme)
" Firstly set the new colorscheme
try
let g:lightline.colorscheme = g:colors_name
catch
call lightline#error('Could not load colorscheme ' . g:lightline.colorscheme . '.')
let g:lightline.colorscheme = 'default'
endtry
" Secondly tell the lightline to load the settings of g:lightline
call lightline#init()
" Thirdly generate the colors based on the value of g:lightline.colorscheme
call lightline#colorscheme()
" Lastly update all the statusline of the windows
call lightline#update()
endfunction
function! LightlineModified()
return &filetype =~? 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightlineReadonly()
return &filetype !~? 'help' && &readonly ? '' : ''
endfunction
function! LightlineFilename()
let l:fname = expand('%:t')
return l:fname ==? 'ControlP' && has_key(g:lightline, 'ctrlp_item') ? g:lightline.ctrlp_item :
\ l:fname ==? '__Tagbar__' ? g:lightline.fname :
\ l:fname =~? '__Gundo\|NERD_tree' ? '' :
\ &filetype ==? 'vimfiler' ? vimfiler#get_status_string() :
\ &filetype ==? 'unite' ? unite#get_status_string() :
\ &filetype ==? 'vimshell' ? vimshell#get_status_string() :
\ ('' !=? LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ ('' !=? l:fname ? l:fname : '[No Name]') .
\ ('' !=? LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightlineFugitive()
try
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &filetype !~? 'vimfiler' && exists('*fugitive#head')
let l:mark = '' " edit here for cool mark
let l:branch = fugitive#head()
return l:branch !=# '' ? l:mark.branch : ''
endif
catch
endtry
return ''
endfunction
function! LightlineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightlineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LightlineFileencoding()
return winwidth(0) > 70 ? (&fileencoding !=# '' ? &fileencoding : &encoding) : ''
endfunction
function! LightlineMode()
let l:fname = expand('%:t')
return l:fname ==? '__Tagbar__' ? 'Tagbar' :
\ l:fname ==? 'ControlP' ? 'CtrlP' :
\ l:fname ==? '__Gundo__' ? 'Gundo' :
\ l:fname ==? '__Gundo_Preview__' ? 'Gundo Preview' :
\ l:fname =~? 'NERD_tree' ? 'NERDTree' :
\ &filetype ==? 'unite' ? 'Unite' :
\ &filetype ==? 'vimfiler' ? 'VimFiler' :
\ &filetype ==? 'vimshell' ? 'VimShell' :
\ winwidth(0) > 60 ? lightline#mode() : ''
endfunction
function! CtrlPMark()
if expand('%:t') =~? 'ControlP' && has_key(g:lightline, 'ctrlp_item')
call lightline#link('iR'[g:lightline.ctrlp_regex])
return lightline#concatenate([g:lightline.ctrlp_prev, g:lightline.ctrlp_item
\ , g:lightline.ctrlp_next], 0)
else
return ''
endif
endfunction
let g:ctrlp_status_func = {
\ 'main': 'CtrlPStatusFunc_1',
\ 'prog': 'CtrlPStatusFunc_2',
\ }
function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked)
let g:lightline.ctrlp_regex = a:regex
let g:lightline.ctrlp_prev = a:prev
let g:lightline.ctrlp_item = a:item
let g:lightline.ctrlp_next = a:next
return lightline#statusline(0)
endfunction
function! CtrlPStatusFunc_2(str)
return lightline#statusline(0)
endfunction
let g:tagbar_status_func = 'TagbarStatusFunc'
function! TagbarStatusFunc(current, sort, fname, ...) abort
let g:lightline.fname = a:fname
return lightline#statusline(0)
endfunction
augroup AutoSyntastic
autocmd!
autocmd BufWritePost *.c,*.cpp call s:syntastic()
augroup END
function! s:syntastic()
SyntasticCheck
call lightline#update()
endfunction
let g:unite_force_overwrite_statusline = 0
let g:vimfiler_force_overwrite_statusline = 0
let g:vimshell_force_overwrite_statusline = 0
endif
augroup LIGHTLINE_INIT
autocmd!
autocmd VimEnter * call LightlineSwitchTheme(g:colors_name)
augroup END
" }}}
" rainbow_parentheses {{{2
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3',],
\ 'ctermfgs': ['lightgray', 'brown','Darkblue','darkgray','darkgreen','darkcyan','darkred','darkmagenta','brown','gray','darkmagenta','Darkblue','darkgreen','darkcyan','darkred','red'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
" }}}
" incsearch {{{2
"" if !exists('g:oob_in_nvim')
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
"" endif
" }}}
" vim-leader-guide
"
" nerdtree {{{2
" On startup, focus NERDTree if opening a directory
" focus file if opening a file
let g:nerdtree_tabs_smart_startup_focus = 1
nmap <leader>fd :NERDTreeToggle<CR>
nmap <leader>ff :NERDTreeFind<CR>
"map <leader>n :NERDTreeToggle<CR>
let g:NERDTreeHighlightCursorline=1
let g:NERDTreeIgnore=[ '\.pyc$', '\.pyo$', '\.obj$', '\.o$', '\.so$', '\.egg$', '^\.git$', '^\.svn$', '^\.hg$' ]
"close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | end
" s/v 分屏打开文件
let g:NERDTreeMapOpenSplit = 's'
let g:NERDTreeMapOpenVSplit = 'v'
augroup nerdtree
autocmd!
" open a NERDTree if vim starts up with no files were specified or
" on opening a directory
autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | enew | exe 'NERDTreeFocus' | endif
" close vim if the only window left open is NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
augroup END
" nerdtree-git-plugin
let g:NERDTreeIndicatorMapCustom = {
\ 'Modified' : '✹',
\ 'Staged' : '✚',
\ 'Untracked' : '✭',
\ 'Renamed' : '➜',
\ 'Unmerged' : '═',
\ 'Deleted' : '✖',
\ 'Dirty' : '✗',
\ 'Clean' : '✔︎',
\ 'Unknown' : '?'
\ }
" }}}
" Vim Workspace Controller
" ctrlspace {{{2
"let g:airline_exclude_preview = 1
"" if the silver searcher exists, use it. then if ack exsits, use it.
"if executable('ag')
" let g:CtrlSpaceGlobCommand = 'ag -l --nocolor -g ""'
"elseif executable('ack')
" let g:CtrlSpaceGlobCommand = 'ack --files-without-matches --no-color -g ""'
"endif
"hi CtrlSpaceSelected guifg=#586e75 guibg=#eee8d5 guisp=#839496 gui=reverse,bold ctermfg=10 ctermbg=7 cterm=reverse,bold
"hi CtrlSpaceNormal guifg=#839496 guibg=#021B25 guisp=#839496 gui=NONE ctermfg=12 ctermbg=0 cterm=NONE
"hi CtrlSpaceSearch guifg=#cb4b16 guibg=NONE gui=bold ctermfg=9 ctermbg=NONE term=bold cterm=bold
"hi CtrlSpaceStatus guifg=#839496 guibg=#002b36 gui=reverse term=reverse cterm=reverse ctermfg=12 ctermbg=8
" }}}
" goyo {{{2
function! s:goyo_enter()
if has('gui_running')
set fullscreen
set background=light
set linespace=7
elseif exists('$TMUX')
silent !tmux set status off
endif
endfunction
function! s:goyo_leave()
if has('gui_running')
set nofullscreen
set background=dark
set linespace=0
elseif exists('$TMUX')
silent !tmux set status on
endif
endfunction
augroup GOYO
autocmd!
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave nested call <SID>goyo_leave()
autocmd! User GoyoLeave Limelight!
augroup END
"}}}
" Limelight {{{22
" Color name (:help cterm-colors) or ANSI code
"" let g:limelight_conceal_ctermfg = 'gray'
let g:limelight_conceal_ctermfg = 241
" Color name (:help gui-colors) or RGB color
"" let g:limelight_conceal_guifg = 'DarkGray'
let g:limelight_conceal_guifg = '#777777'
" Default: 0.5
let g:limelight_default_coefficient = 0.5
" Number of preceding/following paragraphs to include (default: 0)
let g:limelight_paragraph_span = 1
" Beginning/end of paragraph
" When there's no empty line between the paragraphs
" and each paragraph starts with indentation
"" let g:limelight_bop = '^\s'
"" let g:limelight_eop = '\ze\n^\s'
" Highlighting priority (default: 10)
" Set it to -1 not to overrule hlsearch
let g:limelight_priority = -1
"}}}
" 标签导航
" tagbar {{{2
nmap <leader>tt :TagbarToggle<CR>
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'
\ }
" }}}
" ################### Programming ###################
" quickrun {{{2
let g:quickrun_config = {
\ '_' : {
\ 'outputter' : 'message',
\ },
\}
let g:quickrun_no_default_key_mappings = 1
nmap <Leader>r <Plug>(quickrun)
map <F10> :QuickRun<CR>
" }}}
" python-mode {{{2
" Disable if python support not present
if !has('python')
let g:pymode = 0
endif
if !has('python') && !has('python3')
let g:pymode = 0
endif
if isdirectory(expand('~/.vim/plugged/python-mode'))
let g:pymode_lint_checkers = ['pyflakes']
let g:pymode_trim_whitespaces = 0
let g:pymode_options = 0
let g:pymode_rope = 0
endif
" }}}
" pythonsyntax {{{2
let g:python_highlight_all = 1
" }}}
" vim-go {{{2
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
let g:go_fmt_fail_silently = 1
" let g:go_fmt_command = "goimports"
" let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
" }}}
" markdown {{{2
let g:vim_markdown_folding_disabled=1
" }}}
" javascript {{{2
" pangloss/vim-javascript
let g:html_indent_inctags = 'html,body,head,tbody'
let g:html_indent_script1 = 'inc'
let g:html_indent_style1 = 'inc'
" }}}
" json {{{2
let g:vim_json_syntax_conceal = 0
" }}}
" css {{{2
"In some cases you might want to change the filetype from scss to scss.css
"for example, if you want to use SnipMate's CSS snippets within your SCSS
" files. In this case, uncomment the following line.
" au BufRead,BufNewFile *.scss set filetype=scss.css
" }}}
"}}}
" Use local settings if available
if filereadable(expand('~/.vimrc.bundles.local'))
source ~/.vimrc.bundles.local
endif
" vim: ft=vim:fdm=marker:et:sw=4: