-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
2037 lines (1846 loc) · 73.2 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
if 0
source ~/_vim9rc
finish
endif
let g:mapleader ="\<space>"
" 1/0 for bool v:true/v:false
let s:is_win = has('win32')
let s:v = $HOME.(s:is_win ? '\vimfiles' : '/.vim')
let s:is_work = 0
let s:is_cursor_col = 1
let s:is_trans = 0
let s:is_dbglog = 0
function s:CONFIG_vim_base() "{{{
" win外部程序依赖 (不包含 f2菜单 启动项): rg ctags gtags python3 pwsh(powershell7) html-beautify
"OS
"{{{
if s:is_win
set shell=cmd.exe
set shellcmdflag=/c
set encoding=utf-8
" Set PowerShell as shell
"设置后 plug.vim 使用git的 转义字符错误 , 无法打开temp文件 , 命令出错
"set shell=pwsh.exe
"set shellcmdflag=-NoProfile\ -NoLogo\ -NonInteractive\ -Command
"set shellpipe=|
"set shellredir=>
else
" wsl vim
set t_u7=
"set t_Co=256
endif
" }}}
"GUI
"{{{
if has('gui_running')
" GUI font{{{
"if has("gui_gtk2")
" :set guifont=Luxi\ Mono\ 12
"elseif has("x11")
" " Also for GTK 1
" :set guifont=*-lucidatypewriter-medium-r-normal-*-*-180-*-*-m-*-*
"elseif has("gui_win32")
" :set guifont=Luxi_Mono:h12:cANSI
"endif
"set guifont=Sarasa_Term_SC:h10 Term 不是等宽, 导致斜体英文超出显示范围 , W600 字重
set guifont=sarasa_mono_SC_Nerd:h11:W600
"set guifont=sarasa_mono_SC_Nerd_font:h11:W600
"启用此行后菜单和提示气泡中文乱码
"set gfw=youyuan:h10.5:cGB2312:qDRAFT
"set guifont=Bitstream_Vera_Sans_Mono:h10:cANSI
"set guifont=Ubuntu_Mono_derivative_Powerlin:h10:cANSI
"set guifontwide=幼圆:h10.5:cGB2312
"}}}
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"gui选项,去掉菜单栏等
" :h guioptions 帮助
set guioptions-=m
set guioptions-=T
set guioptions-=r
set guioptions-=L
"tab
"set guioptions-=e
" example from https://github.com/rstacruz/vim-from-scratch
"set transparency =0 " not work in win32 gvim
"set guifont=Iosevka\ Medium:h16 linespace=-1
"set guioptions+=gme " gray menu items, menu bar, gui tabs
set antialias
"color ir_black+
else
" console colorscheme
"Plug 'chriskempson/base16-vim'
"color base16
endif
"}}}
"normal
"{{{
" 显示状态行当前设置
"set statusline
" 设置状态行显示常用信息
" {{{
" %F 完整文件路径名
" %m 当前缓冲被修改标记
" %m 当前缓冲只读标记
" %h 帮助缓冲标记
" %w 预览缓冲标记
" %Y 文件类型
" %b ASCII值
" %B 十六进制值
" %l 行数
" %v 列数
" %p 当前行数占总行数的的百分比
" %L 总行数
" %{...} 评估表达式的值,并用值代替
" %{"[fenc=".(&fenc==""?&enc:&fenc).((exists("+bomb") && &bomb)?"+":"")."]"} 显示文件编码
" %{&ff} 显示文件类型
" }}}
"set statusline=set statusline=%F%m%r%h%w%=\ [ft=%Y]\ %{\"[fenc=\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\"+\":\"\").\"]\"}\ [ff=%{&ff}]\ [asc=%03.3b]\ [hex=%02.2B]\ [pos=%04l,%04v]\ [%p%%]\ [len=%L]
" 设置 laststatus = 0 ,不显式状态行
" 设置 laststatus = 1 ,仅当窗口多于一个时,显示状态行
" 设置 laststatus = 2 ,总是显式状态行
" 无此行 lightline 也不显示
set laststatus=2
"set cmdheight=2
set updatetime=300
" 不要将消息传递给|插入完成菜单|。
set shortmess+=c
set noswapfile
set nobackup
set nowritebackup
set noundofile
"'ts' 是制表符的显示方式; 'sts' 是按下 Tab 键时要插入多少个"空格"; 'sw' 是每个缩进级别使用多少个"空格"; 'et' 是使用空格还是制表符; 'sta' 允许您在行首按 Tab 键时插入 'sw'"空格"
set et
set ts=4
set sw=4
"filetype plugin indent on
"set omnifunc=syntaxcomplete#Complete
"set background=dark " recover plugin floaterm highlight Floaterm FloatermBorder color
"折行
set sidescroll=80
"set linebreak
"set breakat-=_
"set showbreak=++++
set cpoptions+=n
nnoremap <expr> j v:count == 0 ? 'gj' : 'j'
nnoremap <expr> k v:count == 0 ? 'gk' : 'k'
"
"开启后乱码
"开启此行后菜单中文乱码
set enc=utf-8
set fenc=utf8
"set termencoding=cp936
set fencs=utf-8,chinese,cp936,ucs-bom,
"set fileencodings=utf-8,chinese
"
""解决consle输出乱码
"language messages zh_CN.cp936
"language messages en_US.utf-8
"
"set langmenu=en_US
"let $LANG = 'en_US'
" 设置显示不可见字符
" NonText" 高亮会用于 "eol"、"extends" 和 "precedes"
" "SpecialKey" 用于 "nbsp","space"、"tab" 和 "trail"
hi SpecialKey gui=reverse guifg=#333333
hi NonText gui=reverse guifg=#333333
"set listchars=tab:> ,trail:-,extends:>,precedes:<,nbsp:+,space:·
"set lcs+=space:·
"set lcs=tab:>_,trail:-,extends:>,precedes:<,nbsp:+,space:·,eol:$
set lcs=tab:>_,trail:-,extends:>,precedes:<,nbsp:+
set list
"set invlist
set relativenumber
set nu
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
augroup END
" autoit 3000行时 重绘超时 , 语法高亮被禁用
" 设定更大的超时时间
set redrawtime=10000
" 无声
"set noeb
" 闪屏代替声
set vb
" cursor {{{
set cursorline
let v:colornames['cursor_bg'] = s:is_trans ? '#333333' : v:colornames['black']
hi Cursor cterm=reverse gui=reverse
hi CursorLine guibg=cursor_bg ctermbg=black
"if s:is_win || !s:is_trans
if s:is_cursor_col
set cursorcolumn
hi CursorColumn guibg=cursor_bg ctermbg=black
endif
"hi CursorColumn cterm=reverse gui=reverse
"hi CursorLine cterm=reverse gui=reverse
"}}}
" default cterm=underline or undercurl ctermul guisp
hi ErrorText guifg=yellow guibg=red
"hi CocErrorHighlight links to ErrorText
"tab
"'guitabtooltip' 'gtt'
"Setting 'guitablabel'
"'guitablabel' 'gtl'
" hi Title
"hi VertSplit gui=none cterm=reverse
"hi Folded ctermfg=grey ctermbg=darkgrey
"hi FoldColumn ctermfg=4 ctermbg=7
set guioptions-=e
"set guitablabel=%N\ %t\ %M
"set tabline=%N/\ %t\ %M
" not active tab page label
"hi TabLine ctermfg=white ctermbg=black
"" where there are no labels
"hi TabLineFill guifg=white guibg=dimgray
" "ctermbg=dimgray
""active tab page label
"hi TabLineSel guifg=white guibg=cyan1
"ctermbg=cyan1
"hi diffAdded gui=bold guifg=LightGreen
"hi diffRemoved gui=bold guifg=LightRed
"hi diffFile gui=NONE guifg=LightBlue
"hi gitcommitDiff gui=NONE guifg=LightBlue
"hi diffIndexLine gui=NONE guifg=LightBlue
"hi diffLine gui=NONE guifg=white
hi visual gui=reverse cterm=reverse
"hi visual guibg=#555555 ctermbg=555 term=reverse
hi Search gui=bold guifg=black guibg=white
hi CurSearch gui=bold guifg=#000000 guibg=#FD971f
hi IncSearch gui=bold guifg=black guibg=white
"term=reverse ctermbg=3
set hlsearch
set incsearch
" 上条后 so $MYVIMRC时 会直接高亮之前搜索结果 , 此条关闭
nohl
set whichwrap=b,s,<,>,[,],h,l
" * register (select text) system clipboard
"set clipboard=unnamed
" + register : x window clipboard
set clipboard=unnamedplus
" markdown context always auto fold , this disable
set foldlevelstart=0
"line 1 按j 跳过 line2 直接到line3
"set lines=4
"set columns=68
":e ~/ttttt
set foldmethod=marker
"set nofoldenable
set completeopt=menu,menuone
set list
set cino=(0
set menc=cp936
" when source vimrc , file will be modified (+)
"set ff=unix
set sb
set spr
set nofixendofline
set wildchar=<Tab> wildmenu wildmode=full
set report =0
set synmaxcol =200
set modeline
"set cole=0
" re map show full path
nnoremap <c-g> 1
let g:vimsyn_embed = 'P'
" }}}
endfunction "}}}
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
function s:CONFIG_vimplug() "{{{
call plug#begin('~/.vim/plugged')
"temp {{{
"Plug 'markmap/coc-markmap'
Plug 'github/copilot.vim',
Plug 'jeetsukumaran/vim-filebeagle'
"Plug 'preservim/nerdtree'
"Plug 'justinmk/vim-dirvish'
"
"Plug 'yaegassy/coc-marksman',
""Plug 'mbbill/undotree'
"Plug 'pboettch/vim-cmake-syntax'
"Plug 'rhysd/vim-clang-format'
""Plug 'osyo-manga/vim-over'
"Plug 's3rvac/vim-syntax-yara'
""Plug 'Shougo/vimproc.vim', {'do' : 'make'}
""Plug 'yuratomo/w3m.vim'
""Plug 'ashisha/image.vim'
""Plug 'fidian/hexmode' " open pdf create temp file error
""Plug 'vim-scripts/hexman.vim'
""Plug 'severin-lemaignan/vim-minimap'
""Plug 'wfxr/minimap.vim'", {'do': ':!cargo install --locked code-minimap'} " need comment plugin/minimap.vim 210 line , nunmap *#
""Plug 'puremourning/vimspector'
""Plug 'RRethy/vim-illuminate' " 高亮当前光标单词 ,因遮盖 mark 插件高亮, 停用
""Plug 'mhinz/vim-startify'
""Plug 'christianrondeau/vim-base64'
""Plug 'mattn/webapi-vim'
""Plug 'mattn/vim-gist' "TODO:加一键更新vimrc
""Plug 'fidian/hexmode'
""Plug 'rootkiter/vim-hexedit' "hex 编辑时 右侧实时预览ASCII windows无法打开temp文件 , 可能因为\符号转义
""}}}
"base {{{
"无架构依赖 , win linux 通用 , linux 最小使用
Plug 'yianwillis/vimcdoc'
Plug 'Yggdroot/indentLine' " mess up markdown set cole=0
"Plug 'preservim/vim-indent-guides'
Plug 'junegunn/vim-easy-align'
Plug 'inkarkat/vim-ingo-library' "mark 插件的依赖
Plug 'inkarkat/vim-mark'
Plug 'easymotion/vim-easymotion'
"Plug 'frazrepo/vim-rainbow' " 会被语法高亮覆盖 , 用下面的代替
Plug 'luochen1990/rainbow'
Plug 'sainnhe/sonokai' " monokai pro machine
Plug 'skywind3000/vim-quickui'
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
"Plug 'voldikss/vim-floaterm'
Plug 'skywind3000/asyncrun.vim'
Plug 'voldikss/vim-translator'
"Plug 'plasticboy/vim-markdown'
"}}}
"code base {{{
Plug 'itchyny/lightline.vim'
Plug 'liuchengxu/vista.vim'
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" CocList extensions TODO explorer 安装后Ce无用
"Plug 'weirongxu/coc-explorer', {'do': 'yarn install --frozen-lockfile'}
""Plug 'voldikss/coc-bookmark', {'do': 'yarn install --frozen-lockfile'}
"Plug 'voldikss/coc-floaterm', {'do': 'yarn install --frozen-lockfile'}
"Plug 'jackguo380/vim-lsp-cxx-highlight'
"Plug 'm-pilia/vim-ccls'
Plug 'sheerun/vim-polyglot' " 各语言语法高亮规则 缩进规则
"Plug 'uiiaoo/java-syntax.vim'
"Plug 'OrangeT/vim-csharp'
"Plug 'mzlogin/vim-smali'
"Plug 's3rvac/vim-syntax-yara'
"}}}
"code win {{{
"Plug 'vim-scripts/visual_studio.vim'
Plug 'spiiph/visual_studio'
"Plug 'pprovost/vim-ps1'
"}}}
" code linux {{{
"Plug 'francoiscabrol/ranger.vim'
"}}}
"misc {{{
"Plug 'godlygeek/tabular'
"
"Plug 'tpope/vim-fugitive'
"Plug 'ryanoasis/vim-devicons'
"}}}
call plug#end()
endfunction "}}}
call <sid>CONFIG_vimplug()
" plug config {{{
function s:CONFIG_plugs_base() "{{{
" indentLine {{{
let g:indentLine_char_list = ['|', '¦', '┆', '┊']
"let g:indentLine_color_term = 239
"let g:indentLine_bgcolor_term = 202
"let g:indentLine_bgcolor_gui = '#FF5F00'
"markdown set cole=0 not work
let g:indentLine_setConceal = 0
"let g:vim_json_conceal=0
"let g:markdown_syntax_conceal=0
"
" }}}
" clang format {{{
let g:clang_format#detect_style_file=1
"let g:clang_format#code_style='Microsoft'
autocmd FileType c let g:clang_format#auto_format_on_insert_leave = 0
"let g:clang_format#command = "C:\Program Files\LLVM\bin\clang-format.exe"
"AlignAfterOpenBracket" : "BAS_Align",
"AllowShortIfStatementsOnASingleLine" : "SIS_Never",
"AllowShortLoopsOnASingleLine" : "SLS_Never",
"BreakBeforeBraces" : "AfterFunction",
"UseTab" : "true",
let g:clang_format#style_options = {
\"IndentWidth" : "4",
\"IndentCaseLabels" : "true",
\"ColumnLimit" : "0",
\"PointerAlignment": "Left",
\}
"map <C-k> :py3f "C:\Program Files\LLVM\share\clang\clang-format.py --version"<cr>
"map <C-k> :py3f 'C:\Program Files\LLVM\share\clang\clang-format.py'<cr>
"imap <C-k> <c-o>:py3f ~/PATH/TO/clang-format.py<cr>
"autocmd FileType c,cpp,objc nnoremap <buffer><Leader>f :<C-u>ClangFormat<CR>
"autocmd FileType c,cpp,objc vnoremap <buffer><Leader>f :ClangFormat<CR>
" if you install vim-operator-user
"autocmd FileType c,cpp,objc map <buffer><Leader>x <Plug>(operator-clang-format)
" Toggle auto formatting:
"nmap <Leader>af :ClangFormatAutoToggle<CR>
command Afl let g:clang_format#auto_format_on_insert_leave=0
command Afle echo g:clang_format#auto_format_on_insert_leave
command Af ClangFormatAutoToggle
" }}}
"plug mark{{{
" \m : 将cursor下的单词加到下一个高亮group中
" [N]\m : 将cursor下的单词加到指定的高亮group中
" * 假如指定的高亮group已经有一个单词,则做或操作
" * 假如cursor下的单词已经在某个高亮group中,则这个指令将删除这个
" group
" * 如果是在visual模式下,则对visual选择的部分做这个操作
" * 当N比9大时,则用提示的方式要求用户选择一个group
" \n : 将cursor下的单词所在的group删除
" [N]\n : 将指定的group删除
" :[N]Mark : 删除group N
" :[N]Mark[!] <pattern> : 在不指定group时,如果<pattern>不符合任何一个
" group,将其加入下一个group;如果<pattern>符合某个group,删除这
" 个group。
" 如果指定了group,则用增加或移除的方式修改那个group,除非用”!”,此
" 时用强制赋值的方式修改那个group
" 全局命令
" :Marks : 显示所有Marks,”>”对应下一个默认组,”/”对应上一次搜索的组
" :Mark : 禁用所有Marks,但并不删除它们
" :MarkClear : 删除所有Marks
" 搜索命令
" \* : 搜索同一个group中下一个实例
" \# : 相反于\*
" \/ : 搜索所有group中下一个实例
" \? : 相反与\/
" * : 当cursor下的单词在group中时,重复上一次的\*,\#或\/,\?
" 当cursor下的单词不在group中时,使用默认的VIM行为
" # : 相反于*
" 小键盘数字
" [N][1~9] : 小键盘的1到9对应9个group,搜索该group中的下N个实例
" [N][C-1~9] : 加Ctrl键,反方向搜索
"}}}
" mark {{{
" mark 插件的增强颜色
let g:mwDefaultHighlightingPalette = 'extended'
nmap <Plug>IgnoreMarkSearchNext <Plug>MarkSearchNext
nmap <Plug>IgnoreMarkSearchPrev <Plug>MarkSearchPrev
nmap * <Plug>MarkSearchOrCurNext
nmap # <Plug>MarkSearchOrCurPrev
nmap <leader>m <Plug>MarkSet
nmap <leader>mr <Plug>MarkRegex
nmap <Leader>mt <Plug>MarkToggle
nmap <Leader>mcc <Plug>MarkClear " avoid conflict with <leader>n :nohl
nmap <Leader>ma <Plug>MarkAllClear
"}}}
"easymotion {{{
"map <Leader>e <Plug>(easymotion-prefix)
"map <Leader>m <Plug>(mark-prefix)
let g:EasyMotion_do_mapping = 0 " Disable default mappings
" Turn on case-insensitive feature
let g:EasyMotion_smartcase = 1
" Jump to anywhere you want with minimal keystrokes, with just one key binding.
" `s{char}{label}`
"nmap s <Plug>(easymotion-overwin-f)
" or
" `s{char}{char}{label}`
" Need one more keystroke, but on average, it may be more comfortable.
nmap <Leader>s <Plug>(easymotion-overwin-f2)
"}}}
" rainbow
let g:rainbow_active = 1
let g:rainbow_conf = { 'separately': { 'cmake': 0, } }
" color{{{
"colorscheme molokai
" plug sonokai config
if has('termguicolors')
set termguicolors
endif
" vim help : xterm-true-color
" 只要终端支持,Vim 支持终端真彩 (使用 |highlight-guifg| 和 |highlight-guibg|)。
" 为此,置位 'termguicolors' 选项。
" https://gist.github.com/XVilka/8346728 有支持真彩的终端列表。
" 有时置位 'termguicolors' 还不够,还需要显式设置 |t_8f| 和 |t_8b| 选项。这些选
" The configuration options should be placed before `colorscheme sonokai`.
let g:sonokai_style = 'atlantis'
"let g:sonokai_style = 'andromeda'
"let g:sonokai_style = 'maia'
let g:sonokai_enable_italic = 0
let g:sonokai_disable_italic_comment = 1
colorscheme sonokai
" st-alpha opacity , only work in tmux ??
" !! in '!!system()' mean convert system() return value to bool (':h type()' 6)
if s:is_trans
if !!system('pgrep st-alpha') && !!system('pgrep picom')
hi Normal guibg=NONE
hi EndOfBuffer guibg=NONE
else
call Msgbox("linux not support transparency")
endif
else
"hi Normal guibg=#333333
endif
"}}}
nnoremap <Leader>h :Hexmode<CR>
"inoremap <Leader>h <Esc>:Hexmode<CR>
vnoremap <Leader>h :<CU>Hexmode<CR>
"let g:floaterm_shell = "wsl"
let g:floaterm_shell = "pwsh -nologo "
"let g:floaterm_shell = "C:\\tools\\open_code\\msys64\\usr\\bin\\zsh.exe"
"let g:floaterm_wintype = 'fl'
let g:floaterm_width = 0.8
let g:floaterm_height = 0.8
let g:floaterm_autoclose =2
command -nargs=* Fn FloatermNew <args>
let g:floaterm_keymap_new = '<F6>'
let g:floaterm_keymap_toggle = '<F7>'
let g:floaterm_keymap_prev = '<F8>'
let g:floaterm_keymap_next = '<F9>'
let g:floaterm_keymap_kill = '<f10>'
" Configuration example
" Set floaterm window's background to black
hi Floaterm guibg=#666666
" Set floating window border line color to cyan, and background to orange
hi FloatermBorder guifg=cyan
" vista {{{
" Executive used when opening vista sidebar without specifying it.
" 执行程序在未指定Vista侧边栏时使用。
" See all the avaliable executives via `:echo g:vista#executives`.
let g:vista_highlight_whole_line = 1
let g:vista_stay_on_open = 0
let g:vista_update_on_text_changed = 1
let g:vista_echo_cursor_strategy = 'floating_win'
"let g:vista#executives = ['coc','ctags','vim_lsp']
let g:vista#executives = ['coc','ctags']
let g:vista_default_executive = 'coc'
" local_depend 本地目录依赖标志,换机需改
"let g:vista_ctags_executable = 'C:\tools\open_code\ctags-2020-10-26_p5.9.20201025.0-2-g5d000b1a-x86\ctags.exe'
let g:vista_executive_for = {'lua': 'coc', 'typescript': 'coc', 'go': 'coc', 'c': 'coc', 'javascript': 'coc', 'html': 'coc', 'rust': 'coc', 'cpp': 'coc', 'css': 'coc', 'python': 'coc','vim':'ctags','java':'coc'}
let g:vista_sidebar_position = 'vertical topleft'
let g:vista_sidebar_width = 30
let g:vista_icon_indent = ["╰─▸ ", "├─▸ "]
" Ensure you have installed some decent font to show these pretty symbols, then you can enable icon for the kind.
let g:vista#renderer#enable_icon = 0
" The default icons can't be suitable for all the filetypes, you can extend it as you wish.
let g:vista#renderer#icons = {
\ "function": "\uf794",
\ "variable": "\uf71b",
\ }
let g:vista_fzf_preview = ['right:50%']
nmap <leader>v :Vista focus<cr>
" nmap <leader>vo :Vista<cr>:wincmd p<cr>
command Nt NERDTree
command Ntc NERDTreeClose
command Ntf NERDTreeFind
" 状态栏 最近函数显示
function! NearestMethodOrFunction() abort "{{{
return get(b:, 'vista_nearest_method_or_function', '')
endfunction "}}}
"set statusline+=%{NearestMethodOrFunction()}
let g:lightline = {
\ 'colorscheme': 'sonokai',
\ 'active': {
\ 'left': [
\ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified', 'method' ,'vista_near'],
\ ]
\ },
\ 'component_function': {
\ 'method': 'NearestMethodOrFunction' ,
\ 'test': 'Test_1'
\ },
\ 'component_expend': {'vista_near':'NearestMethodOrFunction'},
\ 'component_type': {
\ 'method': 'error' ,
\ 'test': 'verbose' ,
\ 'vista_near': 'error'
\ },
\ }
set noshowmode
function Test_1()
return "Test_1"
endfunction
" By default vista.vim never run if you don't call it explicitly.
" If auto show the nearest function in statuslie
autocmd User CocStatusChange call vista#RunForNearestMethodOrFunction()
"autocmd VimEnter * call vista#RunForNearestMethodOrFunction()
"autocmd FileType cs,c,cpp,python call vista#RunForNearestMethodOrFunction()
"autocmd CursorMoved * call lightline#update()
"augroup LightLine
" autocmd!
" autocmd WinEnter,BufWinEnter,FileType,ColorScheme,SessionLoadPost * call lightline#update()
" autocmd ColorScheme,SessionLoadPost * call lightline#highlight()
" autocmd VimEnter * call Msgbox("vimEnter".col("."))
"augroup END
"let s:palette = g:lightline#colorscheme#{g:lightline.colorscheme}#palette
"let s:palette.normal.middle = [['#ffffff', '#000000', 0, 21]]
"call g:lightline#colorscheme()
"autocmd VimEnter * call SetupLightlineColors()
"function SetupLightlineColors() abort
" " transparent background in statusbar
" let l:palette = lightline#palette()
" let l:palette.normal.middle = [ [ 'NONE', 'NONE', 'NONE', 'NONE' ] ]
" let l:palette.inactive.middle = l:palette.normal.middle
" let l:palette.tabline.middle = l:palette.normal.middle
" call lightline#colorscheme()
"endfunction
"}}}
endfunction "}}}
function s:CONFIG_plugs_cocconfig() "{{{
"" common.vim
"let g:coc_common = {
" \ "coc.preferences.currentFunctionSymbolAutoUpdate": v:true,
" \ "coc.source.ultisnips.priority": 10,
" \ "coc.source.buffer.priority": 5,
" \ "coc.source.word.priority": 1,
" \ }
"" explorer.vim
"let g:coc_explorer = {
" \ "explorer.icon.enableNerdfont": v:true,
" \ "explorer.keyMappings": {
" \ "<space>": "normal:j"
" \ },
" \ }
"let g:coc_user_config = extend(g:coc_common, g:coc_explorer)
" TODO shfmt
"\"coc.preferences.hoverTarget": "float",
" install: rustup component add rust-analyzer
let g:coc_user_config = {
\"coc.preferences.formatOnSaveFiletypes": ["rust"],
\"diagnostic.checkCurrentLine": v:true,
\"inlayHint.enable": v:false,
\"python.jediEnabled": v:true,
\"rust-analyzer.server.path": $HOME."/.cargo/bin/rust-analyzer",
\"rust-analyzer.updates.checkOnStartup": v:false
\}
"let g:coc_user_config['coc.preferences.jumpCommand'] = ':SplitIfNotOpen4COC'
" coc-rust-analyzer standalone signle rs file without cargo folder
" https://rust-analyzer.github.io/manual.html#non-cargo-based-projects
" touch rust-project.json in main.rs folder
" https://github.com/rust-lang/rust-analyzer/issues/6388
" {
" "sysroot_src": "/home/<YOUR-USER>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library",
" "crates": [
" {
" "root_module": "main.rs",
" "edition": "2018",
" "deps": []
" }
" ]
" }
" coc config json rust-analyzer.linkedProjects with rus-project.json
" let g:coc_user_config = {
" \"rust-analyzer.linkedProjects": [
" \{
" \ "sysroot_src": "/home/u1/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library",
" \ "crates": [
" \ {
" \ "root_module": "main.rs",
" \ "edition": "2021",
" \ "deps": [],
" \ },
" \ ]
" \}
" \]
" \}
endfunction "}}}
function s:CONFIG_plugs_ext() "{{{
"session {{{
let g:session_autosave=0
"}}}
"ycm {{{
"let g:ycm_global_ycm_extra_conf = 'c:/users/test/.vim/ycm_extra_conf.py'
""let g:ycm_server_python_interpreter='C:\Users\test\AppData\Local\Programs\Python\Python37-32'
""set runtimepath+=C:\Program\\\ Files\\\ (x86)\Vim\vim-ycm-20200105\YouCompleteMe\
"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_complete_in_strings=1
"let g:ycm_key_invoke_completion = '<c-z>'
"let g:ycm_semantic_triggers = {
" \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
" \ 'cs,lua,javascript': ['re!\w{2}'],
" \ }
"let g:ycm_filetype_whitelist = {
" \ "c":1,
" \ "cpp":1,
" \ "objc":1,
" \ "sh":1,
" \ "zsh":1,
" \ "zimbu":1,
" \ }
"}}}
" translator {{{
let g:translator_default_engines=['google',]
"let g:translator_proxy_url = 'socks5://127.0.0.1:10808'
"let g:translator_proxy_url = 'http://127.0.0.1:10809'
"let g:translator_debug_mode=1 "log 中详细
command -nargs=* Tr Translate <args>
command -nargs=* Tre Translate --engines=google --target_lang=en <args>
" 选中区域翻译
vmap <leader>g :TranslateW<cr>
nmap <leader>g :TranslateW<cr>
"vmap <Leader>ta :TranslateW --engines=google<cr>
"nmap <Leader>tg :TranslateW --engines=google<cr>
vmap <Leader>ge :TranslateW --engines=google --target_lang=en <cr>
nmap <Leader>ge :TranslateW --engines=google --target_lang=en <cr>
"vmap <Leader>tr :TranslateR --engines=google<cr>
" 选中区域翻译到下一行
nmap <Leader>tn :call Tr_next_line()<cr>
" 选中区域翻译结果到剪贴板
" let @w= 'yyV:TranslateRP'
function Tr_next_line()
let @1= 'yyV:TranslateRP'
"let url = matchstr(test, '==>.*')
"if empty(url)
" throw "no url recognized into ``".test."''"
"endif
endfunction
"vmap <f4> :call Tr_toclip()<cr>
"}}}
" async run {{{
"%:p - 当前 buffer 的文件名全路径
"%:t - 当前 buffer 的文件名(没有前面的路径)
"%:p:h - 当前 buffer 的文件所在路径
"%:e - 当前 buffer 的扩展名
"%:t:r - 当前 buffer 的主文件名(没有前面路径和后面扩展名)
"% - 相对于当前路径的文件名
"%:h:. - 相对于当前路径的文件路径
"<cwd> - 当前路径
"<cword> - 光标下的单词
"<cfile> - 光标下的文件名
"<root> - 当前 buffer 的项目根目录
command -nargs=* AR AsyncRun -mode=popup <args>
command -nargs=* ARt AsyncRun -mode=term <args>
command -nargs=* ARf AsyncRun -mode=term -pos=floaterm <args>
command -nargs=* ARe AsyncRun -mode=term -pos=external <args>
"command -nargs=* AR AsyncRun -mode=popup -pos=tab <args>
command -nargs=* ARc AR cmd <args>
"command -nargs=* ARp AR powershell -nologo -NoProfile <args>
command -nargs=* ARp AR powershell -nol -nop <args>
command -nargs=* ARtp ARt powershell -nol -nop <args>
command -nargs=* ARfp ARf powershell -nol -nop <args>
command -nargs=* ARep ARe powershell -nol -nop <args>
command -nargs=* EX AR explorer <args>
command EXt AsyncRun explorer /select,%:p
command EXd AsyncRun explorer "C:\Users\test\desktop"
"change directory (-cwd) before execution: , set environment variables
":AsyncRun -mode=bang -cwd=<root> gcc -c "$(VIM_FILENAME)"
function! s:run_floaterm(opts)
"let cwd = getcwd()
"let cmd = 'cd ' . shellescape(cwd) . ' && ' . a:opts.cmd
"execute 'FloatermNew --position=topright --height=0.4 --width=0.5 --title=floaterm_runner --autoclose=1 ' . cmd
" Back to the normal mode
" stopinsert
let curr_bufnr = floaterm#curr()
if has_key(a:opts, 'silent') && a:opts.silent == 1
FloatermHide!
endif
let cmd = 'cd ' . shellescape(getcwd())
call floaterm#terminal#send(curr_bufnr, [cmd])
call floaterm#terminal#send(curr_bufnr, [a:opts.cmd])
" Back to the normal mode
stopinsert
endfunction
let g:asyncrun_runner = get(g:, 'asyncrun_runner', {})
let g:asyncrun_runner.floaterm = function('s:run_floaterm')
let g:asynctasks_term_pos = 'floaterm'
"}}}
"ccls CocConfig {{{
"{
" "languageserver": {
" "ccls": {
" "command": "ccls",
" "filetypes": ["c", "cpp", "objc", "objcpp"],
" "rootPatterns": [".ccls", "compile_commands.json", ".vim/", ".git/", ".hg/"],
" "initializationOptions": {
" "index":{"blacklist":["clsload.m"]},
" "cache": {
" "directory": ".cache/ccls"
" },
" "client": {
" "snippetSupport": true
" },
" "highlight": { "lsRanges" : true }
" }
" }
" }
"}
"}}}
" Autoformat {{{
""noremap <F3> :Autoformat<CR>
"let g:autoformat_verbosemode=1
"" 指定html格式化工具,并设置缩进为两个空格
"" local_depend 本地目录依赖标志,换机需改
"let g:formatdef_my_html = '"html-beautify -s 4"'
"let g:formatters_html = ['my_html']
"}}}
" quickui {{{
let g:quickui_color_scheme = 'papercol dark'
let g:quickui_border_style = 2
"}}}
" coc explorer {{{
let g:coc_explorer_global_presets = {
\ 'tab': {
\ 'position': 'tab',
\ 'quit-on-open': v:true,
\ },
\ 'simplify': {
\ 'file-child-template': '[selection | clip | 1] [indent][icon | 1] [filename growRight 1 omitCenter 5] [size]'
\ },
\ 'buffer': {
\ 'sources': [{'name': 'buffer', 'expand': v:true}]
\ },
\ }
"\ 'file-child-template': '[selection | clip | 1] [indent][icon | 1] [filename | 60] [size]'
"}}}
nnoremap <silent> <space>y :<C-u>CocList -A --normal yank<cr>
" coc complete suggestion
"inoremap <silent><expr> <c-n> coc#refresh()
if &filetype == 'vim'
"inoremap <silent><expr> <C-n> coc#pum#visible() ? coc#pum#next(1) : coc#refresh()
"inoremap <silent><expr> <C-p> coc#pum#visible() ? coc#pum#prev(1) : coc#refresh()
else
inoremap <silent><expr> <C-n> coc#pum#visible() ? coc#pum#next(1) : coc#refresh()
inoremap <silent><expr> <C-p> coc#pum#visible() ? coc#pum#prev(1) : coc#refresh()
endif
endfunction "}}}
function s:CONFIG_plugs_temp() "{{{
" minimap {{{
let g:minimap_width = 10
let g:minimap_highlight_range=1
let g:minimap_highlight_search=1
let g:minimap_git_colors=1
let g:minimap_block_filetypes =['fugitive', 'nerdtree', 'tagbar', 'fzf' ]
let g:minimap_block_buftypes =['nofile', 'nowrite', 'quickfix', 'terminal', 'prompt']
let g:minimap_close_filetypes =['startify', 'netrw', 'vim-plug']
nmap <leader>mp :MinimapToggle<cr>
nmap <leader>mu :MinimapUpdateHightLight<cr>
"}}}
" vim-over {{{
command Ov OverCommandLine
let g:over_enable_cmd_window = 1
let g:over_enable_auto_nohlsearch = 1
let g:over#command_line#substitute#replace_pattern_visually = 1
" }}}
"w3m {{{
let g:w3m#command = 'C:\tools\open_code\msys64\usr\bin\w3m.exe'
"let HTTP_PROXY='http://127.0.0.1:10808'
let g:w3m#homepage = "http://news.ycombinator.com/"
let g:w3m#search_engine = 'http://search.yahoo.co.jp/search?search.x=1&fr=top_ga1_sa_124&tid=top_ga1_sa_124&ei=' . &encoding . '&aq=&oq=&p='
"}}}
"mark load {{{
let MARK_RSRCAAAA=[', ''[0-9a-f]\{7,12}'',',', ''08\d\+''',' ''\u\l\{5,}''', '001f8b08''']
let MARK_DNLS1 =['^#\d\+', '^#1[^0-9]', '#1\n', '^#1"', '"\d\+ ', ':[a-zA-Z0-9/_+=]\{20}"','#[!!!]',':\(\w\{1,3}[^a-zA-Z0-9]\)\{5}' ]
let MARK_HRSTR =['\w\{4,}']
let MARK_SSCLI =['field\c\|字段','type\c\|类型','class\c','.* | \d\+','^#\+ .*','TypeHandle\|TypeDef\|TypeDesc','sign\c\|符号','token\c\|令牌','\w\+TypeHandle\w\+','LoadType\w\+']
let MARK_MONO_TRACE =['| \w.* (', '.*managed-to-native.*', '.*runtime-invoke.*', '\<LEAVE\>', '\<ENTER\>']
"}}}
"vimspector {{{
"let g:vimspector_enable_mappings = 'HUMAN'
let g:vimspector_enable_mappings = 'VISUAL_STUDIO'
" for normal mode - the word under the cursor
nmap <Leader>di <Plug>VimspectorBalloonEval
" for visual mode, the visually selected text
xmap <Leader>di <Plug>VimspectorBalloonEval
nmap <LocalLeader><F11> <Plug>VimspectorUpFrame
nmap <LocalLeader><F12> <Plug>VimspectorDownFrame
"sign define vimspectorBP text=\ ● texthl=WarningMsg
"sign define vimspectorBPCond text=\ ◆ texthl=WarningMsg
"sign define vimspectorBPDisabled text=\ ● texthl=LineNr
"sign define vimspectorPC text=\ ▶ texthl=MatchParen linehl=CursorLine
"sign define vimspectorPCBP text=●▶ texthl=MatchParen linehl=CursorLine
"sign define vimspectorCurrentThread text=▶ texthl=MatchParen linehl=CursorLine
"sign define vimspectorCurrentFrame text=▶ texthl=Special linehl=CursorLine
sign define vimspectorBP text=o texthl=WarningMsg
sign define vimspectorBPCond text=o? texthl=WarningMsg
sign define vimspectorBPDisabled text=o! texthl=LineNr
sign define vimspectorPC text=\ > texthl=MatchParen
sign define vimspectorPCBP text=o> texthl=MatchParen
sign define vimspectorCurrentThread text=> texthl=MatchParen
sign define vimspectorCurrentFrame text=> texthl=Special
func! s:CustomiseUI()
call win_gotoid( g:vimspector_session_windows.code )
" Clear the existing WinBar created by Vimspector
nunmenu WinBar
" Cretae our own WinBar
nnoremenu WinBar.Kill :call vimspector#Stop( { 'interactive': v:true } )<CR>
nnoremenu WinBar.Continue :call vimspector#Continue()<CR>
nnoremenu WinBar.Pause :call vimspector#Pause()<CR>
nnoremenu WinBar.Step\ Over :call vimspector#StepOver()<CR>
nnoremenu WinBar.Step\ In :call vimspector#StepInto()<CR>
nnoremenu WinBar.Step\ Out :call vimspector#StepOut()<CR>
nnoremenu WinBar.Restart :call vimspector#Restart()<CR>
nnoremenu WinBar.Exit :call vimspector#Reset()<CR>
endfunction
augroup MyVimspectorUICustomistaion
autocmd!
autocmd User VimspectorUICreated call s:CustomiseUI()
augroup END
"}}}
" vim-syntax-yara{{{
autocmd BufNewFile,BufRead *.yar,*.yara setlocal filetype=yara
"}}}
endfunction "}}}
"}}}
function s:CONFIG_au_filetype() "{{{
" 补全path设置
autocmd FileType markdown setlocal lcs-=trail foldmethod=marker
" markdown syntax highlight hack
" {{{
"autocmd FileType markdown syn match mt0 '^# .*' containedin=ALL contained |hi mt0 guibg=gray90 guifg=gray30
"autocmd FileType markdown syn match mt1 '^## .*' containedin=ALL contained |hi mt1 guibg=gray90 guifg=gray30
"autocmd FileType markdown syn match mt2 '^### .*' containedin=ALL contained |hi mt2 guibg=gray90 guifg=gray30
"autocmd FileType markdown syn match mt3 '^#### .*' containedin=ALL contained |hi mt3 guibg=gray90 guifg=gray30
"autocmd FileType markdown syn match mt4 '^##### .*' containedin=ALL contained |hi mt4 guibg=gray90 guifg=gray30
"autocmd FileType markdown syn match m11 '\*.\{-1,}\*' containedin=ALL contained |hi m11 guifg=cyan
"autocmd FileType markdown syn match m12 '_.\{-1,}_' containedin=ALL contained |hi m12 guifg=cyan
"autocmd FileType markdown syn match m21 '\*\*.\{-1,}\*\*' containedin=ALL contained |hi m21 guifg=springgreen
"autocmd FileType markdown syn match m22 '__.\{-1,}__' containedin=ALL contained |hi m22 guifg=springgreen
"}}}
autocmd FileType markdown nnoremap <leader>` ciw``<esc>P
autocmd FileType markdown setlocal foldlevel=0
"autocmd FileType markdown setlocal foldlevel=99
"let g:vim_markdown_strikethrough = 1
autocmd FileType html setlocal shiftwidth=2 tabstop=2
if s:is_win
autocmd FileType c setlocal noet path+=C:/Program\\\ Files\\\ (x86)/Windows\\\ Kits/10/Include/10.0.19041.0/
"autocmd FileType python setlocal path+=C:/Users/test/AppData/Local/Programs/Python/Python39/Lib/
autocmd FileType python setlocal path+=C:/Python27/Lib
autocmd FileType python let $PYTHONPATH ='D:\code\pytest\work'
else
autocmd FileType c setlocal et
autocmd FileType python let $PYTHONPATH =$HOME.'/code/py/pytest/work'
endif
autocmd FileType c,cpp,python setlocal foldmethod=indent
autocmd BufRead,BufNewFile *.h,*.c setlocal filetype=c list lcs=tab:\|_