-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.vimrc
1104 lines (932 loc) · 28.8 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
"""""""""""""""""""""""""""""""""""""""
"Utils {{{
"""""""""""""""""""""""""""""""""""""""
function! MySys()
if has("win32")
return "windows"
else
if has("mac")
return "mac"
else
return "linux"
endif
endfunction
" CTRL-X and SHIFT-Del are Cut
"vnoremap <C-X> "+x
" CTRL-C and CTRL-Insert are Copy
" vnoremap <C-C> "+y
" CTRL-V and SHIFT-Insert are Paste
if MySys() == "linux"
vmap <C-c> "+y
vmap <C-x> "+c
vmap <C-v> c<ESC>"+p
imap <C-v> <ESC>"+pa
noremap <C-v> "+p
endif
"""""""""""""""""""""""""""""""""""""""
"Utils }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
"Gerneral {{{
"""""""""""""""""""""""""""""""""""""""
" Enable filetype plugin
filetype plugin on
filetype indent on
" Set to auto read when a file is changed from the outside
set autoread
" 编辑vimrc之后,重新加载
autocmd! bufwritepost .vimrc source ~/.vimrc
" 禁用Vi的兼容模式
set nocompatible
if has("gui_running") && ! has('gui_vimr')
"winpos 0 0
" set guioptions -=m
" set guioptions -=T
" set guioptions -=L
" set guioptions -=r
" auto select
" set guioptions +=a
" set macmeta
"set transparency=10
"set showtabline=0
"set lines=45
"set columns=85
" insert mode to IME
"set noimdisable
"set iminsert=2
"autocmd! InsertEnter * set noimdisable|set iminsert=0
"autocmd! InsertLeave * set imdisable|set iminsert=0
"autocmd! FocusGained * set imdisable|set iminsert=0
endif
set noscrollbind
set nocursorbind
if exists('+autochdir')
" 文件路径设置为当前路径
set autochdir
endif
" auto set current work dir
autocmd BufEnter * silent! lcd %:p:h
"auto save exit info
autocmd! BufWinLeave *.* mkview 1
autocmd! BufWinEnter *.* silent loadview 1
set viminfo+=!
"""""""""""""""""""""""""""""""""""""""
"Gerneral }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
" Plugin Management {{{
"""""""""""""""""""""""""""""""""""""""
call plug#begin()
" Syntax
Plug 'vim-scripts/asciidoc.vim'
Plug 'vim-scripts/confluencewiki.vim'
Plug 'othree/html5.vim'
"Plug 'vim-scripts/JavaScript-syntax'
"Plug 'vim-scripts/mako.vim'
Plug 'vim-scripts/moin.vim'
Plug 'vim-scripts/python.vim--Vasiliev'
Plug 'vim-scripts/xml.vim'
Plug 'vim-scripts/less'
" Plug 'hallison/vim-markdown'
" Plug 'tpope/vim-markdown'
Plug 'vim-scripts/wikipedia.vim'
Plug 'derekwyatt/vim-scala'
" play1
" Plug 'alswl/play2vim'
" play2
Plug 'gre/play2vim'
Plug 'tpope/vim-haml'
Plug 'kchmck/vim-coffee-script'
Plug 'vim-ruby/vim-ruby'
Plug 'vim-scripts/django.vim'
Plug 'chr4/nginx.vim'
Plug 'saltstack/salt-vim'
" Install gopls, `go get golang.org/x/tools/gopls@latest`
" Plug 'fatih/vim-go'
Plug 'vim-scripts/haproxy'
Plug 'mustache/vim-mustache-handlebars'
Plug 'chase/vim-ansible-yaml'
Plug 'leafgarland/typescript-vim'
Plug 'aklt/plantuml-syntax'
" Plug 'alswl/plantuml-syntax'
" Plug 'spacewander/openresty-vim'
Plug 'vim-scripts/applescript.vim'
"Plug 'pangloss/vim-javascript'
"Plug 'othree/yajs.vim'
"Plug 'mxw/vim-jsx'
Plug 'skreuzer/vim-prometheus'
Plug 'cespare/vim-toml'
" Color
Plug 'vim-scripts/desert256.vim'
Plug 'vim-scripts/vividchalk.vim'
Plug 'vim-scripts/ego.vim'
"Plug 'tomasr/molokai'
Plug 'crusoexia/vim-monokai'
Plug 'altercation/vim-colors-solarized'
Plug 'morhetz/gruvbox'
" Ftplugin
"Plug 'vim-scripts/python_fold'
" Indent
"Plug 'indent/html.vim'
Plug 'vim-scripts/IndentAnything'
" Plug 'vim-scripts/Javascript-Indentation'
Plug 'vim-scripts/mako.vim--Torborg'
Plug 'gg/python.vim'
" it cause nvim load plugins error
" Plug 'lepture/vim-jinja'
Plug 'Glench/Vim-Jinja2-Syntax'
" Plugins
Plug 'preservim/nerdtree'
"Plug 'AutoClose--Alves'
Plug 'vim-scripts/auto_mkdir'
" required by XXX
Plug 'vim-scripts/cecutil'
" encode detect
Plug 'mbbill/fencview'
" Plug 'vim-scripts/FuzzyFinder'
Plug 'akiyosi/gonvim-fuzzy'
Plug 'vim-scripts/jsbeautify'
" required by XXX
Plug 'vim-scripts/L9'
" required for vim-mark
" required for FilePathConvert
Plug 'inkarkat/vim-ingo-library'
" mark in different color, leader + m
Plug 'inkarkat/vim-mark'
" joke
Plug 'vim-scripts/matrix.vim'
" most recent used
Plug 'vim-scripts/mru.vim'
" auto comment
Plug 'scrooloose/nerdcommenter'
Plug 'vim-scripts/restart.vim'
"Tlist
"Plug 'vim-scripts/taglist.vim'
"Plug 'vim-scripts/templates.vim'
Plug 'majutsushi/tagbar'
"Plug 'vim-scripts/vimim.vim'
Plug 'mattn/emmet-vim'
"Plug 'css_color.vim'
"Plug 'hallettj/jslint.vim'
" code source
"Plug 'vim-scripts/vcscommand.vim'
" task list search
"Plug 'vim-scripts/TaskList.vim'
"Plug 'vim-scripts/pep8'
"Plug 'git://github.com/kevinw/pyflakes-vim.git'
"Rope, a python refactoring library
"Plug 'sontek/rope-vim'
"Plug 'project.tar.gz'
"Plug 'vim-scripts/minibufexplorerpp'
Plug 'vim-scripts/bufexplorer.zip'
"Plug 'vim-scripts/Align.vim'
"Plug 'vim-scripts/SQLUtilities'
" extened % for html ...
Plug 'vim-scripts/matchit.zip'
" % jump, </> pair, >> for complete
Plug 'vim-scripts/xmledit'
" ascii drawing, \di, \ds
" Plug 'vim-scripts/DrawIt is Outdated
Plug 'alswl/DrawIt'
" Plug 'gyim/vim-boxdraw'
" NR, NW
Plug 'chrisbra/NrrwRgn'
" status bar
" Plug 'Lokaltog/vim-powerline'
" Plug 'scala/scala-dist'
Plug 'terryma/vim-multiple-cursors'
" original repos on github
"Plug 'tpope/vim-fugitive'
"Plug 'Lokaltog/vim-easymotion'
"Plug 'rstacruz/sparkup', {'rtp': 'vim/'}
"Plug 'tpope/vim-rails.git'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'vim-scripts/Rename'
Plug '907th/vim-auto-save'
" Plug 'nelstrom/vim-markdown-folding'
Plug 'godlygeek/tabular'
" Plug 'plasticboy/vim-markdown'
Plug 'vim-pandoc/vim-pandoc-syntax'
Plug 'rhysd/vim-gfm-syntax'
Plug 'dhruvasagar/vim-table-mode'
" Plug 'lilydjwg/fcitx.vim'
" now I using Rime to detect in GUI, only using fcitx-remote in Terminal, https://github.com/xcodebuild/fcitx-remote-for-osx
" too slow, disable it
" Plug 'CodeFalling/fcitx-vim-osx'
Plug 'junegunn/vim-easy-align'
"Plug 'wannesm/wmgraphviz.vim'
Plug 'hotoo/pangu.vim'
Plug 'vim-jp/autofmt'
Plug 'sirver/ultisnips'
Plug 'honza/vim-snippets'
"Plug 'jiangmiao/auto-pairs'
" required by FilePathConvert
Plug 'inkarkat/vim-TextTransform'
" shortcut \sf
Plug 'vim-scripts/FilePathConvert'
Plug 'mileszs/ack.vim'
" Plug 'subnut/nvim-ghost.nvim', {'do': ':call nvim_ghost#installer#install()'}
" Plug 'f-person/auto-dark-mode.nvim'
" for weirongxu/plantuml-previewer.vim
Plug 'tyru/open-browser.vim'
Plug 'weirongxu/plantuml-previewer.vim'
" for vim-pyref
" non github repos
"Plug 'git://git.wincent.com/command-t.git'
call plug#end()
"""""""""""""""""""""""""""""""""""""""
" Plugin Management }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
"VIM user interface {{{
"""""""""""""""""""""""""""""""""""""""
" use chinese help
"set helplang=cn
"set the menu & the message to English
set langmenu=en_US
let $LANG="en_US.UTF-8"
" set spell spelllang=en_us,cjk
set nospell
set ruler "右下角显示当前光标
"set cmdheight=2 "The commandbar height
" Set backspace config
set backspace=eol,start,indent
"set whichwrap+=<,>,h,l
set ignorecase "Ignore case when searching
set smartcase
"set nowrapscan
" 使用正统的搜索正则
"nnoremap / /\v
"vnoremap / /\v
set hlsearch "Highlight search things
set incsearch "在输入部分查找模式时显示相应的匹配点。
"set nolazyredraw "Don't redraw while executing macros
set magic "Set magic on, for regular expressions
set showmatch "Show matching bracets when text indicator is over them
set sidescroll=10 "左右移动边距
"set list " 显示制表符/回车符
set listchars=tab:>-,trail:$ " 行尾符号
set showcmd "显示右下角命令
set cursorline
set noerrorbells
set novisualbell
"set iskeyword=@,48-57,192-255
if ! has("gui_running") && ! has('gui_vimr')
set mouse-=a
endif
set equalalways "分割窗口时保持相等的宽/高
set guitablabel=%N.%t " 设定标签上显示序号
set foldmethod=syntax
set foldcolumn=0
set foldlevel=0
set nofoldenable
set diffopt=vertical,iwhite
set laststatus=2
set statusline=\ \%F\ \ \ \ \ %m%r%h%w\ \ %y\ [%{&ff}]\ [%{&fileencoding}]\ [%p%%]\ [%l/%L]\ [%c]
set ttyfast
set shortmess-=S
if !exists(':relativenumber')
set relativenumber " 显示相对行号
endif
set number " 显示行号
set numberwidth=2 "行号栏的宽度
" set foldclose=all
"function! MarkPoint()
"mark `
"endfunction
"autocmd CursorMoved * call MarkPoint()
"""""""""""""""""""""""""""""""""""""""
"VIM user interface }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
"Colors and Fonts {{{
"""""""""""""""""""""""""""""""""""""""
syntax enable "Enable syntax hl
"gfn=consolas:h10
"set gui options
" Gonvim please setting in ~/.config/goneovim/settings.toml
if (has("gui_running") && ! has('gui_vimr'))
" set linespace=10
" set "uifont=Monospace\ 11
" set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h16
" set guifont=Anonymous\ Pro\ for\ Powerline:h20
" set guifont=Droid\ Sans\ Mono\ for\ Powerline:h20
" set macligatures
" set guifont=Droid\ Sans\ Mono\ for\ Powerline:h13
if MySys() == "mac"
set guifont=Fira\ Code:h14
set guifontwide=Fira\ Code:h14
" set printfont=Fira\ Code:h12
else
if MySys() == "linux"
set guifont=Fira\ Code\ 16
" set printfont=Fira\ Code\ 12
endif
endif
" set guifont=Source\ Code\ Pro\ for\ Powerline:h20
" set guifont=Ubuntu\ Mono\ derivative\ Powerline:h20
" set guifont=Ubuntu\ Mono\ derivative\ Powerline:h20
"set guifont=Menlo:h18
"let Powerline_symbols = 'fancy'
" set printencoding=utf-8
" set printmbcharset=ISO10646
" set printmbfont=r:Fira\ SC\ Light,c:yes
" Set syntax color
" colorscheme monokai
colorscheme gruvbox
else
colorscheme gruvbox
"colorscheme desert256
endif
set background=dark
" set background=light
"set ambiwidth=double " 设定某些标点符号为宽字符
" 设定行首tab为灰色
highlight LeaderTab guifg=#666666
" Hi links
au syntax * hi link markdownBold GruvboxRed
au syntax * hi link markdownOrderedListMarker GruvboxBlue
au syntax * hi link markdownListMarker GruvboxBlue
au syntax * hi link markdownCode GruvboxAqua
au syntax * hi link markdownCodeDelimator GruvboxAqua
au syntax * hi link markdownBlockquote GruvboxYellowSign
" Hi todos
syn match myTodo contained "\<\(TODO\|FIXME\|XXX\):"
syn match myself contained "\<@\(alswl\|jingchao\|3d\|djc\|三谛\):"
hi def link myTodo Todo
hi def link myself Myself
"""""""""""""""""""""""""""""""""""""""
"Colors and Fonts }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
"Files, backups and undo {{{
"""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git anyway...
set nobackup
set nowritebackup
"set noswapfile
set backupext=.bak
" paste for any files keey original indent
set paste
"设置编码
set fileencodings=utf-8,gbk,ucs-bom,default,latin1
set termencoding=utf-8
set encoding=utf-8
"Persistent undo
if exists('+undodir')
if MySys() == "windows"
set undodir=C:\Windows\Temp
else
if has('nvim-0.5')
" New format in https://github.com/neovim/neovim/pull/13973 (f42e932,
" 2021-04-13).
let &undodir = $HOME . "/.vim_runtime" . '/undodir2'
else
let &undodir = $HOME . "/.vim_runtime" . '/undodir'
endif
endif
set undofile
endif
"""""""""""""""""""""""""""""""""""""""
"Files, backups and undo }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
"Text, tab and indent related {{{
"""""""""""""""""""""""""""""""""""""""
"set expandtab
set noexpandtab "是否使用Tab缩进 默认使用
set shiftwidth=4
set tabstop=4
set smarttab
set autoindent "Auto indent
set smartindent "Smart indet
set wrap "Wrap lines
"""""""""""""""""""""""""""""""""""""""
"Text, tab and indent related }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
"FileType setting {{{
"""""""""""""""""""""""""""""""""""""""
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile */tmp/edit-server-prometheus**.txt set filetype=prometheus
autocmd BufRead,BufNewFile */tmp/edit-server-*.txt set filetype=markdown.gfm
autocmd BufRead,BufNewFile /private/tmp/zsh* set filetype=sh
autocmd BufRead,BufNewFile *.pmd set filetype=markdown.pandoc
autocmd BufRead,BufNewFile *.scala set filetype=scala
autocmd BufRead,BufNewFile *.sc set filetype=scala
autocmd BufRead,BufNewFile *.sls set filetype=sls
autocmd BufRead,BufNewFile *.js set expandtab shiftwidth=2
autocmd BufRead,BufNewFile *.go set filetype=go
autocmd BufRead,BufNewFile *.wiki.dev.* set filetype=confluencewiki
autocmd BufRead,BufNewFile *.ts set filetype=typescript
autocmd BufRead,BufNewFile *.wxml set filetype=xml
autocmd BufRead,BufNewFile *.wxss set filetype=css
autocmd BufRead,BufNewFile *.gv set filetype=dot
autocmd BufRead,BufNewFile *.puml set filetype=plantuml
autocmd BufRead,BufNewFile *.cc set filetype=cpp
autocmd BufRead,BufNewFile *.zshrc set filetype=sh
autocmd BufRead,BufNewFile *.omnijs set filetype=javascript
" using python sytax for kcl
autocmd BufRead,BufNewFile *.k set filetype=python
autocmd BufRead,BufNewFile OWNERS set filetype=yaml
autocmd BufRead,BufNewFile Dockerfile.* set filetype=dockerfile
autocmd BufRead,BufNewFile Dockerfile-* set filetype=dockerfile
autocmd FileType python setlocal expandtab colorcolumn=80 textwidth=0 diffopt=vertical " fo+=Mm
"Map F9 to Run Python Script
autocmd FileType python map <F9> :!python %
autocmd FileType asciidoc setlocal colorcolumn=120
autocmd FileType markdown,markdown.pandoc,markdown.github,markdown.gfm
\ setlocal colorcolumn=120 expandtab shiftwidth=2 nowrap
\ tabstop=4 textwidth=0
\ formatexpr=autofmt#uax14#formatexpr()
\ noshowmatch
" mardown set shfitwidth for obsidian
autocmd BufRead,BufNewFile */*kms/**.md set shiftwidth=4 tabstop=4
autocmd BufRead,BufNewFile */*kms/*/**.md set shiftwidth=4 tabstop=4
autocmd BufRead,BufNewFile */*kms/*/*/**.md set shiftwidth=4 tabstop=4
" comments configuration from https://github.com/plasticboy/vim-markdown/issues/390#issuecomment-450392655
autocmd FileType mako setlocal colorcolumn=120 cc=0 fdm=indent
autocmd FileType html setlocal expandtab shiftwidth=2 tabstop=2
autocmd FileType javascript setlocal expandtab shiftwidth=2 tabstop=2
autocmd FileType haskell setlocal expandtab
autocmd FileType lua setlocal expandtab
autocmd FileType nginx setlocal expandtab
autocmd FileType java setlocal expandtab colorcolumn=120
autocmd FileType ruby setlocal expandtab shiftwidth=2 colorcolumn=120
autocmd FileType eruby setlocal expandtab shiftwidth=2
autocmd FileType rst setlocal colorcolumn=120
autocmd FileType htmldjango setlocal expandtab shiftwidth=2 foldmethod=indent
autocmd FileType yaml setlocal expandtab shiftwidth=2 foldmethod=indent
autocmd FileType plantuml setlocal expandtab
" notice, here is more `\` for `\|` for autocmd
autocmd FileType plantuml vnoremap = :EasyAlign */\(starts\)\\|\(ends\)\\|\(lasts\)\\|\(happens\)/<CR>
autocmd FileType plantuml let g:plantuml_previewer#plantuml_jar_path = get(
\ matchlist(system('cat `which plantuml` | grep plantuml.jar'), '\v.*\s[''"]?(\S+plantuml\.jar).*'),
\ 1,
\ 0
\)
autocmd FileType sh setlocal expandtab shiftwidth=2
autocmd FileType dockerfile setlocal expandtab shiftwidth=2
"""""""""""""""""""""""""""""""""""""""
"FileType setting }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
"Moving around, tabs and buffers {{{
"""""""""""""""""""""""""""""""""""""""
" Smart way to move btw. windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Use the arrows to something usefull
map <right> :bn<cr>
map <left> :bp<cr>
"""""""""""""""""""""""""""""""""""""""
"Moving around, tabs and buffers }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
" Text Formatting/Layout {{{
"""""""""""""""""""""""""""""""""""""""
set formatoptions+=mB
"set formatoptions=croqn2mB1
"try
"" Vim 7.4
"set formatoptions+=j
"catch /.*/
"endtry
set linebreak "智能换行
"set tw=500 "自动换行 超过n列
" text hidden
set conceallevel=0
"""""""""""""""""""""""""""""""""""""""
" Text Formatting/Layout }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
" Map {{{
"""""""""""""""""""""""""""""""""""""""
map <F1> :NERDTreeToggle<cr>
imap <F1> <Esc>:NERDTreeToggle<cr>
"map <F2> :Tlist<cr>
map <F2> :TagbarToggle<cr>
imap <F2> <Esc>:TagbarToggle<cr>
"代码折叠快捷方式
map <F3> zR
imap <F3><Esc> zR
map <F4> zM
imap <F4> <Esc>zM
" 标签设置
map <F7> gT
imap <F7> <Esc>gT
map <F8> gt
imap <F8> <Esc>gt
map <C-h> gT
map <C-l> gt
imap <F7> <Esc>gT
imap <F8> <Esc>gt
noremap <C-Tab> :tabnext<CR>
noremap <C-S-Tab> :tabprev<CR>
inoremap <C-Tab> <Esc>:tabnext<CR>
inoremap <C-S-Tab> <Esc>:tabprev<CR>
map <S-k> <Nop>
if has("gui_running") && ! has('gui_vimr')
imap <D-1> <Esc>1gt
nmap <D-1> 1gt
imap <D-2> <Esc>2gt
nmap <D-2> 2gt
imap <D-3> <Esc>3gt
nmap <D-3> 3gt
imap <D-4> <Esc>4gt
nmap <D-4> 4gt
imap <D-5> <Esc>5gt
nmap <D-5> 5gt
imap <D-6> <Esc>6gt
nmap <D-6> 6gt
imap <D-7> <Esc>7gt
nmap <D-7> 7gt
imap <D-8> <Esc>8gt
nmap <D-8> 8gt
imap <D-9> <Esc>9gt
nmap <D-9> 9gt
endif
if has("gui_running") && ! has('gui_vimr')
imap <silent> <S-Insert> <MiddleMouse>
cmap <silent> <S-Insert> <MiddleMouse>
endif
" 用空格键来开关折叠
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
map Q :q<CR>
vnoremap <leader> v :NRV<CR>
" 用 * / # 匹配选中
vnoremap * y/<C-R>=escape(@", '\\/.*$^~[]')<CR><CR>
vnoremap # y?<C-R>=escape(@", '\\/.*$^~[]')<CR><CR>
" html缩进
let g:html_indent_inctags = "p,li,dt,dd"
nnoremap <S-Tab> <<
inoremap <S-Tab> <C-D>
" 模拟 Emacs 键绑定
" Move
inoremap <C-a> <Home>
inoremap <C-e> <End>
" inoremap <C-p> <Up>
" inoremap <C-n> <Down>
inoremap <C-b> <Left>
inoremap <C-f> <Right>
cmap <C-a> <Home>
cmap <C-e> <End>
cmap <C-p> <Up>
cmap <C-n> <Down>
cmap <C-b> <Left>
cmap <C-f> <Right>
inoremap <M-b> <C-o>b
inoremap <M-f> <C-o>w
" Rubout word / line and enter insert mode
" use <Esc><Right> instead of <C-o>
inoremap <C-w> <Esc>dbcl
" delete
inoremap <C-u> <Esc>d0cl
inoremap <C-k> <Esc><Right>C
inoremap <C-d> <Del>
inoremap <M-d> <C-o>de
map <leader>f :NERDTreeToggle<CR>
" diff
map <leader>d /^[=<>]\{7\}<CR>
" noremap <silent> <leader>b :BufExplorer<CR>
" noremap <silent> <leader>s :BufExplorerVerticalSplit<CR>
" noremap <silent> <leader>b :BufExplorerHorizontalSplit<CR>
noremap <silent> <leader>b :CtrlPMRUFiles<CR>
imap <C-\> <Esc>:split<CR>:set nocursorbind noscrollbind<CR>:diffoff<CR>
nmap <C-\> :split<CR>:set nocursorbind noscrollbind<CR>:diffoff<CR>
nmap <silent> <leader>t :tabe %<CR>
nmap <silent> <leader>\ :split<CR>:set nocursorbind noscrollbind<CR>:diffoff<CR><C-]>
inoremap <silent> <leader>p "*p<CR>
noremap <silent> <leader>p "*p<CR>
inoremap <silent> <leader>q :q<CR>
noremap <silent> <leader>q :q<CR>
inoremap <silent> <leader>w :w<CR>
noremap <silent> <leader>w :w<CR>
nnoremap <S-Tab> <<
inoremap <S-Tab> <C-d>
" delete without yanking
" nnoremap <leader>d "_d
" vnoremap <leader>d "_d
" pip install pandoc-plantuml
if MySys() == "mac"
" markdown preview
noremap <leader>N :!open -a MacDown %<CR>
" noremap <leader>N :!open -a Typora %<CR>
" noremap <leader>M :silent exec "!open -a Macdown %"<CR>
" preview
" noremap <leader>M :GonvimMarkdown<CR>
noremap <leader>M :silent exec "!pandoc % -f markdown+smart -s --toc --toc-depth=4 -c ~/local/etc/Blank.css --mathjax='https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML' -t html -o %.generated.html && open %.generated.html"<CR>
" Error running filter pandoc-plantuml:, rm
" --filter=pandoc-plantuml
" markdown image processing
noremap <leader>u :silent exec "!plantuml -tpng % && open %:r.png"<CR>
noremap <leader>U :silent exec "!plantuml -tsvg % && open . && open %:r.svg"<CR>
noremap <leader>p :!$HOME/local/bin/image-from-clipboard-to-png-copy-markdown %
"noremap <leader>p :!$HOME/local/bin/image-from-clipboard-to-png-global %
noremap <leader>P :!$HOME/local/bin/image-from-path-to-assets-copy-markdown %
else
if MySys() == "linux"
" markdown preview
noremap <leader>M :silent exec "!pandoc % -f markdown+smart -s --toc --toc-depth=4 -c ~/local/etc/Blank.css --mathjax='https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --filter=pandoc-plantuml -t html -o %.generated.html && xdg-open %.generated.html"<CR>
endif
endif
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
if has('macunix')
function! OpenURLUnderCursor()
let s:uri = matchstr(getline('.'), '[a-z]*:\/\/[^ >,;()]*')
let s:uri = shellescape(s:uri, 1)
if s:uri != ''
silent exec "!open '".s:uri."'"
:redraw!
endif
endfunction
nnoremap gx :call OpenURLUnderCursor()<CR>
endif
"""""""""""""""""""""""""""""""""""""""
" Map }}}
"""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""
" Plugin {{{
"""""""""""""""""""""""""""""""""""""""
set tags=tags;
"pydiction 1.2 python auto complete
"let g:pydiction_location = 'D:/Program Files/Vim/vimfiles/ftplugin/pydiction'
"defalut g:pydiction_menu_height == 15
"let g:pydiction_menu_height = 20
"SuperTab
"let g:SuperTabRetainCompletionType = 2
"let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
"Neo
"let g:neocomplcache_enable_at_startup=1
" Restart
let g:restart_sessionoptions = "restart_session"
" fuzzyfinder
"map <silent> <leader>sf :FufFile<CR>
"map <silent> <leader>sb :FufBuffer<CR>
" jslint.vim
" let g:JSLintHighlightErrorLine = 0 " disabled
" Fencview
" let g:fencview_autodetect = 1
" JSLint
let g:JSLintHighlightErrorLine = 0
" Project
"map <silent> <leader>p :Project<CR>
" NERDTree
let g:NERDTreeIgnore = ['\.pyc$', '\.class$', '\.jpeg$', '\.jpg$', '\.png$', '\.git$', '^target$', '\.slide\.html$', '\.generated\.html$', '\.md\.assets$']
let g:NERDTreeChDirMode = 2
let g:NERDTreeShowBookmarks=1
" ctrlp
nnoremap <C-p> :call RunCtrlP()<CR>
let g:ctrlp_map = ''
fun! RunCtrlP()
lcd %:p:h
if (getcwd() == $HOME)
echo "Can't run in \$HOME"
return
endif
CtrlP
endfunc
"let g:ctrlp_working_path_mode = 'c'
"let g:ctrlp_working_path_mode = 'ca'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_root_markers = ['.ctrlp', 'README.md', 'build.sbt', '.git']
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn)$)|target|node_modules',
\ 'file': '\v\.(exe|so|dll|class|jar|png|jpeg|jpg|numbers|slide.html|generated.html|graphml|svg)$',
\ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
\ }
" fzf.vim
" nnoremap <C-p> :GFiles<CR>
" nnoremap <C-p> :FZF<CR>
" powerline
if has("gui_running") && ! has('gui_vimr')
"python from powerline.vim import setup as powerline_setup
"python powerline_setup()
"python del powerline_setup
endif
" autosaving
let g:auto_save = 1 " enable AutoSave on Vim startup
let g:auto_save_silent = 1 " do not display the auto-save notification
let g:auto_save_presave_hook = 'call AbortIfNotFileType()'
function! AbortIfNotFileType()
if &filetype != 'markdown' && &filetype != 'markdown.gfm' && &filetype != 'markdown.pandoc' && &filetype != 'plantuml' && &filetype != 'yaml'
let g:auto_save_abort = 1
endif
endfunction
" Add support for markdown files in tagbar.
"let g:tagbar_type_markdown = {
"\ 'ctagstype': 'markdown',
"\ 'ctagsbin' : '/path/to/markdown2ctags.py',
"\ 'ctagsargs' : '-f - --sort=yes',
"\ 'kinds' : [
"\ 's:sections',
"\ 'i:images'
"\ ],
"\ 'sro' : '|',
"\ 'kind2scope' : {
"\ 's' : 'section',
"\ },
"\ 'sort': 0,
"\ }
" https://github.com/majutsushi/tagbar/wiki
"let g:tagbar_type_markdown = {
"\ 'ctagstype' : 'markdown',
"\ 'kinds' : [
"\ 'h:Heading_L1',
"\ 'i:Heading_L2',
"\ 'k:Heading_L3'
"\ ],
"\ 'sort': 0
"\ }
let g:tagbar_type_markdown = {
\ 'ctagstype': 'markdown',
\ 'ctagsbin' : '~/local/bin/markdown2ctags.py',
\ 'ctagsargs' : '-f - --sort=yes',
\ 'kinds' : [
\ 's:sections',
\ 'i:images'
\ ],
\ 'sro' : '|',
\ 'kind2scope' : {
\ 's' : 'section',
\ },
\ 'sort': 0,
\ }
let g:tagbar_type_ansible = {
\ 'ctagstype' : 'ansible',
\ 'kinds' : [
\ 't:tasks'
\ ],
\ 'sort' : 0
\ }
let g:tagbar_type_css = {
\ 'ctagstype' : 'Css',
\ 'kinds' : [
\ 'c:classes',
\ 's:selectors',
\ 'i:identities'
\ ]
\ }
let g:tagbar_type_go = {
\ 'ctagstype': 'go',
\ 'kinds' : [
\'p:package',
\'f:function',
\'v:variables',
\'t:type',
\'c:const'
\]
\}
let g:tagbar_type_groovy = {
\ 'ctagstype' : 'groovy',
\ 'kinds' : [
\ 'p:package:1',
\ 'c:classes',
\ 'i:interfaces',
\ 't:traits',
\ 'e:enums',
\ 'm:methods',
\ 'f:fields:1'
\ ]
\ }
let g:tagbar_type_scala = {
\ 'ctagstype' : 'scala',
\ 'sro' : '.',
\ 'kinds' : [
\ 'p:packages',
\ 'T:types:1',
\ 't:traits',
\ 'o:objects',
\ 'O:case objects',
\ 'c:classes',
\ 'C:case classes',
\ 'm:methods',
\ 'V:values:1',
\ 'v:variables:1'
\ ]
\ }
" markdown.pandoc
let g:pandoc#syntax#conceal#use = 0
" let g:pandoc#syntax#conceal#urls = 1
" let g:pandoc#syntax#conceal#blacklist = ["atx","codeblock_start","codeblock_delim"]
au syntax * hi link pandocAtxStart Type
au syntax * hi link pandocAtxHeader Type
au syntax * hi! link pandocEmphasis GruvboxGreen
au syntax * hi! link pandocStrong GruvboxGreen
au syntax * hi link pandocListItemBullet GruvboxBlue
au syntax * hi link pandocUListItemBullet GruvboxBlue
" vim-mark
"nmap <silent> <leader>hl <Plug>MarkSet
"vmap <silent> <leader>hl <Plug>MarkSet
"nmap <silent> <leader>hh <Plug>MarkClear
"vmap <silent> <leader>hh <Plug>MarkClear
"nmap <silent> <leader>hr <Plug>MarkRegex
"vmap <silent> <leader>hr <Plug>MarkRegex
let g:mwAutoLoadMarks = 1
runtime plugin/mark.vim
silent! unmap <k1>
silent! unmap <k2>
silent! unmap <k3>
silent! unmap <k4>
silent! unmap <k5>
silent! unmap <k6>
silent! unmap <k7>
silent! unmap <k8>
silent! unmap <k9>
silent! unmap <C-k1>
silent! unmap <C-k2>
silent! unmap <C-k3>
silent! unmap <C-k4>