-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinit.vim
More file actions
1123 lines (1007 loc) · 39.4 KB
/
init.vim
File metadata and controls
1123 lines (1007 loc) · 39.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" __ __ __ __ __ ______ ______ ______ ______
" /\ \ / / /\ \ /\ "-./ \ /\ ___\ /\ __ \ /\ ___\ /\__ _\
" \ \ \"/ \ \ \ \ \ \-./\ \ \ \ __\ \ \ __ \ \ \___ \ \/_/\ \/
" \ \__| \ \_\ \ \_\ \ \_\ \ \_\ \ \_\ \_\ \/\_____\ \ \_\
" \/_/ \/_/ \/_/ \/_/ \/_/ \/_/\/_/ \/_____/ \/_/
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" chenxuan's nvim config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" base config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = "," " use ',' as leader
set nocompatible " set not compatible with vi
filetype on " set file type detection
filetype plugin on " set load plugin by file type
set noeb " turn off error syntax prompts
syntax enable " highlight enable
syntax on " highlight auto
set t_Co=256 " open 256 color
set vb t_vb= " set no bell
set cmdheight=1 " set command height
set showcmd " show select line nums in visual
set textwidth=0 " close auto enter
set ruler " cursor position displayed
set laststatus=3 " show status, nvim 3, vim 2
set number " show line number
set relativenumber " show relativenumber
set cursorline " highlight current line
set whichwrap+=<,>,h,l " set the cursor key across rows
set ttimeoutlen=0 " set <ESC> response time
set virtualedit=block,onemore " allows the cursor appear after last character
set noshowmode " disable bottom mode displayed 'insert'
set hidden " allows toggle buffers in unsaved
set matchpairs+=<:> " make % can jump <>
set background=dark " set background color
set maxmempattern=10240 " add max pattern memory size(10M)
set jumpoptions=stack " set jump to stack instead of list
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" code indent and typesetting config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set autoindent " set auto indent
set cindent " set indent by c/cpp
set cinoptions=g0,:0,N-s,(0 " set c/cpp indent way
set smartindent " smart choose indent way
filetype indent on " intelligent indent for different languages
set noexpandtab " set forbidden space to replace tab
set tabstop=4 " number of spaces used by tabs when editing
set shiftwidth=4 " number of spaces tab occupies when formatting
set softtabstop=4 " set 4 spaces as tabs
set smarttab " use tabs at the beginning of lines and segments
set nowrap " disable divide a line to two
set backspace=2 " use enter key to normally handle input, eol, start, etc
set sidescroll=10 " sets the number of characters to scroll to the right
set nofoldenable " disables folding code
set list lcs=tab:¦\ " default show indent line
set sidescroll=0 " set move line when cursor too right
set sidescrolloff=4 " set curor line to right
" set scrolloff=5 " set cursor line to bottom
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" code inside completion config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set wildmenu " vim itself named line pattern intelligent completion
set completeopt-=preview " completion window is not displayed when completed, only list is displayed
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" search config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set hlsearch " highlight search results
set incsearch " turn on real-time search
set ignorecase " search is not case sensitive
set smartcase " search smart match case
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" cache config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nobackup " set no back up
set noswapfile " disable create temp file
set autoread " if file change by others,load it auto
set autowrite " set auto save
set confirm " if quit without save,make confirm
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" encode config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set langmenu=zh_CN.UTF-8 " set langmenu encode utf-8
set helplang=cn " set helplang Chinese
set encoding=utf8 " set encode
set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030 " set detect encode of file
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" gvim/macvim config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("gui_running")
set guifont=DroidSansMono\ Nerd\ Font\ Regular\ 14 " set fonts in gvim
set guioptions-=m " hide the menu bar
set guioptions-=T " hide tool bar
set guioptions-=L " hide left scroll bar
set guioptions-=r " hide right scroll bar
set guioptions-=b " hide bottom scroll bar
set showtabline=0 " hide tab bar
set guicursor=n-v-c:ver5 " set cursor to a vertical line
endif
" load vim default plugin
runtime macros/matchit.vim
" key map and inside config setting
" reload .vimrc
nnoremap <leader><leader>s :source $MYVIMRC<cr>
nnoremap <leader><leader>S :source <c-r>=expand('%:p')<cr><cr>
" lazy interface
nnoremap <leader><leader>i :Lazy<cr>
" vim-buffer
nnoremap <silent><c-p> :call <sid>ChangeBuffer('p')<cr>
nnoremap <silent><c-n> :call <sid>ChangeBuffer('n')<cr>
nnoremap <silent>H :call <sid>ChangeBuffer('p')<cr>
nnoremap <silent>L :call <sid>ChangeBuffer('n')<cr>
nnoremap <silent><expr><c-m> &bt==''?":w<cr>":&bt=='terminal'?"i\<enter>":
\ getwininfo(win_getid())[0]["quickfix"]!=0?"\<cr>:cclose<cr>":
\ getwininfo(win_getid())[0]["loclist"]!=0?"\<cr>:lclose<cr>":"\<cr>"
nnoremap <silent><leader>d :call <sid>CloseBuf()<cr>
func! s:ChangeBuffer(direct) abort
if &bt!=''||&ft=='netrw'|echoerr "buftype is ".&bt." cannot be change"|return|endif
if a:direct=='n'|bn
else|bp|endif
while &bt!=''
if a:direct=='n'|bn
else|bp|endif
endwhile
endfunc
func! s:CloseBuf()
if &bt!=''||&ft=='netrw'|bd|return|endif
let buf_now=bufnr()
let buf_jump_list=getjumplist()[0]|let buf_jump_now=getjumplist()[1]-1
while buf_jump_now>=0
let last_nr=buf_jump_list[buf_jump_now]["bufnr"]
let last_line=buf_jump_list[buf_jump_now]["lnum"]
if buf_now!=last_nr&&bufloaded(last_nr)&&getbufvar(last_nr,"&bt")==''
execute ":buffer ".last_nr|silent! execute ":bd ".buf_now|return
else|let buf_jump_now-=1
endif
endwhile
bp|while &bt!=''|bp|endwhile
execute "bd ".buf_now
endfunc
" insert model to move cursor
imap <c-j> <down>
imap <c-k> <up>
imap <c-l> <right>
imap <c-h> <left>
" move in insert
inoremap <c-e> <end>
inoremap <c-a> <c-o>^
inoremap <c-d> <del>
vnoremap <c-d> <del>
inoremap <c-f> <c-o>w
inoremap <c-v> <c-o>D
inoremap <expr><c-b> <sid>CtrlB()
func! s:CtrlB()
if pumvisible()|return "\<c-n>"
elseif getline('.')[col('.')-2]==nr2char(9)
let s:pos=col('.')|let s:result=""
while s:pos!=0|let s:result=s:result."\<bs>"|let s:pos-=1|endwhile
return s:result
else
return "\<c-o>b"
endif
endfunc
" use jk map for esc
inoremap jk <esc>
" select paste
snoremap <c-v> <space><bs><c-o>"0P
" delete line
inoremap <c-q> <c-o>dd
snoremap <c-q> <c-o>dd
" find next {}
nnoremap <c-y> /{<cr>:noh<cr>va}<c-g>
nnoremap <c-t> ?}<cr>:noh<cr>va{<c-g>
inoremap <c-y> <c-[>/{<cr>:noh<cr>va}<c-g>
vnoremap <c-y> <c-[>/{<cr>:noh<cr>va}<c-g>
vnoremap <c-t> <c-[>?}<cr>:noh<cr>va{<c-g>
inoremap <c-t> <c-[>?}<cr>:noh<cr>va{<c-g>
" yank to system
vnoremap <leader><leader>y "+y
vnoremap Y "+y
" paste to system
nnoremap <leader><leader>p "+p
nnoremap <leader><leader>P "+P
vnoremap <leader><leader>p "+p
vnoremap <leader><leader>P "+P
augroup ReadPost
au!
autocmd FileType java,c,cpp set commentstring=//\ %s
autocmd TermOpen * if &bt=='terminal'|setlocal norelativenumber|setlocal nonumber|startinsert|endif
autocmd WinEnter * if &bt=='terminal'&&!exists(':Termdebug')|call feedkeys("i\<esc>\<esc>")|endif
autocmd TermClose * if !exists('g:nvim_term_open')|call feedkeys("i\<esc>\<esc>")|else|unlet g:nvim_term_open|endif
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g'\"" | execute "normal! zz" | endif
autocmd BufDelete * if expand('%:p')!=''&& &bt==""|let g:map_recent_close[expand('%:p')] =
\{'lnum':line('.'),'col':col('.'),'text':'close at '.strftime("%H:%M"),'time':localtime()}
\|endif
" nvim 0.11+ 自带右键 PopUp 菜单会在 MenuPopup 时动态 enable/disable。
" vim-fast 会 unmenu PopUp 并重建菜单,导致内置回调找不到菜单项时报 E329。
" 清掉内置的 nvim.popupmenu 组,避免与自定义右键菜单冲突。
" f**k nvim break change
if has('nvim') && exists('#nvim.popupmenu#MenuPopup')
silent! augroup nvim.popupmenu
autocmd!
silent! augroup END
endif
autocmd MenuPopup * call RightMouseMenu()
augroup END
" global popupmenu
let g:rightmouse_popupmenu={}
let g:rightmouse_extramenu=[]
func AddMouseMenu(func)
if type(a:func)!=2|echoerr 'func must be function'|return|endif
call add(g:rightmouse_extramenu,a:func)
endfunc
func RightMouseMenu()
if has_key(g:rightmouse_popupmenu, &ft)|call g:rightmouse_popupmenu[&ft]()
else|call MouseConfig()|endif
if !empty(g:rightmouse_extramenu)|for Func_name in g:rightmouse_extramenu|call Func_name()|endfor|endif
endfunc
" load the file last edit pos
let g:map_recent_close={}
func! s:GetRecentClose()
let s:list=[]
for [key,value] in items(g:map_recent_close)
let value['filename']=key
call insert(s:list,value)
endfor
let s:func={m1,m2 -> m1['time']>m2['time']?-1:1}
call sort(s:list,s:func)
call setqflist(s:list,'r')
copen
endfunc
nnoremap <silent><nowait><space>q :call <sid>GetRecentClose()<cr>
" ctags config
command! -nargs=? TagCreate call s:CreateTags(<q-args>,0)
command! -nargs=? TagPwd call s:CreateTags(<q-args>,1)
command! -nargs=0 TagKind echo system("ctags --list-maps")
command! -nargs=1 -complete=tag TagFind exec ":ts /".<q-args>
command! -nargs=1 -complete=file TagSave if exists("g:tag_file")&&filereadable(g:tag_file)|call system("cp ".g:tag_file." ".<q-args>)|endif
cab TagSave TagSave <c-r>=termtask#Term_get_dir()<cr>/tags
nnoremap <expr><c-]> <sid>FindTags(expand('<cword>'))
vnoremap <nowait><c-]> "sy:TagFind <c-r>=@s<cr><cr>
func! s:FindTags(str)
let list=taglist(a:str)
if len(list)==1|return "\<c-]>"|else|return ":ts ".a:str."\<cr>"|endif
endfunc
func! s:CreateTags(arg,flag)
if exists("g:tag_file")|exec "set tags-=".g:tag_file|endif|let g:tag_file=tempname()
if a:flag|let g:tag_file="./tags"|endif
if a:arg!=""|let arg=" --languages=".a:arg|else|let arg=" "|endif
let dir=termtask#Term_get_dir()
call jobstart("ctags -f ".g:tag_file.arg." --tag-relative=no -R ".dir,
\{"on_exit":"CreateTagCB","on_stderr":"CreateTagErrCB"})
exec "set tags+=".g:tag_file
endfunc
func! CreateTagErrCB(chan,msg,name)
if a:msg[0]!=""|echoerr a:msg|endif
endfunc
func! CreateTagCB(chan,msg,event)
if a:msg==0|echom "tag create success"|else|echom a:msg."create tag wrong"|endif
endfunc
" termdebug
let g:termdebug_wide=1
nnoremap <leader><leader>d :packadd termdebug<cr>:Termdebug<space>
nnoremap <F5> :packadd termdebug<cr>:Termdebug<space>
nnoremap <F6> :Break<cr>
nnoremap <F7> :Over<cr>
nnoremap <F8> :Step<cr>
" term console
tnoremap <c-\> <c-\><c-n>
tnoremap <c-o> ~/.config/nvim/nvr.py -l <space>
tnoremap <c-]> ~/.config/nvim/nvr.py -l<space>;exit<left><left><left><left><left>
tnoremap <c-z> exit<cr>
nnoremap <leader><leader>T :belowright split +resize\ <c-r>=winheight(0)/3<cr><cr>:term<cr>
nnoremap <leader><leader>t :vsplit<CR>:term<cr>
nnoremap <silent><space><space>t :tabe<cr>:term<cr>
nnoremap <silent><space><space>T :let @s=expand('%:p:h')<cr>:tabe<cr>:term $SHELL -c "cd <c-r>=@s<cr>;$SHELL"<cr>
tnoremap <c-w>l <c-\><c-n><c-w>l
tnoremap <c-w>h <c-\><c-n><c-w>h
tnoremap <c-w>j <c-\><c-n><c-w>j
tnoremap <c-w>k <c-\><c-n><c-w>k
" lazygit
nnoremap <silent><space>g :call <sid>ShellOpenFile(-1,0,"LAZYGIT_FILE")<cr>:call termopen("lazygit",{"on_exit":"<sid>ShellOpenFile"})<cr>
nnoremap <silent><space>G :let @s=expand('%')<cr>:tabe<cr>:term lazygit -f <c-r>s<cr>
func! s:ShellOpenFile(close,exitcode,event) abort
if a:close==-1
tabe
if !exists("s:shell_open_file")||getenv(a:event)==v:null
let s:shell_open_file=tempname()|let s:shell_open_env=a:event
call setenv(a:event,s:shell_open_file)
endif
return
endif
silent! bd
let need_close_tab=1|let all_buffers_info = getbufinfo()
for buf_info in all_buffers_info|if buf_info.name != ""|let need_close_tab=0|endif|endfor
if need_close_tab|silent! tabc|endif
if exists("s:shell_open_file")&&filereadable(expand(s:shell_open_file))&&getenv(s:shell_open_env)==s:shell_open_file&&filereadable(expand(s:shell_open_file))
call setenv(s:shell_open_env, v:null)
for line in readfile(s:shell_open_file)
let msg=split(line)
let file=msg[0]
if filereadable(file)
execute ":edit ".file
elseif isdirectory(file)
execute ":cd ".file
endif
if len(msg)>1&&msg[1]!=1|call cursor(msg[1],0)|endif
endfor
endif
endfunc
" lf config define
nnoremap <silent><space>E :call <sid>ShellOpenFile(-1,0,"OPEN_FILE")<cr>:call termopen("lf <c-r>=getenv('HOME')<cr>",{"on_exit":"<sid>ShellOpenFile"})<cr>
nnoremap <silent><space>e :call <sid>ShellOpenFile(-1,0,"OPEN_FILE")<cr>:call termopen("lf",{"on_exit":"<sid>ShellOpenFile"})<cr>
" yank and paste
nnoremap <leader>p "0p
vnoremap <leader>p "0p
nnoremap <leader>P "0P
vnoremap <leader>P "0P
" vimdiff tool
cab <expr>Diff "Diff ".expand('%:p:h')."/"
command! -nargs=1 -bang -complete=file Diff exec ":vert diffsplit ".<q-args>
command! -nargs=0 Remote :diffg RE
command! -nargs=0 Base :diffg BA
command! -nargs=0 Local :diffg LO
" edit binrary
func! s:BinraryEdit(args) abort
if join(readfile(expand('%:p'), 'b', 5), '\n') !~# '[\x00-\x08\x10-\x1a\x1c-\x1f]\{2,}'
echo "not a bin file"|return
endif
if &readonly|execute ":edit ++bin ".expand('%:p')|endif|setlocal bin
if !executable('xxd')|echoerr "xxd not find,install it first"|return|endif
echo "transform...please wait..."
let g:xxd_cmd=":%!xxd ".a:args
silent! execute g:xxd_cmd|let &modified=0|redraw!
augroup Binrary
au!
autocmd BufWritePre <buffer> let g:bin_pos_now=getcurpos()|silent! exec ":%!xxd -r"
autocmd BufWritePost <buffer> silent! exec g:xxd_cmd|call cursor([g:bin_pos_now[1],g:bin_pos_now[2]])
autocmd BufDelete <buffer> au! Binrary
augroup END
endfunc
command! -nargs=? Binrary :call <sid>BinraryEdit(<q-args>)
" change window width
nnoremap <c-up> <c-w>+
nnoremap <c-down> <c-w>-
nnoremap <c-left> <c-w><
nnoremap <c-right> <c-w>>
" change window pos in normal
nnoremap <c-k> <c-w>k
nnoremap <c-j> <c-w>j
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
nnoremap <s-up> <c-w>k
nnoremap <s-down> <c-w>j
nnoremap <s-left> <c-w>h
nnoremap <s-right> <c-w>l
" change window location
nnoremap <c-s-up> <c-w>K
nnoremap <c-s-down> <c-w>J
nnoremap <c-s-left> <c-w>H
nnoremap <c-s-right> <c-w>L
" quick fix
nnoremap ]q :cnext<cr>
nnoremap [q :cprevious<cr>
nnoremap \q :cclose<cr>
nnoremap =q :copen<cr>
nnoremap ]Q :cnext<cr>:call <sid>Qfpopup()<cr>
nnoremap [Q :cprevious<cr>:call <sid>Qfpopup()<cr>
func! s:Qfpopup()abort
let dict=getqflist({'all':1})|let pos=dict['idx']|let item=dict['items']|let len=len(dict['items'])
if len==0||(pos==1&&item[pos-1]['lnum']==0)|cclose|return|endif|let show=[item[pos-1]['text']]
while pos<len&&item[pos]['lnum']==0|let show=add(show,item[pos]['text'])|let pos+=1|endwhile
let show=show[0:-2]|call popup_atcursor(show,{})
endfunc
" set mouse
func! MouseConfig()
set mouse=a
set mousemodel=popup_setpos
" visual model
vnoremenu PopUp.Yank\ Text "+y
vnoremenu PopUp.Cut\ Text "+d
vnoremenu PopUp.Del\ Text "_d
vnoremenu PopUp.Paste\ Text "+p
vnoremenu PopUp.-Sep- :<cr>
" normal model
nnoremenu PopUp.Paste\ Text "+p
nnoremenu PopUp.Select\ All ggVG
nnoremenu PopUp.Back\ Pos <c-o>zz
nnoremenu PopUp.Next\ Pos <c-i>zz
" fold
nnoremenu PopUp.Open\ Fold zO
nnoremenu PopUp.Close\ Fold zC
" close
nnoremenu PopUp.Close\ Mouse :set mouse=""<cr>
nnoremenu PopUp.-Sep- :<cr>
" term model
tlnoremenu PopUp.Exit\ Term exit<cr>
endfunc
unmenu PopUp
call MouseConfig() " default set mouse enable
nnoremap <silent><nowait>=m :unmenu PopUp<cr>call MouseConfig()<cr>
nnoremap <silent><nowait>\m :set mouse=""<cr>
" show indent line
nnoremap <silent><nowait>=i :set list lcs=tab:¦\<space> <cr>
nnoremap <silent><nowait>\i :set nolist<cr>
" set spell
nnoremap <silent><nowait>=s :setlocal spell<cr>
nnoremap <silent><nowait>\s :setlocal nospell<cr>
" z= is list of change
" set wrap
nnoremap <silent><nowait>=r :setlocal wrap<cr>:noremap<buffer> j gj<cr>:noremap<buffer> k gk<cr>
nnoremap <silent><nowait>\r :setlocal nowrap<cr>:unmap<buffer> j<cr>:unmap<buffer> k<cr>
" set line number
nnoremap <silent><nowait>=n :setlocal norelativenumber<cr>
nnoremap <silent><nowait>\n :setlocal relativenumber<bar>setlocal number<cr>
" close/open number
nnoremap <silent><nowait>=N :setlocal norelativenumber<cr>:setlocal nonumber<cr>:set nolist<cr>
nnoremap <silent><nowait>\N :setlocal relativenumber<cr>:setlocal number<cr>:set list lcs=tab:¦\<space> <cr>
" set fold auto,use zE unset all fold,zf create fold
nnoremap <silent><nowait>=z :setlocal fdm=indent<cr>:setlocal fen<cr>
nnoremap <silent><nowait>\z :setlocal fdm=manual<cr>:setlocal nofen<cr>
nnoremap <silent><nowait>=o zO
nnoremap <silent><nowait>\o zC
nnoremap <silent><nowait><expr><bs> foldlevel('.')>0?"zc":"\<bs>"
" tab ctrl
nnoremap <silent><nowait>=t :tabnew<cr>
nnoremap <silent><nowait>\t :tabc<cr>
nnoremap <silent><nowait>[t :tabp<cr>
nnoremap <silent><nowait>]t :tabn<cr>
" set search noh
nnoremap <silent><nowait>\h :noh<cr>
nnoremap <silent><nowait>=h :set hlsearch<cr>
" set auto indent file
nnoremap <silent>=<tab> :call <sid>IndentSet()<cr>
func! s:IndentSet()abort
let line=matchstr(getline(line('.')),"^\\s*")
for temp in getline(line('.')+1, line('$'))
let temp=matchstr(temp,"^\\s*")|if temp!=line|break|endif
endfor
if (len(line)!=0&&line[0]==' ')||(len(temp)!=0&&temp[0]==' ')
setlocal expandtab|exec "setlocal shiftwidth=".abs(len(line)-len(temp))
endif
echo 'indent ok'
endfunc
func! g:SetTypeIndex(index_type,index_num) abort
if a:index_type=='tab'|setlocal noexpandtab
else|setlocal expandtab|endif
exec "setlocal shiftwidth=".a:index_num
exec "setlocal softtabstop=".a:index_num
exec "setlocal softtabstop=".a:index_num
endfunc
" delete <space> in end of line
nnoremap <silent><nowait>d<space> :%s/ *$//g<cr>:noh<cr><c-o>
nnoremap <nowait>g<space> :syntax match DiffDelete " *$"<cr>
" delete empty line
nnoremap <silent><nowait>dl :g/^\s*$/d<cr>
" select search
xmap g/ "sy/\V<c-r>=@s<cr>
" run macro in visual model
xnoremap @ :normal @
" repeat for macro
nnoremap <silent><c-q> @@
" md fold enable
let g:markdown_fold_enable=1
" termtask project config
command! -nargs=? -complete=customlist,termtask#Term_task_list TaskRun :call termtask#Term_task_run(<q-args>)
command! -nargs=0 TaskList :echo termtask#Term_task_list('','','')
command! -nargs=0 TaskLoad :call termtask#Term_task_run('')
nnoremap <space>c :TaskRun<space>
nnoremap <silent><space>C :call termtask#Term_config_edit()<cr>
" auto read project file
" let s:fileway=termtask#Term_get_dir() . '/.config.vim'
" if filereadable(s:fileway)
" execute 'source ' . s:fileway
" endif
" get key binding
let g:findkey_mode=0
nnoremap <leader>h :call findkey#get_key_msg(0)<cr>
nnoremap <silent>-h :call findkey#get_key_msg(1)<cr>
nnoremap <silent>]h :call findkey#open_file(1)<cr>
nnoremap <silent>[h :call findkey#open_file(0)<cr>
" show space indent line
nnoremap <silent><nowait>=I :call indentline#Enable()<cr>
nnoremap <silent><nowait>\I :call indentline#Disable()<cr>
" highlight color
nnoremap <silent><nowait>=c :call highlightcolor#Able()<cr>
nnoremap <silent><nowait>\c :call highlightcolor#DisAble()<cr>
" multcursor
nnoremap <silent><c-s> :call multcursor#Choose()<cr>
nnoremap <silent>-s :call multcursor#Toggle()<cr>
" rainbow-pair
nnoremap <silent><nowait>=b :call rainbow#load()<cr>
nnoremap <silent><nowait>\b :call rainbow#clear()<cr>
" rest test
augroup restful
au!
autocmd BufNewFile,BufRead *.rest silent! call rest#Able()
augroup END
cab pyj !python3 -m json.tool
nnoremap <space><space>i :call rest#VrcQuery(1)<CR>
nnoremap <space><space>I :call rest#VrcQuery(0)<CR>
" gutter for git
let g:gitgutter_sign_able=1
let g:gitgutter_highlight_able=0
nnoremap <silent>=g :call gutter#GitGutterAble()<cr>
nnoremap <silent>\g :call gutter#GitGutterDisable()<cr>
nnoremap <silent>[g :call gutter#GitGutterChangeTurn(0,line('.'))<cr>
nnoremap <silent>]g :call gutter#GitGutterChangeTurn(1,line('.'))<cr>
nnoremap <silent>-g :call gutter#GitGutterRecover()<cr>
nnoremap <silent>zg :call gutter#GitGutterFold()<cr>
nnoremap <silent><c-g> :call gutter#GitGutterDiff()<cr>
" editorconfig
nnoremap <silent>=E :call editorconfig#Able()<cr>
nnoremap <silent>\E :call editorconfig#Disable()<cr>
nnoremap <silent>-E :call editorconfig#EditconfigFile()<cr>
" line cword
let g:cursorline_delay=0
nnoremap <silent><nowait>=f :call cursorline#Able()<cr>
nnoremap <silent><nowait>-f :call cursorline#Toggle()<cr>
nnoremap <silent><nowait>\f :call cursorline#Disable()<cr>
" ici to tran
let g:term_cmd='~/.local/bin/ici'
xnoremap <silent><leader>i :call termtask#Term_cmd_exec_popup('v')<cr>
nnoremap <silent><leader>i :call termtask#Term_cmd_exec_popup('')<cr>
" use select area to replace
xnoremap s :<c-u>execute "normal! gv\"sy"<cr>:%s/\V<c-r>=escape(@s,'/\.')<cr>/<c-r>=escape(@s,'/\.')<cr>/gn<left><left><left>
nnoremap gs :%s/<c-r>=@/<cr>//gn<left><left><left>
xnoremap gs :<c-u>execute "normal! gv\"sy"<cr>:call <sid>ReplaceGlobal(@s)<cr>
func s:ReplaceGlobal(str) abort
let escape_char='."'
let str=escape(a:str,escape_char)|let replace=escape(input("replace ".a:str." to:",a:str),escape_char)
if replace==""|return|endif
let sed='sed'|if has('macunix')|let sed='gsed'|endif
echo system('find . -path "./.git" -prune -o -type f -exec '.sed.' -i "s|'.str.'|'.replace.'|g" {} +')
" reload file
exec ":edit ".expand('%')
endfunc
" object buffer
nnoremap <silent><nowait> =e gg=G
onoremap <silent>ae :<c-u>normal! ggVG<cr>
xnoremap <silent>ae :<c-u>normal! ggVG<cr>
" object line
onoremap <silent>il :<c-u>normal! ^v$BE<cr>
xnoremap <silent>il :<c-u>normal! ^v$<cr><left>
onoremap <silent>al :<c-u>normal! 0v$<cr>
xnoremap <silent>al :<c-u>normal! 0v$<cr>
" object argc
onoremap <silent>aa :<c-u>call obj#GetArgs('a')<cr>
onoremap <silent>ia :<c-u>call obj#GetArgs('i')<cr>
xnoremap <silent>aa :<c-u>call obj#GetArgs('a')<cr>
xnoremap <silent>ia :<c-u>call obj#GetArgs('i')<cr>
" object indent
onoremap <silent>ai :<c-u>call obj#GetIndent(0)<cr>
onoremap <silent>ii :<c-u>call obj#GetIndent(1)<cr>
xnoremap <silent>ai :<c-u>call obj#GetIndent(0)<cr>
xnoremap <silent>ii :<c-u>call obj#GetIndent(1)<cr>
" object syntax
onoremap <silent>ih :<c-u>call obj#GetSynchl('i')<cr>
xnoremap <silent>ih :<c-u>call obj#GetSynchl('i')<cr>
" object bigword
onoremap <silent>iq :<c-u>call obj#GetBigWord('i')<cr>
xnoremap <silent>iq :<c-u>call obj#GetBigWord('i')<cr>
" object all
onoremap <silent>i/ :<c-u>call obj#GetAllObj('i','/')<cr>
xnoremap <silent>i/ :<c-u>call obj#GetAllObj('i','/')<cr>
onoremap <silent>i- :<c-u>call obj#GetAllObj('i','-')<cr>
xnoremap <silent>i- :<c-u>call obj#GetAllObj('i','-')<cr>
onoremap <silent>i. :<c-u>call obj#GetAllObj('i','.')<cr>
xnoremap <silent>i. :<c-u>call obj#GetAllObj('i','.')<cr>
onoremap <silent>i* :<c-u>call obj#GetAllObj('i','*')<cr>
xnoremap <silent>i* :<c-u>call obj#GetAllObj('i','*')<cr>
" easy to get obj
onoremap <silent>i, i<
onoremap <silent>a, a<
xnoremap <silent>i, i<
xnoremap <silent>a, a<
onoremap <silent>i; i"
onoremap <silent>a; a"
xnoremap <silent>i; i"
xnoremap <silent>a; a"
onoremap <silent>in i{
onoremap <silent>an a{
xnoremap <silent>in i{
xnoremap <silent>an a{
" sudo to write file
func! SaveAsRoot()
execute "silent! w !pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY tee % >/dev/null"
" reload buffer
exec ":edit! ".expand('%')
endfunc
cab w!! call SaveAsRoot()
" quick to change dir
cab <expr> cdn getcmdtype() == ':' ? "cd ".expand('%:p:h') : "cdn"
cab <expr> cdr getcmdtype() == ':' ? "cd ".termtask#Term_get_dir() : "cdr"
" cmd emacs model
cnoremap <c-a> <home>
cnoremap <c-e> <end>
cnoremap <c-d> <del>
cnoremap <c-h> <left>
cnoremap <c-l> <right>
cnoremap <c-b> <s-left>
cnoremap <c-f> <s-right>
" cmd pair
let g:pair_map={'(':')','[':']','{':'}','"':'"',"'":"'",'<':'>','`':'`',}
func! s:Judge(ch,mode)
if a:mode=='c'&&getcmdtype()!=':'|return a:ch|endif
if a:mode!='c'|let ch=getline('.')[col('.')-1]|else|let ch=getcmdline()[getcmdpos()-1]|endif
if a:ch=='"'||a:ch=="'"||a:ch=='`'|if ch!=a:ch|return a:ch.a:ch."\<left>"|endif|endif
if ch==a:ch|return "\<right>"|endif
return a:ch
endfunc
func! s:Backspace(mode)
if a:mode!='c'
let s:pair=getline('.')[col('.')-1]|let s:pair_l=getline('.')[col('.')-2]
else
let s:pair=getcmdline()[getcmdpos()-1]|let s:pair_l=getcmdline()[getcmdpos()-2]
endif
if has_key(g:pair_map, s:pair_l)&&(g:pair_map[s:pair_l]==s:pair)|return "\<right>\<bs>\<bs>"|else|return "\<bs>"|endif
endfunc
cnoremap <expr>( getcmdtype()==':' ? "()\<left>" : "("
cnoremap <expr>[ getcmdtype()==':' ? "[]\<left>" : "["
cnoremap <expr>{ getcmdtype()==':' ? "{}\<left>" : "{"
cnoremap <expr>" <sid>Judge('"','c')
cnoremap <expr>` <sid>Judge('`','c')
cnoremap <expr>' <sid>Judge("'",'c')
cnoremap <expr>> <sid>Judge('>','c')
cnoremap <expr>) <sid>Judge(')','c')
cnoremap <expr>} <sid>Judge('}','c')
cnoremap <expr>] <sid>Judge(']','c')
cnoremap <expr><bs> <sid>Backspace('c')
" jump >
inoremap <expr><silent>> <sid>Judge('>','i')
" set cursor middle
nnoremap <c-o> <c-o>zz
nnoremap <c-i> <c-i>zz
" set tab indent
xnoremap <tab> >gv
xnoremap <s-tab> <gv
" set tab next snippet
smap <tab> <c-j>
smap <s-tab> <c-k>
" enhance gf
nnoremap gf gF
vnoremap gf gF
" set split window
nnoremap <silent><nowait>_ :vsp<cr>:bn<cr>
nnoremap <silent><nowait>+ :sp<cr>:bn<cr>
" edit file
nnoremap e :edit<space><c-r>=getcwd()<cr>/
nnoremap E :edit<space><c-r>=expand('%:p:h')<cr>/
nnoremap <leader>e :edit<space>~/
" open : quick
nnoremap <space>; :
xnoremap <space>; :
" bs to delete
xnoremap <silent><bs> d
snoremap <silent><bs> <space><bs>
" add empty line
nnoremap <silent><nowait>U :call append(line('.')-1,"")<cr>
nnoremap <silent><nowait>M :call append(line('.'),"")<cr>
" make move easy
nnoremap <silent><c-e> $
vnoremap <silent><c-e> $
nnoremap <silent><expr><c-a> getline('.')[col('.')-1]>='0'&&getline('.')[col('.')-1]<='9'?"\<c-a>":"^"
vnoremap <silent><expr><c-a> mode()==#'v'&&line('.')==line('v')?"^":"\<c-a>"
" enhance c-a and c-x
nnoremap <silent><expr>g<c-a> getline('.')[col('.')-1]=='9'?"r0":"r".(getline('.')[col('.')-1]+1)
nnoremap <silent><expr>g<c-x> getline('.')[col('.')-1]=='0'?"r9":"r".(getline('.')[col('.')-1]-1)
" add space
func! s:AddSpace()
execute("normal! i ")|redraw|let ch=nr2char(getchar())
while ch==' '|execute("normal! i ")|redraw|let ch=nr2char(getchar())|endwhile
call feedkeys(ch,'im')
endfunc
nnoremap <silent><leader><space> :call <sid>AddSpace()<cr>
" scroll in other window
nnoremap <silent>\u <c-w>p<c-u><c-w>p
nnoremap <silent>\d <c-w>p<c-d><c-w>p
" redraw the screen
nnoremap <silent>R :redr!<cr>
" ctrl file system
command! -nargs=0 -bang Pwd echo expand('%:p')
command! -nargs=? -bang Reload exec ":edit ".<q-args>." ".expand('%')
nnoremap <silent>S :edit<space><c-r>=expand('%')<cr><cr>
command! -nargs=0 -bang Delete if filereadable(expand('%'))|w|call delete(expand('%'))|call <sid>CloseBuf()|execute ":bn"|endif
command! -nargs=1 -bang -complete=file Rename let @s=expand('%')|f <args>|w<bang>|call delete(@s)
cab <expr>Rename "Rename ".expand('%:p:h')."/"
command! -nargs=1 -bang -complete=file Mkdir echo mkdir(<f-args>)
cab <expr>Mkdir "Mkdir ".expand('%:p:h')."/"
command! -nargs=1 -bang -complete=file Rmdir echo delete(<f-args>,"d")
cab <expr>Rmdir "Rmdir ".expand('%:p:h')."/"
command! -nargs=0 -bang Write call mkdir(expand("%:p:h"),"p")|write!
" use cd to change dir
" autoload file
func s:SetUpdateTime(delay) abort
setlocal readonly
if a:delay==""|let delay=1000
else|let delay=a:delay|endif
if !exists("s:update_timer")||s:update_timer==-1|let s:update_timer=timer_start(delay, "TimerUpdate",{"repeat":-1})|echo "check begin"
else|call timer_stop(s:update_timer)|let s:update_timer=-1|echo "check stop"|setlocal noreadonly|endif
endfunc
func TimerUpdate(timer)
checktime
execute "normal! Gzz"
endfunc
command! -nargs=? -bang Check call s:SetUpdateTime(<q-args>)
" select move
xnoremap <silent><up> :move '<-2<cr>gv
xnoremap <silent><down> :move '>+1<cr>gv
xnoremap <silent><right> y<c-w>lo<c-[>Vpgv
xnoremap <silent><left> y<c-w>ho<c-[>Vpgv
xnoremap <silent><c-j> :move '>+1<cr>gv
xnoremap <silent><c-k> :move '<-2<cr>gv
xnoremap <silent><c-l> y<c-w>lo<c-[>Vpgv
xnoremap <silent><c-h> y<c-w>ho<c-[>Vpgv
" open link,is default in vim by gx
func! s:GotoLink()
let s:list=matchstrpos(getline('.'),'https*://\S[^][(){}]*',0)
let s:link=s:list[0]
while s:list[0]!=''&&(s:list[1]>col('.')||s:list[2]<col('.'))
let s:list=matchstrpos(getline('.'),'https*://\S[^][(){}]*',s:list[2])
endwhile
if s:list[0]!=''|let s:link=s:list[0]|endif
let s:browser=get(g:,'default_browser','firefox')
if s:link!=''|call jobstart(s:browser.' '.s:link)|else|echo 'cannot find link'|endif
endfunc
nnoremap <silent><nowait>gl :call <sid>GotoLink()<cr>
" set alias
iab ;e 1607772321@qq.com
iab ;n chenxuan
nnoremap \a :iabc<cr>
nnoremap =a :ab<cr>
" set function to choose select area
func s:GetSelectArea()
norm! gv"sy
let split_ch="'"
if stridx(@s, split_ch)!=-1|let split_ch = '"'|endif
return split_ch.@s.split_ch
endfunc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" plug config setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" tokyonight themes
set termguicolors
let g:tokyonight_style = 'night' " available: night, storm
let g:tokyonight_enable_italic = 1
colorscheme tokyonight
" onedark themes
" let g:onedark_termcolors=256
" colorscheme onedark
" set prepare code when new file
augroup PreCode
autocmd!
autocmd BufNewFile *.cpp,*.cc,*.go,*.py,*.sh,*.hpp,*.h,*.html,.config.vim,CMakeLists.txt call VimFastSetPreCode()
augroup END
" nvim-tree
nnoremap <silent><leader>n :NvimTreeToggle<cr>
nnoremap <silent><leader>N :NvimTreeFocus<cr>
func s:NvimTreeFind()
lua require('nvim-tree.api').tree.find_file()
endfunc
augroup NvimTree
autocmd!
" 当进入缓冲区时,如果仅存一个窗口且为 nvim-tree,则切换到下一个缓冲区
autocmd BufEnter * if winnr('$') == 1 && &filetype == 'NvimTree' | :bn |endif
autocmd BufEnter * if &filetype != 'NvimTree'| call s:NvimTreeFind()|endif
augroup END
" diffview.nvim
function! DiffviewToggle()
if luaeval('next(require("diffview.lib").views) ~= nil')
DiffviewClose
else
DiffviewOpen
endif
endfunction
command! DiffviewToggle call DiffviewToggle()
nnoremap <silent><space>d :DiffviewToggle<cr>
" coc.nvim
let g:coc_disable_startup_warning = 1
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1):
\ CheckBackspace() ? "\<TAB>" :
\ coc#refresh()
" seting for diff copilot and coc
inoremap <silent><expr> <S-TAB>
\ coc#pum#visible() ? coc#pum#next(1):
\ CheckBackspace() ? "\<TAB>" :
\ coc#refresh()
" inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
inoremap <silent><expr><right> coc#pum#visible() ? coc#pum#confirm() : "\<right>"
inoremap <silent><expr><c-p> coc#pum#visible() ? coc#pum#prev(1) : "\<c-[>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" coc find define
nmap <leader>u <Plug>(coc-definition)
nmap <leader>U <Plug>(coc-type-definition)
nmap <silent>gd <Plug>(coc-definition)
nmap <silent>gD <Plug>(coc-type-definition)
nmap <silent>gr <Plug>(coc-references)
nmap <silent>gi <Plug>(coc-implementation)
" coc refactor code
nmap <space>r <Plug>(coc-refactor)
nmap <leader>r <Plug>(coc-rename)
" coc find wrong
nmap <silent><F3> <Plug>(coc-diagnostic-prev)
nmap <silent><F4> <Plug>(coc-diagnostic-next)
nmap <silent>[w <Plug>(coc-diagnostic-prev)
nmap <silent>]w <Plug>(coc-diagnostic-next)
nmap <silent>-w <Plug>(coc-fix-current)
nnoremap <silent><nowait>=w :<C-u>CocList --normal diagnostics<cr>
nnoremap <silent><nowait><space>w :<C-u>CocList --normal diagnostics<cr>
" coc text obj
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" coc code action
nmap <leader>a <Plug>(coc-codeaction)
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>l <Plug>(coc-codelens-action)
" coc select range
nmap <silent><leader>s <Plug>(coc-range-select)
xmap <silent><leader>s <Plug>(coc-range-select)
" coc format
command! -nargs=0 Format :call CocActionAsync('format')
command! -nargs=0 Import :call CocActionAsync('runCommand', 'editor.action.organizeImport')
nmap <leader><leader>f :Format<cr>
" coc config
nmap <silent><nowait><space><space>c :CocConfig<cr>
nmap <silent><nowait><space><space>l :CocList --normal extensions<cr>
nmap <silent><nowait><space><space>j :CocList outline<cr>
" coc currnt tag
nnoremap <silent><nowait><space><space>k :echo CocAction('getCurrentFunctionSymbol')<cr>
" coc help
nnoremap <silent> K :call ShowDocumentation()<cr>
nnoremap <silent> gh :call ShowDocumentation()<cr>
" coc mouse
nmap <c-LeftMouse> <LeftMouse><Plug>(coc-definition)
nmap <a-LeftMouse> <LeftMouse><Plug>(coc-definition)
nmap <c-RightMouse> <LeftMouse>:call ShowDocumentation()<cr>
nmap <a-RightMouse> <LeftMouse>:call ShowDocumentation()<cr>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')|call CocActionAsync('doHover')
else|call feedkeys('K', 'in')
endif
endfunction
func! g:CocMenu()
if &bt == ''
nmenu <silent>PopUp.Coc\ Define gd
nmenu <silent>PopUp.Coc\ Refer gr
endif
endfunc
call AddMouseMenu(function('CocMenu'))
" vista and tagbar
nnoremap <silent> <leader>t :Vista!!<cr>
let g:tagbar_width = 22
let g:vista_default_executive = 'ctags'
let g:vista#renderer#enable_icon = 0
let g:vista_sidebar_width = 22
let g:vista_echo_cursor = 0
let g:vista_stay_on_open = 0
" exit vim if vista is the only window remaining in the only tab.
augroup Vista
autocmd!
autocmd BufEnter * if ( &ft == 'vista' || &ft == 'vista_markdown' ) && winnr('$') == 1 | call feedkeys(":vsplit|bn\<cr>") | endif
augroup END
" auto pair
let g:AutoPairsMapCh = 0
let g:AutoPairsMapSpace = 0
" dash board
let g:dashboard_disable_statusline=1
" let g:dashboard_icon_disable=1
" vim-easymotion
let g:EasyMotion_smartcase = 1
map <leader>w <Plug>(easymotion-bd-w)
map <leader>f <Plug>(easymotion-s)
nmap <silent>s <Plug>(easymotion-s)
imap <silent><c-s> <c-o>s
" python-highlight
let g:python_highlight_all = 1
" vim-go-highlight
let g:go_highlight_functions = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_space_tab_error = 1
let g:go_highlight_trailing_whitespace_error = 1
let g:go_highlight_operators = 1
let g:go_highlight_function_parameters = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_types = 1
let g:go_highlight_build_constraints =1