-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
executable file
·4049 lines (3437 loc) · 121 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
" Vim configure file
" Author: bootleq <bootleq@gmail.com>
" Blog: bootleq.blogspot.com
" ============================================================================
" Startup: {{{1 ==============================================
if has('vim_starting')
set all&
set nocompatible
mapclear
mapclear!
endif
augroup my_vimrc
autocmd!
augroup END
let &termencoding = &encoding
set encoding=utf-8
set fileencodings=usc-bom,utf-8,big5,taiwan,chinese,default,latin1
language messages POSIX
filetype plugin indent on
function! s:SID_PREFIX()
return matchstr(expand('<sfile>'), '<SNR>\d\+_')
endfunction
let s:i = {}
" }}}1 Startup ==============================================
" Bundles: {{{1 =======================================
" Bundler {{{2
if has('vim_starting')
if has("gui_win32")
if isdirectory(fnamemodify('c:\cygwin\home\admin\.vim', ':p'))
let s:rtp = 'c:\cygwin\home\admin\.vim'
else
" g:win32_gvim_rtp should be set by gvimrc
if exists('g:win32_gvim_rtp') && isdirectory(fnamemodify(g:win32_gvim_rtp, ':p'))
let s:rtp = g:win32_gvim_rtp
else
echoerr "You must set runtimepath (for plugin bundling) manually."
finish
endif
endif
elseif expand("<sfile>") == '/etc/users/bootleq/.vimrc'
\ && substitute(system("whoami"), '\n$', '', '') != 'bootleq'
\ && !exists("g:did_bootleq_runtime")
let g:did_bootleq_runtime = 1
let s:rtp = "/etc/users/bootleq/.vim"
elseif expand("<sfile>") == '/tmp/vimrc_human/bootleq/.vimrc'
\ && !exists("g:did_vimrc_human_runtime")
let g:did_vimrc_human_runtime = 1
let s:rtp = "/tmp/vimrc_human/bootleq/.vim"
else
let s:rtp = "~/.vim"
endif
if !isdirectory(fnamemodify(s:rtp, ':p'))
try
call mkdir(fnamemodify(s:rtp, ':p'), "p")
catch /^Vim\%((\a\+)\)\=:E739/
echoerr "Error detected while processing: " . v:throwpoint . ":\n " . v:exception .
\ "\nCan't make runtime directory. Skipped sourcing vimrc.\n"
finish
endtry
endif
execute "set runtimepath+=" . fnamemodify(s:rtp, ':p') . "bundle/neobundle.vim"
endif
set runtimepath-=~/.vim
try
call neobundle#begin(fnamemodify(s:rtp, ':p') . "bundle")
catch /^Vim\%((\a\+)\)\=:E117/
echoerr "Please install NeoBundle first: " .
\ "git clone http://github.com/Shougo/neobundle.vim.git " . fnamemodify(s:rtp, ":p") . "bundle/neobundle.vim"
finish
endtry
" }}}2 Listing {{{2
let s:bundles = []
let s:bundles += [
\ ['kana/vim-smartinput', {":skip": 1}],
\ ['Raimondi/delimitMate'],
\ ['kana/vim-surround'],
\ ['kana/vim-repeat'],
\ ['kana/vim-fakeclip'],
\ ['junegunn/vim-easy-align'],
\ ['Shougo/neosnippet'],
\ ['Shougo/vimfiler'],
\ ['Konfekt/FastFold'],
\ ['thinca/vim-prettyprint'],
\ ['thinca/vim-qfreplace'],
\ ['thinca/vim-quickrun', {'lazy': 1}],
\ ['thinca/vim-partedit', {'lazy': 1}],
\ ['bootleq/vim-qrpsqlpq', {":prefer_local": 1}],
\ ['mojako/ref-sources.vim'],
\ ['bootleq/vim-ref-bingzh'],
\ ['tpope/vim-rails'],
\ ['tpope/vim-bundler'],
\ ['tpope/vim-tbone', {":skip": 1}],
\ ['liquidz/vim-iced', {":skip": 0, 'rev': '1.3.2'}],
\ ['tpope/vim-fugitive'],
\ ['mattn/webapi-vim'],
\ ['mattn/wwwrenderer-vim'],
\ ['thinca/vim-ref'],
\ ['tyru/open-browser.vim'],
\ ['tyru/vim-altercmd'],
\ ['wokmarks.vim'],
\ ['bootleq/ShowMarks', {":prefer_local": 1}],
\ ['bootleq/camelcasemotion'],
\ ['bootleq/gsession.vim'],
\ ['tomtom/tcomment_vim'],
\ ['bootleq/vim-color-bootleg'],
\ ['bootleq/vim-cycle', {":prefer_local": 1}],
\ ['bootleq/vim-tabline', {":prefer_local": 1}],
\ ['bootleq/vim-gitdiffall', {":prefer_local": 1}],
\ ['chrisbra/vim-diff-enhanced'],
\ ['bootleq/vim-hardmotion', {":skip": 1, ":prefer_local": 1}],
\ ['bootleq/vim-wordword'],
\ ['rking/ag.vim'],
\ ['thinca/vim-zenspace'],
\ ['Yggdroot/indentLine', {':skip': 0}],
\ ['osyo-manga/vim-anzu', {':skip': 0, ":prefer_local": 0}],
\ ['justinmk/vim-sneak', {':skip': 0}],
\ ['easymotion/vim-easymotion'],
\ ['t9md/vim-choosewin'],
\ ['AndrewRadev/splitjoin.vim'],
\ ['netrw.vim'],
\ ['bootleq/LargeFile', {":prefer_local": 0}],
\ ['majutsushi/tagbar'],
\ ]
" filetype {{{3
let s:bundles += [
\ ['leshill/vim-json', {':filetypes': ['json']}],
\ ['depuracao/vim-rdoc', {':filetypes': ['rdoc']}],
\ ['bootleq/JavaScript-syntax', {':filetypes': ['javascript'], ":skip": 1}],
\ ['othree/yajs', {':filetypes': ['javascript'], ":skip": 0}],
\ ['jelera/vim-javascript-syntax', {':filetypes': ['javascript'], ":skip": 1}],
\ ['othree/vim-javascript-syntax', {':filetypes': ['javascript'], ":skip": 1}],
\ ['jiangmiao/simple-javascript-indenter', {':filetypes': ['javascript']}],
\ ['guns/vim-sexp'],
\ ['eraserhd/parinfer-rust', {"build": {'others': 'cargo build --release'}}],
\ ['junegunn/rainbow_parentheses.vim', {':filetypes': ['clojure'], ":skip": 1}],
\ ['kchmck/vim-coffee-script', {':filetypes': ['coffee']}],
\ ['posva/vim-vue', {':filetypes': ['vue'], ":skip": 1}],
\ ['groenewege/vim-less', {':filetypes': ['less']}],
\ ['hail2u/vim-css3-syntax', {':filetypes': ['css']}],
\ ['httplog', {':filetypes': ['httplog']}],
\ ['nginx.vim', {':filetypes': ['nginx']}],
\ ['othree/html5.vim', {':filetypes': ['html']}],
\ ['pearofducks/ansible-vim'],
\ ['plasticboy/vim-markdown', {':filetypes': ['mkd', 'markdown'], ':skip': 1}],
\ ['jtratner/vim-flavored-markdown', {':filetypes': ['ghmarkdown']}],
\ ['nelstrom/vim-markdown-folding', {':filetypes': ['mkd', 'markdown'], ':skip': 1}],
\ ['timcharper/textile.vim', {':filetypes': ['textile']}],
\ ['tpope/vim-haml', {':filetypes': ['haml']}],
\ ['slim-template/vim-slim', {':filetypes': ['slim'], ':prefer_local': 0}],
\ ['vim-ruby/vim-ruby', {':filetypes': ['ruby'], ':prefer_local': 1, ':skip': 0}],
\ ['sunaku/vim-ruby-minitest', {':filetypes': ['ruby'], ':prefer_local': 1, ':skip': 0}],
\ ['bruno-/vim-ruby-fold', {':filetypes': ['ruby'], ':prefer_local': 0, ':skip': 1}],
\ ['cespare/vim-toml', {':filetypes': ['toml']}],
\ ['Glench/Vim-Jinja2-Syntax', {':filetypes': ['jinja', 'jinja2']}],
\ ['tpope/vim-git', {'on_ft': ['gitcommit', 'gitconfig', 'gitrebase', 'gitsendemail', 'git']}],
\ ]
" }}}3 text-objs {{{3
let s:bundles += [
\ ['kana/vim-textobj-user'],
\ ['kana/vim-textobj-diff'],
\ ['kana/vim-textobj-fold'],
\ ['kana/vim-textobj-indent'],
\ ['kana/vim-textobj-line'],
\ ['kana/vim-textobj-function'],
\ ['thinca/vim-textobj-function-javascript'],
\ ['sgur/vim-textobj-parameter'],
\ ['kana/vim-textobj-jabraces'],
\ ['thinca/vim-textobj-between'],
\ ['saihoooooooo/vim-textobj-space'],
\ ['osyo-manga/vim-textobj-multitextobj'],
\ ['nelstrom/vim-textobj-rubyblock'],
\ ['bootleq/vim-textobj-rubysymbol'],
\ ['coderifous/textobj-word-column.vim', {':skip': 1}],
\ ]
" }}}3 operator-user {{{3
let s:bundles += [
\ ['kana/vim-operator-user'],
\ ['kana/vim-operator-replace'],
\ ['tyru/operator-html-escape.vim'],
\ ]
" }}}3 gf-user {{{3
let s:bundles += [
\ ['kana/vim-gf-user', {":skip": 1}],
\ ]
" }}}3 unite {{{3
let s:bundles += [
\ ['Shougo/unite.vim', {"rev": 'ver.6.1', ":prefer_local": 0}],
\ ['Shougo/unite-session'],
\ ['Shougo/unite-outline'],
\ ['Shougo/neomru.vim', {":skip": 0}],
\ ['tacroe/unite-mark'],
\ ['thinca/vim-unite-history'],
\ ['tsukkee/unite-help', {"rev": 'tags-caching'}],
\ ['ujihisa/unite-gem'],
\ ['basyura/unite-rails'],
\ ]
" }}}3 colorschemes {{{3
let s:bundles += [
\ ['itchyny/landscape.vim'],
\ ['tomasr/molokai'],
\ ['sk1418/last256'],
\ ['altercation/vim-colors-solarized'],
\ ]
" }}}3 neocomplete {{{3
if has('lua') && (v:version > 703 || (v:version == 703 && has('patch885')))
let s:bundles += [['Shougo/neocomplete']]
else
let s:bundles += [['Shougo/neocomplcache']]
endif
" }}}3
for s:i.dir in ['~/repository/', 'D:/repository/']
if isdirectory(fnamemodify(s:i.dir, ':p'))
let s:bundle_local_repo_dir = s:i.dir
endif
endfor
let s:bundle_local_repo_dir = expand(get(s:, 'bundle_local_repo_dir', ''))
NeoBundleFetch 'Shougo/neobundle.vim'
for s:i.bundle in s:bundles
let s:tmp_options = get(s:i.bundle, 1, {})
if get(s:tmp_options, ":skip")
continue
elseif get(s:tmp_options, ":prefer_local")
if isdirectory(fnamemodify(s:bundle_local_repo_dir . split(s:i.bundle[0], '/')[-1], ':p'))
call extend(s:tmp_options, {
\ "base": s:bundle_local_repo_dir,
\ "type": "none",
\ "frozen": 1
\ })
endif
endif
if type(get(s:tmp_options, ":filetypes")) == type([])
call extend(s:tmp_options, {
\ "lazy": 1,
\ "on_ft": get(s:tmp_options, ":filetypes")
\ })
endif
call filter(s:tmp_options, "v:key[0] != ':'")
call neobundle#add(s:i.bundle[0], s:tmp_options)
endfor
unlet! s:bundles s:tmp_options
" }}}2 Listing
" }}}1 Bundles =======================================
" Plugin Config: {{{1 ============================================
runtime! ftplugin/man.vim " 啟用 |:Man| 指令
runtime! macros/matchit.vim
let g:loaded_getscriptPlugin = 1
" Ag {{{2
call neobundle#config('ag.vim', {
\ 'lazy': 1,
\ 'on_cmd': {'name': 'Ag', 'complete': 'dir'}
\ })
" }}}2 Ref {{{2
call neobundle#config('vim-ref', {
\ 'lazy': 1,
\ 'on_cmd': 'Ref'
\ })
if neobundle#tap('vim-ref')
let g:ref_cache_dir = expand('~/.vim/ref-cache')
if $OSTYPE =~ '^darwin' " Mac man has no `-T` option
let g:ref_man_cmd = 'man -P cat'
endif
call neobundle#untap()
endif
" FIXME: enable 'lazy'
call neobundle#config('vim-ref-bingzh', {
\ 'lazy': 0,
\ 'depends': 'vim-ref',
\ 'autoload': {
\ 'commands': 'Ref',
\ 'function_prefix': 'ref'
\ }
\ })
if neobundle#tap('vim-ref-bingzh')
if executable('opencc')
let g:ref_bingzh_opencc_config = 't2s.json'
endif
function! neobundle#hooks.on_source(bundle)
autocmd FileType ref-bingzh call s:initialize_ref_viewer_bingzh()
function! s:initialize_ref_viewer_bingzh()
setlocal number nowrap
setlocal noreadonly
setlocal modifiable
setlocal foldmethod=expr foldlevel=1 foldexpr=RefBingZhFold(v:lnum)
endfunction
function! RefBingZhFold(line)
return <SID>ref_bingzh_fold(a:line)
endfunction
function! s:ref_bingzh_fold(line)
let splitter = '\v ##$'
if getline(a:line) =~ splitter
return '>1'
elseif getline(a:line+1) =~ splitter
return '<1'
else
return '='
endif
endfunction
endfunction
nnoremap <silent> K :call ref#jump('normal', 'bingzh')<CR>
xnoremap <silent> K :call ref#jump('visual', 'bingzh')<CR>
nnoremap <silent> <LocalLeader>K :normal! K<CR>
xnoremap <silent> <LocalLeader>K :normal! K<CR>
call neobundle#untap()
endif
" }}}2 qfreplace {{{2
call neobundle#config('vim-qfreplace', {
\ 'lazy': 1,
\ 'on_ft': ['qf']
\ })
autocmd my_vimrc FileType qf nnoremap <buffer> r :<C-U>Qfreplace tabnew<CR>
" }}}2 Zenkaku Space {{{2
if neobundle#tap('vim-zenspace')
let g:zenspace#default_mode = 'on'
call neobundle#untap()
endif
" }}}2 neosnippet {{{2
call neobundle#config('neosnippet', {
\ 'lazy': 1,
\ 'on_i': 1,
\ 'on_ft': 'snippet',
\ })
if neobundle#tap('neosnippet')
let g:neosnippet#snippets_directory = expand('~/.vim/snippets')
imap <expr><Tab> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : pumvisible() ? "\<C-N>" : "\<Tab>"
" TODO jump back to previous placeholder
imap <expr><S-Tab> neosnippet#jumpable() ?
\ "\<Plug>(neosnippet_jump_or_expand)" : pumvisible() ? "\<C-P>" : "\<S-Tab>"
smap <Tab> <Plug>(neosnippet_expand_or_jump)
let g:neosnippet#disable_runtime_snippets = {
\ 'css': 1
\ }
" TODO migrate all my snipMate settings
" https://github.com/bootleq/snipmate.vim/tree/master/snippets
" ~/repository/snipmate.vim
command! -bang -bar -complete=filetype -nargs=? EditSnippets call s:edit_snippets(<bang>0, [<f-args>])
function! s:edit_snippets(runtime_snippets, args) "{{{
let l:filetype = get(a:args, 0, &l:filetype)
if !empty(l:filetype)
tab split
if a:runtime_snippets
execute "NeoSnippetEdit -runtime " . l:filetype
else
execute "NeoSnippetEdit " . l:filetype
endif
endif
endfunction "}}}
call neobundle#untap()
endif
" }}}2 Netrw {{{2
call neobundle#config('netrw.vim', {
\ 'lazy': 1,
\ 'on_cmd': 'Explore'
\ })
if neobundle#tap('netrw.vim')
" let g:netrw_ftp = 1
" let g:netrw_preview = 1
" let g:netrw_ignorenetrc = 0
" let g:netrw_ftpextracmd = 'passive'
let g:netrw_liststyle = 3
let g:netrw_winsize = 20
" let g:netrw_browsex_viewer = '-'
let g:netrw_timefmt = '%Y-%m-%d %T'
" if exists("g:qfix_win") && a:forced == 0
function! neobundle#tapped.hooks.on_source(bundle) "{{{
nmap <leader>e :Vexplore<CR>
endfunction "}}}
call neobundle#untap()
endif
" }}}2 FastFold {{{2
if neobundle#tap('FastFold')
nmap <SID>(DisableFastFoldUpdate) <Plug>(FastFoldUpdate)
call neobundle#untap()
endif
" }}}2 open-browser {{{2
call neobundle#config('open-browser.vim', {
\ 'lazy': 1,
\ 'autoload': {
\ 'mappings': ['<Plug>(openbrowser-search)', '<Plug>(openbrowser-smart-search)']
\ }
\ })
if neobundle#tap('open-browser.vim')
let g:openbrowser_search_engines = {
\ 'morebile': 'http://www.google.com.tw/m/search?site=dictionary&gdm=1&wtr=1&q={query}',
\ 'dictionary': 'http://www.google.com/dictionary?q={query}',
\ 'google': 'http://google.com/search?q={query}',
\ }
let g:openbrowser_default_search = 'google'
let g:openbrowser_force_foreground_after_open = 1
" ["'"] removed
let g:openbrowser_iskeyword = join(
\ range(char2nr('A'), char2nr('Z'))
\ + range(char2nr('a'), char2nr('z'))
\ + range(char2nr('0'), char2nr('9'))
\ + ['_', ':', '/', '.', '-', '+', '%', '#', '?', '&', '=', ';', '@', '$', ',', '[', ']', '!', "(", ")", "*", "~", ],
\ ',')
nmap <Leader><CR> <Plug>(openbrowser-smart-search)
vmap <Leader><CR> <Plug>(openbrowser-smart-search)
nmap <Leader>s<CR> <Plug>(openbrowser-search)
vmap <Leader>s<CR> <Plug>(openbrowser-search)
call neobundle#untap()
endif
" }}}2 giti {{{2
if neobundle#tap('vim-unite-giti')
call neobundle#config({
\ 'autoload' : {
\ 'unite_sources' : [
\ 'giti',
\ 'giti/status'
\ ],
\ }
\ })
call neobundle#untap()
endif
" }}}2 vimfiler {{{2
call neobundle#config('vimfiler', {
\ 'lazy': 1,
\ 'depends': 'Shougo/unite.vim',
\ 'autoload': {
\ 'commands': [
\ {'name': 'VimFiler', 'complete': 'customlist,vimfiler#complete'},
\ 'VimFilerExplorer', 'VimFilerSplit', 'Edit', 'Read', 'Source', 'Write'
\ ],
\ 'mappings': ['<Plug>(vimfiler_switch)']
\ }
\ })
let bundle = neobundle#get('vimfiler')
function! bundle.hooks.on_source(bundle)
let g:loaded_netrwPlugin = 1
let g:vimfiler_as_default_explorer = 1
let g:vimfiler_edit_action = 'tabopen'
let g:vimfiler_enable_clipboard = 0
let g:vimfiler_safe_mode_by_default = 0
let g:vimfiler_time_format = '%y-%m-%d %H:%M'
if $OSTYPE == 'cygwin' || has("gui_win32")
let g:unite_kind_file_use_trashbox = 1
let g:vimfiler_detect_drives = [
\ 'C:/', 'D:/', 'E:/', 'F:/', 'G:/', 'H:/', 'I:/',
\ 'J:/', 'K:/', 'L:/', 'M:/', 'N:/']
elseif $OSTYPE == 'linux-gnu'
let g:vimfiler_detect_drives =
\ split(glob('/mnt/*'), '\n') + split(glob('/media/*'), '\n')
endif
autocmd my_vimrc FileType vimfiler call s:vimfiler_my_settings()
function! s:vimfiler_my_settings()
nnoremap <silent><buffer> H <Nop>
endfunction
endfunction
" }}}2 vimfiler
" }}}1 Plugin Config ===========================================
" Bundle Finish: {{{1 ========================================
call neobundle#end()
filetype plugin indent on
" }}}1 Bundle Finish =======================================
" Basic Options: {{{1 ==========================================
" }}}2 檔案格式 {{{2
set fileformats=unix
set noendofline
" }}}2 GUI {{{2
if has("gui_running")
set antialias
source $VIMRUNTIME/delmenu.vim
set langmenu=zh_TW.UTF-8
source $VIMRUNTIME/menu.vim
set fileformats+=dos
set guioptions=gri
let did_install_default_menus = 1
let did_install_syntax_menu = 1
let do_syntax_sel_menu = 1
let no_buffers_menu = 1
let bmenu_max_pathlen = 50
if has("gui_win32")
set guifont=Consolas:h11,\ Monaco:h10
set guifontwide=Consolas:h11
" set guifontwide=Microsoft\ JhengHei,\ Meiryo,\ cwTeXMing
set winaltkeys=no
elseif has("gui_macvim")
set guifont=Consolas:h14,\ Monaco:h14
set guifontwide=Consolas:h14
" set guifontwide=Microsoft\ JhengHei,\ Meiryo,\ cwTeXMing
set winaltkeys=no
else
set guifont=Liberation\ Mono\ 12
" set guifont=Consolas\ 14
" set guifont=Monospace\ 12
" set guifontwide=文泉驛等寬微米黑\ 12
set guifontwide=AR\ PL\ UMing\ TW\ MBE\ 12
endif
endif
" }}}2 Vim 記憶選項 {{{2
set history=666
set viewoptions=folds,cursor
set updatetime=10000
set noswapfile
set directory-=.
set backupdir-=.
set nowritebackup
set updatecount=0
" }}}2 term 相關調整 {{{2
set ttyfast
if &term =~ "xterm"
set t_#4=[D " C-Left 視環境調整
set t_%i=[C " C-Right 視環境調整
set t_Co=256
" MinTTy 游標形狀
if $OSTYPE == 'cygwin' || $VM_HOST_OS == 'cygwin'
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
endif
endif
" }}}2 排版、縮排 {{{2
set expandtab tabstop=2 softtabstop=2 shiftwidth=2 autoindent smartindent smarttab
set shiftround
set cinkeys-=:
set cinoptions+=(0
set textwidth=78
try
set breakindent
set showbreak=\\
catch /^Vim\%((\a\+)\)\=:E518/
endtry
try
setlocal formatoptions=roql2mBj
catch /^Vim\%((\a\+)\)\=:E539/
setlocal formatoptions=roql2m
endtry
" NOTE foldmethod can be local, but I prefer global setting
if &foldmethod == 'manual'
set foldmethod=marker
endif
" }}}2 編輯功能 {{{2
set mouse=nvi
set virtualedit=block
set clipboard=autoselect,exclude:cons\|linux
set tildeop
set backspace=indent,eol,start
set whichwrap=b,s,<,>,[,]
set nojoinspaces
set nrformats=hex
set nostartofline
set scrolloff=10
set sidescrolloff=40
set sidescroll=1
set scrollopt=ver,hor,jump
set timeoutlen=4000
" }}}2 顯示、外觀 {{{2
set cursorline
set number
set hlsearch
nohlsearch
set ruler
set showcmd
set shortmess+=I
if v:version > 704 || (v:version == 704 && has('patch314'))
set shortmess+=c
endif
set nolinebreak
set display=lastline
set listchars=tab:>-,eol:¬,trail:*,extends:»,precedes:«
set background=dark
set ambiwidth=single
syntax on
if v:version > 704 || (v:version == 704 && has('patch88'))
else
" http://blogger.godfat.org/2011/07/spellcheck-only-for-english-in-vim.html
syntax match Normal /[^!-~]/ contains=@NoSpell
endif
if !exists('g:colors_name')
set background=dark
try
colorscheme bootleg
catch /^Vim\%((\a\+)\)\=:E185/
endtry
endif
set title titlestring=%t%(\ %M%)%(\ (%{expand(\"%:~:.:h\")})%)%(\ %a%)
set statusline=%<%f\ %h%m%r%w%=%-14.(%l,%c%V%)\ %P
set showtabline=2
" }}}2 尋找、搜尋 {{{2
" set autochdir
set ignorecase
set smartcase
set incsearch
set matchpairs+=<:>
" https://github.com/lilydjwg/dotvim/commit/880fc3b
try
set matchpairs+=《:》,〈:〉,[:],(:),「:」,『:』,‘:’,“:”
catch /^Vim\%((\a\+)\)\=:E474/
endtry
" set includeexpr=substitute(v:fname,'\\.','/','g')
" }}}2 自動完成 {{{2
set omnifunc=syntaxcomplete#Complete
set pumheight=20
set menuitems=35
set completeopt=longest,menu
set complete+=U
set showfulltag
set wildmenu
set wildmode=longest:full,full
set wildoptions=tagfile
" set wildignore+=*.o,*.a,*.so,*.obj,*.exe,*.lib,*.ncb,*.opt,*.plg,.svn,.git
" }}}2 多檔案編輯 {{{2
set splitbelow
set splitright
set noequalalways
set previewheight=9
set switchbuf=useopen,usetab,newtab
set tabpagemax=400
set diffopt+=vertical,context:4,foldcolumn:1
set hidden
" }}}2 Vim 7.3 / 7.4 {{{2
if version >= 703
set conceallevel=1
set concealcursor=nc
set colorcolumn=+1
set cinoptions+=L0
set undofile
set undodir=~/.vim/undofiles
if !isdirectory(&undodir)
call mkdir(&undodir, "p")
endif
map <C-ScrollWheelDown> <ScrollWheelRight>
map <C-ScrollWheelUp> <ScrollWheelLeft>
imap <C-ScrollWheelDown> <ScrollWheelRight>
imap <C-ScrollWheelUp> <ScrollWheelLeft>
if exists('+regexpengine')
set regexpengine=0
endif
try
setlocal formatoptions+=j
catch /^Vim\%((\a\+)\)\=:E539/
endtry
endif
" }}}2
" }}}1 Basic Options ==========================================
" Mappings: {{{1 =================================================
let maplocalleader = ","
noremap <Leader><LocalLeader> <LocalLeader>
noremap! <Leader><LocalLeader> <LocalLeader>
noremap <LocalLeader>, <C-\><C-N>
noremap! <LocalLeader>, <C-\><C-N>
" 各種移動 {{{2
nnoremap <expr> <Space> <SID>scroll_down()
nnoremap <expr> <LocalLeader><Space> <SID>scroll_up()
xnoremap <expr> <Space> <SID>scroll_down('v')
xnoremap <expr> <LocalLeader><Space> <SID>scroll_up('v')
for s:i.map_mode in ['n', 'o', 'x']
execute s:i.map_mode . "noremap j gj"
execute s:i.map_mode . "noremap k gk"
execute s:i.map_mode . "noremap gj j"
execute s:i.map_mode . "noremap gk k"
endfor
inoremap <expr> <Down> pumvisible() ? "\<C-N>" : "\<C-O>gj"
inoremap <expr> <Up> pumvisible() ? "\<C-P>" : "\<C-O>gk"
nmap <silent><Home> :call SmartHome("n")<CR>
nmap <silent><End> :call SmartEnd("n")<CR>
imap <silent><Home> <C-R>=SmartHome("i")<CR>
imap <silent><End> <C-R>=SmartEnd("i")<CR>
vmap <silent><Home> <Esc>:call SmartHome("v")<CR>
vmap <silent><End> <Esc>:call SmartEnd("v")<CR>
nnoremap <silent> <LocalLeader>I :call SmartHome("n")<CR>
nnoremap <silent> <LocalLeader>A :call SmartEnd("n")<CR>
vnoremap <silent> <LocalLeader>I <Esc>:call SmartHome("v")<CR>
vnoremap <silent> <LocalLeader>A <Esc>:call SmartEnd("v")<CR>
map <kHome> <Home>
map! <kHome> <Home>
map <kEnd> <End>
map! <kEnd> <End>
nnoremap ' `
nmap <LocalLeader>w <C-W>
nnoremap <C-W>V :wincmd K <Bar> wincmd =<CR>
nnoremap <silent> <C-W>m :MoveIntoTabpage<CR>
nnoremap <silent> <C-W>M :MoveIntoTabpage <count> <C-R>=tabpagenr()-1<CR><CR>
nnoremap <silent> <localleader>z :wincmd z<CR>
nmap <localleader>gf <C-W>gf
vmap <localleader>gf <C-W>gf
nnoremap <expr> <CR> &modifiable ? "i<CR><C-\><C-N>" : "<C-]>"
nnoremap <expr> <BS> &modifiable ? "i<C-W><C-\><C-N>" : "<C-O>"
nnoremap gr gT
nnoremap <silent> gT :tablast<CR>
nnoremap <silent> gR :tabfirst<CR>
nnoremap <silent> <expr> <LocalLeader>gt printf(":tabmove %s<CR>", tabpagenr() == tabpagenr('$') ? 0 : tabpagenr() + 1)
nnoremap <silent> <expr> <LocalLeader>gr printf(":tabmove %s<CR>", tabpagenr() == 1 ? '' : tabpagenr() - 2)
nnoremap <silent> <LocalLeader>gT :tabmove<CR>
nnoremap <silent> <LocalLeader>gR :tabmove 0<CR>
" Scroll to top/center/bottom (@Shougo)
noremap <expr> zz (winline() == (winheight(0)+1)/ 2) ?
\ 'zt' : (winline() == 1)? 'zb' : 'zz'
" }}}2 編輯 {{{2
nmap <C-H> <BS>
nnoremap p ]p
nnoremap Y y$
nnoremap vaa ggVG
nnoremap <LocalLeader>gv V`]
autocmd FileType qf nnoremap <buffer> <CR> <CR>
nnoremap <LocalLeader>< i0<C-D><C-\><C-N>
inoremap <LocalLeader>< 0<C-D>
xnoremap <LocalLeader>< 99<
inoremap <C-Z> <C-O>u
inoremap <C-W> <C-G>u<C-W>
inoremap <expr> <C-U> (pumvisible() ? "\<C-E>" : '') . "\<C-G>u\<C-U>"
nnoremap <LocalLeader>u <C-R>
inoremap <LocalLeader>o <C-O>
inoremap <LocalLeader>r <C-R>
cnoremap <LocalLeader>r <C-R>
noremap <silent> <C-S> :update<CR>
inoremap <silent> <C-S> <C-\><C-N>:update<CR>
xnoremap <silent> <C-S> <C-\><C-N>:update<CR>
noremap <C-Del> :quit<CR>
noremap <C-kDel> :quit<CR>
noremap <C-BS> :quit<CR>
map <kDel> <Del>
" TODO command mode text-object delete
" noremap! <LocalLeader>w
cnoremap <LocalLeader>; <C-W>
cmap <LocalLeader>v <C-F>
" Delete to end, from @tyru https://github.com/tyru/dotfiles
cnoremap <LocalLeader>d <C-\>e getcmdpos() == 1 ? '' : getcmdline()[:getcmdpos()-2]<CR>
" Auto escape / and ? in search command (@Shougo)
cnoremap <expr> / getcmdtype() == '/' ? '\/' : '/'
cnoremap <expr> ? getcmdtype() == '?' ? '\?' : '?'
" Switch between /\<keyword\> and /keyword
nnoremap <expr> <LocalLeader>/ getreg('/') =~ '^\\<.*\\>$' ?
\ '/' . matchstr(getreg('/'), '^\\<\zs.*\ze\\>$') :
\ '/\<' . getreg('/') . '\>'
" }}}2 功能鍵 {{{2
noremap <F1> :help <C-R>=expand('<cword>')<CR><CR>
noremap <LocalLeader><F1> :tab help <C-R>=expand('<cword>')<CR><CR>
xnoremap <F1> :<C-U>call SaveReg()<CR>gvy:let b:tempReg=@"<CR>:call RestoreReg()<CR>:help <C-R>=b:tempReg<CR><CR>
xnoremap <LocalLeader><F1> :<C-U>call SaveReg()<CR>gvy:let b:tempReg=@"<CR>:call RestoreReg()<CR>:tab help <C-R>=b:tempReg<CR><CR>
nnoremap <F2> :%s/<C-R><C-W>
xnoremap <F2> :<C-U>call SaveReg()<CR>gvy:let b:tempReg=@"<CR>:call RestoreReg()<CR>gv:<C-U>%s/\V<C-R>=escape(b:tempReg, '/')<CR>/
if exists('v:hlsearch') " require Vim 7.4.079
noremap <silent><expr> <F3> v:hlsearch ? ':nohlsearch<CR>' : ':set hlsearch<CR>'
inoremap <silent><expr> <F3> v:hlsearch ? '<C-\><C-O>:nohlsearch<CR>' : '<C-\><C-O>:set hlsearch<CR>'
else
noremap <silent> <F3> :nohlsearch<CR>
inoremap <silent> <F3> <C-\><C-O>:nohlsearch<CR>
noremap <silent> <F4> :set hlsearch<CR>
inoremap <silent> <F4> <C-\><C-O>:set hlsearch<CR>
endif
nnoremap <F5> :call SynStackInfo()<CR>
nnoremap <silent> <F6> :QuickOff<CR>
nnoremap <LocalLeader><F6> :tabclose<CR>
if v:version > 704 || (v:version == 704 && has('patch88'))
nnoremap <silent><F8> :setlocal spell! spelllang=en_us,cjk spell?<CR>
xnoremap <silent><F8> :<C-U>setlocal spell! spelllang=en_us,cjk spell?<CR>gv
inoremap <silent><F8> <C-O>:setlocal spell! spelllang=en_us,cjk spell?<CR>
else
nnoremap <silent><F8> :setlocal spell! spelllang=en_us spell?<CR>
xnoremap <silent><F8> :<C-U>setlocal spell! spelllang=en_us spell?<CR>gv
inoremap <silent><F8> <C-O>:setlocal spell! spelllang=en_us spell?<CR>
endif
set pastetoggle=<F11>
map <silent> <F12> :set list!<CR>
imap <silent> <F12> <C-O>:set list!<CR>
" }}}2 自動完成 {{{2
cnoremap <LocalLeader>. <C-E>
cnoremap <LocalLeader><CR> <C-E>
inoremap <LocalLeader>. <C-X><C-O>
inoremap <expr> <C-J> pumvisible() ? "\<C-N>" : "\<C-J>"
inoremap <expr> <C-K> pumvisible() ? "\<C-P>" : "\<C-K>"
" }}}2 Quickfix {{{2
" Ref: kana - https://github.com/kana/config
" Note: -- Ex-mode will be never used and recordings are rarely used.
nmap q [quickfix]
nmap [quickfix]w [localist]
nnoremap [quickfix] <Nop>
nnoremap [localist] <Nop>
nnoremap Q q
" Quickfix list {{{3
nnoremap <silent> [quickfix]j :cnext<CR>
nnoremap <silent> [quickfix]k :cprevious<CR>
nnoremap <silent> [quickfix]r :crewind<CR>
nnoremap <silent> [quickfix]K :cfirst<CR>
nnoremap <silent> [quickfix]J :clast<CR>
nnoremap <silent> [quickfix]l :clist<CR>
nnoremap <silent> [quickfix]o :copen<CR>
nnoremap <silent> [quickfix]c :cclose<CR>
nnoremap <silent> [quickfix]p :colder<CR>
nnoremap <silent> [quickfix]n :cnewer<CR>
" }}} Location list {{{3
nnoremap <silent> [localist]j :lnext<CR>
nnoremap <silent> [localist]k :lprevious<CR>
nnoremap <silent> [localist]r :lrewind<CR>
nnoremap <silent> [localist]K :lfirst<CR>
nnoremap <silent> [localist]J :llast<CR>
nnoremap <silent> [localist]l :llist<CR>
nnoremap <silent> [localist]o :lopen<CR>
nnoremap <silent> [localist]c :lclose<CR>
nnoremap <silent> [localist]p :lolder<CR>
nnoremap <silent> [localist]n :lnewer<CR>
" }}}
" }}}2 User text objects {{{2
let g:textobj_rubyblock_no_default_key_mappings = 1
" TODO 那如果不是 ruby 的話咧?
function! s:textobj_rubyblock_settings()
xmap <buffer> ab <Plug>(textobj-rubyblock-a)
omap <buffer> ab <Plug>(textobj-rubyblock-a)
xmap <buffer> ib <Plug>(textobj-rubyblock-i)
omap <buffer> ib <Plug>(textobj-rubyblock-i)
endfunction
autocmd! my_vimrc FileType ruby call s:textobj_rubyblock_settings()
let g:textobj_space_no_default_key_mappings = 1
xmap a<Space> <Plug>(textobj-space-a)
omap a<Space> <Plug>(textobj-space-a)
xmap i<Space> <Plug>(textobj-space-i)
omap i<Space> <Plug>(textobj-space-i)
let g:textobj_between_no_default_key_mappings = 1
xmap a/ <Plug>(textobj-between-a)
omap a/ <Plug>(textobj-between-a)
xmap i/ <Plug>(textobj-between-i)
omap i/ <Plug>(textobj-between-i)
let g:textobj_parameter_no_default_key_mappings = 1
xmap a; <Plug>(textobj-parameter-a)
omap a; <Plug>(textobj-parameter-a)
xmap i; <Plug>(textobj-parameter-i)
omap i; <Plug>(textobj-parameter-i)
let g:textobj_jabraces_no_default_key_mappings = 1
let s:textobj_multitextobj_textobjects_group_base_paren = [
\ "\<Plug>(textobj-jabraces-parens-%)",
\ "\<Plug>(textobj-jabraces-kakko-%)",
\ "\<Plug>(textobj-jabraces-double-kakko-%)",
\ "\<Plug>(textobj-jabraces-yama-kakko-%)",
\ "\<Plug>(textobj-jabraces-double-yama-kakko-%)",
\ "\<Plug>(textobj-jabraces-sumi-kakko-%)",
\ '%(',
\ '%[',
\ ]
let g:textobj_multitextobj_textobjects_group_i = {
\ "paren": map(
\ copy(s:textobj_multitextobj_textobjects_group_base_paren),
\ 'substitute(v:val, "%", "i", "")'
\ )
\ }
let g:textobj_multitextobj_textobjects_group_a = {