/
.vimrc
1217 lines (1148 loc) · 38.3 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
" Initialize
" # runtimepath {{{
if has('win32')
" INFO: .vimrc unifies vimrc
" .vim unifies vimfiles
set runtimepath^=$HOME/.vim
set runtimepath+=$HOME/.vim/after
endif
" }}}
" # encoding {{{
" Note: Kaoriya MacVim is needless encoding.
if !has('gui_macvim') || !has('kaoriya')
" INFO: If encode is fixed, :e ++enc = {encoding-name}
set encoding=utf-8
set fileencodings=utf-8,shiftjis,euc-jp,iso-2022-jp
endif
if has('win32')
set encoding=utf-8
set termencoding=&encoding
set fileencodings=utf-8,cp932,shiftjis,euc-jp,iso-2022-jp
endif
" }}}
" # Basic "{{{
"filetype plugin indent on
set nocompatible " Use Vim defaults (much better!)
set showcmd " Highliting bracket set.
set hidden " Enable open new file, when while editing other file.
set autoread
set history=255
set viminfo='20,\"50 " Read/write a .viminfo file, don't store more than 50 lines of registers
set backspace=indent,eol,start " Allow backspacing over everything in insert mode
set ambiwidth=double
set virtualedit+=block " Block-select to the end of the line for blockwise Visual mode.
set shortmess+=filmnrxoOtT " Avoid all the hit-enter prompts
set title
set completeopt=menuone " チラツキ防止
set helplang=ja,en
nnoremap <silent> <C-h> :<C-u>help<Space><C-r><C-w><CR>
let mapleader = " "
" }}}
" Local Dependency
set nobackup noswapfile
let g:my_config_use_plugin = get(g:, 'my_config_use_plugin', 0)
let $MYVIMRC_LOCAL = $HOME . '/.vimrc.local'
if filereadable(expand($MYVIMRC_LOCAL))
set backup swapfile
" INFO: Read more .vimrc.local.dist
source $MYVIMRC_LOCAL
let $MYVIMRC = g:local_config['dotfiles_dir'] . '/.vimrc'
" Quick start my vimrc
nnoremap <silent> e. :<C-u>edit $MYVIMRC<CR>
nnoremap <silent> eS :<C-u>source $MYVIMRC<CR>
" Use weekly buffer for GTD.
nnoremap <silent> <S-t><S-t> :call weekly_buffer#open()<CR>
" Load settings for each location {{{
augroup load_local_config
autocmd!
autocmd BufNewFile,BufReadPost * call s:load_rc_local(expand('<afile>:p:h'))
augroup END
function! s:load_rc_local(loc)
let files = findfile('.vimrc.local', escape(a:loc, ' ') . ';', -1)
for i in reverse(filter(files, 'filereadable(v:val)'))
source `=i`
endfor
endfunction " }}}
" Bundle {{{
if g:my_config_use_plugin && !exists('g:loaded_neobundle')
source $HOME/.vim/bundle.vim
let s:bundle_dir = $HOME . '/.vim/bundle'
endif
" }}}
endif
let s:tmpdir = exists('g:local_config["tmp_dir"]')
\ ? g:local_config['tmp_dir']
\ : $HOME
" # Switch ; <-> : {{{
" Warning: Don't use ':remap' as possible (for Unaffected).
nnoremap ; :
nnoremap : ;
vnoremap ; :
vnoremap : ;
nnoremap q; q:
vnoremap q; q:
" }}}
" # Syntax {{{
if has('syntax')
syntax enable
set synmaxcol=1500
set nospell
"scriptencoding utf-8
set list
" - tab: タブ文字, trail: 行末スペース, eol: 改行文字, extends: 行末短縮, precedes: 行頭短縮, nbsp: 空白文字
set listchars=tab:»-,extends:>,precedes:<,eol:↲,nbsp:%,trail:-,nbsp:>
augroup ZenSpace
autocmd!
autocmd ColorScheme * highlight ZenSpace cterm=reverse ctermfg=DarkMagenta gui=reverse guifg=DarkMagenta
autocmd WinEnter,BufNew,BufReadPost,ColorScheme *
\ if &filetype !~ 'unite\|vimshell\|vimfiler\|git\|rst'
\ | match ZenSpace / \|\s\+$/ |
\ endif
augroup END
if v:version >= 703
set relativenumber
endif
set number
set numberwidth=4
endif
" }}}
" # Indent {{{
set autoindent
set expandtab " replaced Tab with Indent
setlocal tabstop=4
setlocal shiftwidth=4
setlocal softtabstop=0
:let g:vim_indent_cont = 2
" }}}
" # Filetype Detect {{{
" Moved ~/.vim/filetype.vim
let g:sql_type_default = 'mysql' " SQL
" }}}
" # Color Scheme {{{
set t_Co=256
if !has('gui_runnig') || !g:my_config_use_plugin || !exists('g:colors_name')
let g:colors_name = 'desert'
set background=dark
endif
let g:solarized_termcolors = 256 " CASE: g:colors_name is solarized
" Add cursorline at the current window.
augroup cch
autocmd!
autocmd WinLeave * set nocursorline
autocmd WinEnter,BufRead * set cursorline
augroup END
let g:apache_version = '2.0' " apache highliting
" highlighting target of long line.
if exists('&colorcolumn')
set colorcolumn=+1
"nnoremap <silent> <Leader>l :<C-u>set<Space>spell!<Space>list!<Space>colorcolumn=-1<CR>
nnoremap <silent> <Leader>l :<C-u>set<Space>list!<Space>colorcolumn=-1<CR>
endif
"# HIGHLIGHT_CURRENT_LINE
nnoremap <silent> <Leader>hs :<C-u>HighlightCurrentLine Search<CR>
nnoremap <silent> <Leader>hd :<C-u>HighlightCurrentLine DiffAdd<CR>
nnoremap <silent> <Leader>he :<C-u>HighlightCurrentLine Error<CR>
nnoremap <silent> <Leader>H :<C-u>UnHighlightCurrentLine<CR>
command! -nargs=1 HighlightCurrentLine execute 'match <args> /<bslash>%'.line('.').'l/'
command! -nargs=0 UnHighlightCurrentLine match
" }}}
" # Console {{{
" By Sir.thinca http://d.hatena.ne.jp/thinca/20101215/1292340358
if has('unix') && !has('gui_running')
" Use meta keys in console.
function! s:use_meta_keys() " {{{2
for i in map(
\ range(char2nr('a'), char2nr('z'))
\ + range(char2nr('A'), char2nr('Z'))
\ + range(char2nr('0'), char2nr('9'))
\ , 'nr2char(v:val)')
" <ESC>O do not map because used by arrow keys.
if i != 'O'
execute 'nmap <ESC>' . i '<M-' . i . '>'
endif
endfor
endfunction " }}}2
call s:use_meta_keys()
map <NUL> <C-Space>
map! <NUL> <C-Space>
" stopped job
nnoremap <silent> gZZ :set t_te = t_ti = <CR>:quit<CR>:set t_te& t_ti&<CR>
nnoremap <silent> gsh :set t_te = t_ti = <CR>:st<CR>:set t_te& t_ti&<CR>
nnoremap <silent> gst :set t_te = t_ti = <CR>:st<CR>:set t_te& t_ti&<CR>
endif
" }}}
" # Status Bar {{{
set ruler
set showcmd
set showmode
set cmdheight=1
set wildmenu
set wildmode=list:longest,full
set laststatus=2
set statusline=%<%f\ #%n%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%y%=%l,%c%V%8P
"set statusline=[%{winnr('$')>1?.winnr().'/'.winnr('$'):}]\ %<\ %f\ %m%r%h%w%y%{'['.(&fenc!=''?&fenc:&enc).'\|'.&ff.']'}%=%l/%L\ (%P)
" }}}
" # <Tab> {{{
set showtabline=2 " :h tabline
nnoremap tn :<C-u>tabnew<Space>
nnoremap <silent> <Tab> :<C-u>tabnext<CR>
nnoremap <silent> <S-Tab> :<C-u>tabprevious<CR>
" }}}
" # Search {{{
set hlsearch " Highlight search option
set incsearch " Typed so far, matches
set ignorecase " Ignoring case in a pattern
set smartcase " Override ignorecase option (search contains upper case).
set nowrapscan " Searches nowrap around.
nnoremap * *N
nnoremap # #N
" regex pattern
nnoremap \ /^
" }}}
" # Copy & Paste {{{
"set paste " When you're setting paste, can't use inoremap extend ;-<
if has('clipboard')
set clipboard=unnamed,autoselect
" For Ubuntu "+y not * (;h clipboard)
" Copy
vnoremap <C-c> "+y
" Paste
vnoremap <C-v> d"+P
cnoremap <C-v> <C-R>+
inoremap <C-v> <ESC>"+pa
" source $VIMRUNTIME/mswin.vim
endif
" }}}
" # Insert {{{
inoremap { {}<LEFT>
inoremap [ []<LEFT>
inoremap ( ()<LEFT>
inoremap \| \|\|<LEFT>
inoremap " ""<LEFT>
inoremap ' ''<LEFT>
inoremap ` ``<LEFT>
inoremap \|\| \|
inoremap "" "
inoremap '' '
inoremap `` `
inoremap <C-r> <CR>
cnoremap { {}<LEFT>
cnoremap [ []<LEFT>
cnoremap ( ()<LEFT>
cnoremap \| \|\|<LEFT>
cnoremap "" ""<LEFT>
cnoremap '' ''<LEFT>
cnoremap `` ``<LEFT>
cnoremap \|\| \|\|<LEFT>
" Support Input Date
inoremap <expr> ,df strftime('%Y-%m-%d %H:%M')
inoremap <expr> ,dd strftime('%Y-%m-%d')
inoremap <expr> ,dt strftime('%H:%M:%S')
" Input vertical serial number
nnoremap <silent> co :ContinuousNumber <C-a><CR>
vnoremap <silent> co :ContinuousNumber <C-a><CR>
command! -count -nargs=1 ContinuousNumber
\ let c = col('.')
\ | for n in range(1, <count>?<count>-line('.'):1)
\ | exec 'normal! j' . n . <q-args>
\ | call cursor('.', c)
\ | endfor
" }}}
" # Yank {{{
" Like nmap 'D' and 'C'
nnoremap Y y$
" カーソル位置の単語をヤンクした単語に置換
nnoremap <silent> cy ciw<C-r>0<ESC>:let@/=@1<CR>:noh<CR><ESC>
nnoremap <silent> ciy ce<C-r>0<ESC>:let@/=@1<CR>:noh<CR><ESC>
" }}}
" # IME Control {{{
" <ESC> insert mode, IME off
set noimdisable
set iminsert=0 imsearch=0
set noimcmdline
inoremap <silent> <C-@> <ESC>:set iminsert=0<CR>
inoremap <silent> <C-]> <ESC>:set iminsert=0<CR>
inoremap <silent> <ESC> <ESC>:set iminsert=0<CR>
if has('multi_byte_ime')
augroup MutibyteIMEStrategy
autocmd!
autocmd ColorScheme * highlight Cursor guifg=#000d18 guibg=#8faf9f gui=bold
autocmd ColorScheme * highlight CursorIM guifg=NONE guibg=#ecbcbc
augroup END
endif
augroup InsModeAu
autocmd!
autocmd InsertEnter,CmdwinEnter * set noimdisable
autocmd InsertLeave,CmdwinLeave * set imdisable
augroup END
" }}}
" # Moving Cursole {{{
augroup MovementPreviousSaveLine
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$")
\ | exe "normal g`\"" |
\ endif
augroup END
" for snippet complete
nnoremap j gj
onoremap j gj
xnoremap j gj
nnoremap k gk
onoremap k gk
xnoremap k gk
nnoremap gj j
nnoremap gk k
nnoremap <C-j> <C-f>
nnoremap <C-k> <C-b>
" .bash like
" but up-down mapped j-k
inoremap <C-a> <C-o>0
inoremap <C-e> <C-o>$
inoremap <C-k> <Up>
inoremap <C-j> <Down>
inoremap <C-b> <Left>
inoremap <C-f> <Right>
inoremap <C-d> <Delete>
cnoremap <C-a> <Home>
cnoremap <C-e> <END>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <C-l> <C-d>
cnoremap <C-d> <Delete>
nnoremap cw ciw
nnoremap dw diw
inoremap <C-w> <ESC>ciw
" selected at last editting text.
"" ちなみにVisualModeで最後に選択したテキストのに戻るはgv
nnoremap gc '[v']
vnoremap <silent>gc :<C-u>normal gc<CR>
onoremap <silent>gc :<C-u>normal gc<CR>
" vim-users.jp Hack #214
nnoremap ) f)
nnoremap ( f(
onoremap ) f)
onoremap ( f(
vnoremap ) f)
vnoremap ( f(
" Only do this part, when compiled with support for autocommands
augroup RedHatEnterpriseNantoka "{{{2
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$")
\ | exe "normal! g'\"" |
\ endif
augroup END "}}}
" }}}
" # Window {{{
" FIXME: When setted winmin(height|width), errored unite-outline
"set winminheight=8
"set winminwidth=20
"set winfixheight
"set winfixwidth
set splitright " Default vsplit, left
set splitbelow " Default split, top
" vim-users.jp Hack #42
"nnoremap <silent> <C-w>h <C-w>h:call <SID>good_width()<CR>
"nnoremap <silent> <C-w>l <C-w>l:call <SID>good_width()<CR>
"nnoremap <silent> <C-w>H <C-w>H:call <SID>good_width()<CR>
"nnoremap <silent> <C-w>L <C-w>L:call <SID>good_width()<CR>
function! s:good_width() "{{{2
if winwidth(0) < 84 && &ft != 'taglist' && &ft != 'quickrun'
vertical resize 84
endif
endfunction "}}}2
set noequalalways " Minimize Window Size
" }}}
" # Buffer {{{
" Inspaired @taku-o's Kwdb.vim
:com! Kwbd let kwbd_bn= bufnr("%")|enew|exe "bdel ".kwbd_bn|unlet kwbd_bn
nnoremap <silent> <Leader>d :<C-u>:Kwbd<CR>
" }}}
" # Fold, View {{{
nnoremap <Leader>f za
set foldcolumn=4
" INFO: foldlevel moved to each fplugin
"set foldlevel=0
set fillchars+=fold:-
" Don't save options.
set viewoptions-=options
if has('win32')
set viewoptions+=unix
endif
augroup MkviewAccessor " Save fold settings. Vim-user.jp Hack #84
autocmd!
autocmd BufWritePost *
\ if expand('%') !~ 'vim\|php\|ruby'
\ | exe "mkview" |
\ endif
autocmd BufRead *
\ if expand('%') !~ 'vim\|php\|ruby'
\ | exe "silent loadview" |
\ endif
augroup END
" }}}
" # Directory {{{
" disabled autochdir depends to Vimshell
"set autochdir
augroup AutoChDir
autocmd!
au BufEnter * execute ":silent! lcd " . escape(expand("%:p:h"), ' ')
augroup END
" Change directory. vim-users.jp Hack #69
nnoremap <silent> CD :<C-u>CD<CR>
nnoremap <silent> gu :<C-u>GU<CR>
" nmap `gh` is using vim-rooter
nnoremap <silent> gH :<C-u>GH<CR>
command! -nargs=? -complete=dir -bang CD call s:ChangeCurrentDir('<args>', '<bang>')
command! -nargs=? -complete=dir -bang GU call s:ChangeCurrentDir('../', '<bang>')
command! -nargs=? -complete=dir -bang GH call s:ChangeCurrentDir('$HOME', '<bang>')
function! s:ChangeCurrentDir(directory, bang) "{{{2
if a:directory == ''
lcd %:p:h
else
execute 'lcd' . a:directory
endif
if a:bang == ''
pwd
endif
endfunction "}}}
" }}}
" # Dictionary {{{
set dictionary=$HOME/.vim/dict/default.dict
"inoremap <silent> <C-k> <C-x><C-k> " FIXME: duplicate mapping <Up>
" }}}
" # Ctags {{{
if has('path_extra') && &filetype !~ 'zsh\|conf'
setlocal tags=~/tags
setlocal tags+=.
if filereadable("tags")
setlocal tags+=tags
endif
if filereadable("tags-ja")
setlocal tags+=tags-ja
endif
set showfulltag
set notagbsearch
endif
" }}}
" # Cscope {{{
"if has("cscope") && filereadable("/usr/bin/cscope")
" set csprg=/usr/bin/cscope
" set csto=0
" set cst
" set nocsverb
" " add any database in current directory
" if filereadable("cscope.out")
" cs add cscope.out
" " else add database pointed to by environment
" elseif $CSCOPE_DB != ""
" cs add $CSCOPE_DB
" endif
" set csverb
"endif
" }}}
" # Migemo {{{
" Howto: g/, g?
if has('migemo')
set migemo
endif
" }}}
" # Omni complete {{{
" omni_complete, completed each ftplugin
inoremap <silent> <C-o> <C-x><C-o>
" }}}
" # Undo persistence {{{
if has('persistent_undo')
augroup UndoPersistence
autocmd!
autocmd BufReadPost * call ReadUndo()
autocmd BufWritePost * call WriteUndo()
augroup END
function! ReadUndo() "{{{2
let undo_file = substitute(expand('%:p'), '\/\|\\', '\_', 'g')
if filereadable(&undodir .'/'. undo_file)
execute 'rundo' &undodir.'/'.undo_file
endif
endfunction "}}}
function! WriteUndo() "{{{2
if !isdirectory(&undodir)
call mkdir(&undodir)
endif
let undo_file = substitute(expand('%:p'), '\/\|\\', '\_', 'g')
execute 'wundo' &undodir.'/'.undo_file
endfunction "}}}
endif
" }}}
" Plugin
if !g:my_config_use_plugin
echo "INFO: g:my_config_use_plugin is 0 or not defined. and no reading plugin settings"
finish " ここまで読んだらお前は死ぬ
endif
" Plugin: vimproc {{{
"let g:vimproc_dll_path = s:bundle_dir . '/vimproc/autoload'
" }}}
" Plugin: vim-airline {{{
let g:airline_theme = 'badwolf'
"let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
"let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_linecolumn_prefix = '␊ '
let g:airline_linecolumn_prefix = ' '
let g:airline_linecolumn_prefix = '¶ '
let g:airline_branch_prefix = '⎇ '
let g:airline_paste_symbol = 'ρ'
let g:airline_paste_symbol = 'Þ'
let g:airline_paste_symbol = '∥'
let g:airline_enable_branch = 1
let g:airline_enable_syntastic = 1
let g:airline_detect_modified = 1
let g:airline_detect_paste = 1
let g:airline_powerline_fonts = 0
" }}}
" Plugin: vim-powerline {{{
"let g:Powerline_cache_file = s:tmpdir . '/Powerline.cache'
"let g:Powerline_symbols = 'fancy'
"let g:Powerline_theme = 'solarized256'
"let g:Powerline_colorscheme = 'solarized256'
" }}}
" Plugin: calendar.vim {{{
let g:calendar_wruler = '日 月 火 水 木 金 土 '
let g:calendar_weeknm = 1 " WK01
" }}}
" Plugin: taglist.vim {{{
if has('path_extra')
nnoremap <silent> tl :<C-u>Tlist<CR>
let g:Tlist_Exit_OnlyWindow = 1 " Closable When last window is taglist
let g:Tlist_WinWidth = 40
let g:Tlist_Enable_Fold_Column = 2
"let g:Tlist_Process_File_Always = 1
"let g:Tlist_Show_One_File = 1
endif
" }}}
" Plugin: submode.vim {{{
" Reside window
call submode#enter_with('winsize', 'n', '', '<C-w>>', '<C-w>>')
call submode#enter_with('winsize', 'n', '', '<C-w><', '<C-w><')
call submode#enter_with('winsize', 'n', '', '<C-w>+', '<C-w>-')
call submode#enter_with('winsize', 'n', '', '<C-w>-', '<C-w>+')
call submode#map('winsize', 'n', '', '>', '<C-w>>')
call submode#map('winsize', 'n', '', '<', '<C-w><')
call submode#map('winsize', 'n', '', '+', '<C-w>-')
call submode#map('winsize', 'n', '', '-', '<C-w>+')
" }}}
" Plugin: context_filetype.vim {{{
let g:context_filetype#filetypes = {
\ 'perl6' : [{
\ 'start' : 'Q:PIR\s*{',
\ 'end' : '}',
\ 'filetype' : 'pir',
\ }],
\ 'vim' : [{
\ 'start' : '^\s*python <<\s*\(\h\w*\)',
\ 'end' : '^\1',
\ 'filetype' : 'python',
\ }],
\ 'markdown': [{
\ 'start' : '^\s*```\s*\(\h\w*\)',
\ 'end' : '^\s*```$',
\ 'filetype' : '\1',
\ }],
\}
" }}}
" Plugin: indent-guides {{{
" INFO: auto highlight indent-space.
let g:indent_guides_color_change_percent = 30
let g:indent_guides_guide_size = 1
let g:indent_guides_enable_on_vim_startup = 1
" }}}
" Plugin: matchit.vim {{{
" INFO: Extended % command.
"if filereadable($HOME . '/macros/matchit.vim')
if filereadable(s:bundle_dir . '/matchit.zip/plugin/matchit.vim')
runtime macros/matchit.vim
let b:match_words = 'if:endif'
let b:match_ignorecase = 1
endif
" }}}
" Plugin: vim-textmanip {{{
xmap <C-j> <Plug>(Textmanip.move_selection_down)
xmap <C-k> <Plug>(Textmanip.move_selection_up)
xmap <C-h> <Plug>(Textmanip.move_selection_left)
xmap <C-l> <Plug>(Textmanip.move_selection_right)
" copy selected text-object.
vmap <M-d> <Plug>(Textmanip.duplicate_selection_v)
"}}}
" Plugin: visualstar.vim {{{
" search extended plugin.
if exists('g:loaded_visualstar')
map * <Plug>(visualstar-*)N
map # <Plug>(visualstar-#)N
endif
" }}}
" Plugin: alignta {{{
vnoremap <silent> > :Alignta =><CR>
" @todo add json type
" ex.) 'hoge': jojo
" 'jojolion': jojo
let g:unite_source_alignta_preset_arguments = [
\ ["Align at '='", '=>\='],
\ ["Align at ':'", '01 :'],
\ ["Align at '|'", '|' ],
\ ["Align at ')'", '0 )' ],
\ ["Align at ']'", '0 ]' ],
\ ["Align at '}'", '}' ],
\]
let s:comment_leadings = '^\s*\("\|#\|/\*\|//\|<!--\)'
let g:unite_source_alignta_preset_options = [
\ ["Justify Left", '<<' ],
\ ["Justify Center", '||' ],
\ ["Justify Right", '>>' ],
\ ["Justify None", '==' ],
\ ["Shift Left", '<-' ],
\ ["Shift Right", '->' ],
\ ["Shift Left [Tab]", '<--'],
\ ["Shift Right [Tab]", '-->'],
\ ["Margin 0:0", '0' ],
\ ["Margin 0:1", '01' ],
\ ["Margin 1:0", '10' ],
\ ["Margin 1:1", '1' ],
\
\ 'v/' . s:comment_leadings,
\ 'g/' . s:comment_leadings,
\]
unlet s:comment_leadings
" }}}
" Plugin: QuickRun, Quicklaunch & xUnit {{{
let g:quickrun_config = get(g:, 'quickrun_config', {})
"nnoremap <silent> <Leader>r :<C-u>QuickRun -runner vimproc:90 -split 'rightbelow 50vsp'<CR>
nnoremap <silent> <Leader>r :<C-u>QuickRun -runner vimproc:updatetime=10 -split 'rightbelow 50vsp'<CR>
if has('clientserver')
"if has('clientserver') && !empty(v:servername)
let b:quickrun_config = {
\ 'runner/vimproc' : 90,
\ 'runner/vimproc/updatetime' : 90,
\ }
let g:quickrun_config = {
\ '_' : {
\ 'runner/vimproc' : 90,
\ 'runner/vimproc/updatetime' : 90,
\ 'outputter' : 'buffer',
\ 'splist' : '{"rigitbelow 50vsp"}',
\ },
\ 'run/vimproc' : {
\ 'exec' : '%s:p:r %a',
\ 'runner' : 'vimproc',
\ 'outputter' : 'buffer',
\ },
\ 'ruby' : {
\ 'command' : 'irb',
\ 'cmdopt' : '--simple-prompt',
\ 'runner' : 'process_manager',
\ 'runner/process_manager/load' : "load '%s'",
\ 'runner/process_manager/prompt' : '>> ',
\ },
\ 'ruby.rspec' : {
\ 'command' : "rspec -l {line('.')",
\ },
\ 'php.phpunit' : {
\ 'command' : 'phpunit',
\ },
\ 'phpunit.php' : {
\ 'command' : 'phpunit',
\ },
\ 'javascript' : {
\ 'command' : 'phantomjs',
\ },
\ }
if exists('g:sphinx_build_bin')
let g:quickrun_config['rst'] = {
\ 'command': g:sphinx_build_bin,
\ 'hook/sphinx/enable' : 1,
\ 'cmdopt': '-b html',
\ 'splist' : '{"rigitbelow 65vsp"}',
\ }
endif
endif
if has('mac')
" TODO: Sikuli 起動は引数渡さねば??
"let g:quickrun_config['python.sikuli'] = {
" \ 'command': '/Applications/Sikuli-IDE.app/sikuli-ide.sh',
" \ }
elseif has('win32')
else " Linux
let g:quickrun_config['php.phpunit'] = { 'command' : 'phpunit' }
endif
" TODO: Add QuickRun's syntax for xUnit family
"autocmd BufAdd,BufNew,BufNewFile,BufRead [quickrun output] set syntax=xUnit
" }}}
" Plugin: TweetVim {{{
let g:tweetvim_config_dir = s:tmpdir . '/tweetvim'
let g:tweetvim_include_rts = 1
" }}}
" Plugin: jscomplatete.vim {{{
let g:jscomplete_use = ['dom']
" }}}
" Plugin: dbext.vim {{{
let g:dbext_default_history_file = s:tmpdir . '/dbext_sql_history.sql'
" }}}
" Plugin: Emmet.vim (Replaced from zenconding.vim) {{{
let g:user_emmet_mode = 'a'
let g:user_emmet_leader_key = '<c-y>'
let g:use_emmet_complete_tag = 1
let g:user_emmet_settings = {
\ 'lang' : 'ja',
\ 'html' : {
\ 'filters' : 'html',
\ 'indentation' : ' '
\ },
\ 'perl' : {
\ 'indentation' : ' ',
\ 'aliases' : {
\ 'req' : "require '|'"
\ },
\ 'snippets' : {
\ 'use' : "use strict\nuse warnings\n\n",
\ 'w' : "warn \"${cursor}\";",
\ },
\ },
\ 'php' : {
\ 'extends' : 'html',
\ 'filters' : 'html,c',
\ },
\ 'css' : {
\ 'filters' : 'fc',
\ },
\ 'javascript' : {
\ 'snippets' : {
\ 'jq' : "$(function() {\n\t${cursor}${child}\n});",
\ 'jq:each' : "$.each(arr, function(index, item)\n\t${child}\n});",
\ 'fn' : "(function() {\n\t${cursor}\n})();",
\ 'tm' : "setTimeout(function() {\n\t${cursor}\n}, 100);",
\ },
\ },
\ 'haml': {
\ 'extends': 'html',
\ }
\ }
"}}}
" Plugin: neocomplete {{{
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#max_list = 30
let g:neocomplete#max_keyword_width = 20
let g:neocomplete#auto_completion_start_length = 3
let g:neocomplete#manual_completion_start_length = 3
let g:neocomplete#min_keyword_length = 5
"let g:neocomplete#enable_ignore_case = 'ignorecase'
let g:neocomplete#enable_smart_case = 'infercase'
let g:neocomplete#enable_insert_char_pre = 1 " Really??
let g:neocomplete#enable_auto_select = 1
let g:neocomplete#data_directory = s:tmpdir . '/neocomplete'
let g:neocomplete#use_vimproc = 1
"if !exists('g:neocomplete#same_filetypes')
"let g:neocomplete#same_filetypes = {}
"endif
"let g:neocomplete#same_filetypes.twig = 'twig'
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
"return neocomplete#smart_close_popup() . "\<CR>"
" For no inserting <CR> key.
return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction
" }}}
" Plugin: neosnippet {{{
let g:neosnippet#snippets_directory =
\ s:bundle_dir . 'neocomplcache-snippets-complete/autoload/neocomplcache/sources/snippets_complete'
\ .','. $HOME . '/.vim/snippets'
" TODO: Update phpunit snippet for neosnippet
"\ .','. s:bundle_dir . '/vim-phpunit-snippets/snippets'
"\ .','. s:bundle_dir . '/neocomplcache-phpunit-snippet/autoload/neocomplcache/sources/snippets_complete'
nmap <silent> <C-l> <Plug>(neosnippet_expand_or_jump)
imap <silent> <C-l> <Plug>(neosnippet_expand_or_jump)
smap <silent> <C-l> <Plug>(neosnippet_expand_or_jump)
"imap <silent> <C-s> <Plug>(neocomplcache_start_unite_complete)
imap <silent> <C-s> <Plug>(neosnippet_start_unite_snippet)
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" Onetime :p
nnoremap <Leader>ns :<C-u>NeoSnippetEdit<CR>
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" }}}
" Plugin: vim-rooter {{{
silent! nmap <unique> gh <Plug>RooterChangeToRootDirectory
let g:rooter_manual_only = 1
let g:rooter_use_lcd = 1
let g:rooter_patterns = [
\ '.git/', '.hg/',
\ 'Gemfile', 'Rakefile', 'Guardfile',
\ 'Vagrantfile',
\ 'composer.json',
\ 'build.xml',
\ 'build.gradle',
\ ]
let g:rooter_change_directory_for_non_project_files = 0
" }}}
" Plugin: vim-vcs {{{
let g:vcs#config_log_file = s:tmpdir . '/vcs'
" }}}
" Plugin: vim-fugitive {{{
" Gstatus
" * Gstatus上の変更のあったファイルにカーソルを合わせた状態で
" Dで:Gdiff起動(差分表示)
" -でstageとunstageの切り替え
" pでパッチを表示
" Enterでファイル表示
" Cでcommit
" * :help Gstatus
nnoremap <Leader>gb :<C-u>Gblame<CR>
nnoremap <Leader>gd :<C-u>Gdiff<CR>
nnoremap <Leader>gD :<C-u>Gdiff --cached<CR>
nnoremap <Leader>gs :<C-u>Gstatus<CR>
nnoremap <Leader>ga :<C-u>Gwrite<CR>
nnoremap <Leader>gA :<C-u>Gwrite <cfile><CR>
nnoremap <Leader>gc :<C-u>Gcommit<CR>
"}}}
" Plugin: vimfiler {{{
let s:bundle = neobundle#get('vimfiler')
function! s:bundle.hooks.on_source(bundle)
let g:vimfiler_as_default_explorer = 1
let g:vimfiler_split_action = 'left'
"let g:vimfiler_execute_file_list = 'vim'
let g:vimfiler_ignore_pattern = '^.*\%(.git\|.DS_Store\|.idea\|.iml\)$'
let g:vimfiler_edit_action = 'open'
let g:vimfiler_sort_type = 'filename'
let g:vimfiler_time_format = "%y-%m-%d %H:%M"
" Note: This variable works in file source.
"let g:vimfiler_enable_auto_cd = 1
let g:vimfiler_data_directory = s:tmpdir . '/vimfiler'
let g:vimfiler_time_format = "%y-%m-%d %H:%M"
" Enable file operation commands.
"let g:vimfiler_safe_mode_by_default = 0
" Like Textmate icons.
let g:vimfiler_tree_leaf_icon = ' '
let g:vimfiler_tree_opened_icon = '▾'
let g:vimfiler_tree_closed_icon = '▸'
let g:vimfiler_file_icon = '-'
let g:vimfiler_marked_file_icon = '*'
if has('win32')
let g:unite_kind_file_use_trashbox = s:tmpdir . '/vimfiler_trashbox'
endif
"augroup StartupWithVimFiler " {{{
" autocmd!
" autocmd VimEnter * VimFiler
" \ -buffer-name=explorer -split -simple -winwidth=40 -toggle -no-quit
" \ -auto-cd=1
"augroup END " }}}
endfunction
nnoremap : :<C-u>VimFilerSplit -winwidth=45<CR>
augroup VimFilerUniteAction " {{{
autocmd!
autocmd FileType vimfiler call unite#custom_default_action('directory', 'lcd')
augroup END " }}}
" }}}
" Plugin: vimshell {{{
"let s:bundle = neobundle#get('vimshell')
"function! s:bundle.hooks.on_source(bundle)
let g:vimshell_temporary_directory = s:tmpdir . '/.vimshell'
"let g:vimshell_right_prompt = 'vcs#info("(%s)-[%b]", \\"(%s)-[%b|%a]")'
let g:vimshell_enable_smart_case = 1
let g:vimshell_enable_auto_slash = 1
let g:vimshell_max_command_history = 200
let g:vimshell_max_list = 15
let g:vimshell_split_height = 22
let g:vimshell_split_command = 'split'
" almost paste from vimshll-examples
" Initialize execute file list.
let g:vimshell_execute_file_list = {}
"call vimshell#set_execute_file('txt,vim,c,h,cpp,d,xml,java', 'vim')
let g:vimshell_execute_file_list['rb'] = 'ruby'
let g:vimshell_execute_file_list['pl'] = 'perl'
let g:vimshell_execute_file_list['py'] = 'python'
let g:vimshell_execute_file_list['php'] = 'php'
let g:vimshell_execute_file_list['git'] = 'git'
"call vimshell#set_execute_file('html,xhtml', 'gexe firefox')
"let g:vimshell_user_prompt = 'fnamemodify(getcwd(), \\":~")'
"let g:vimshell_right_prompt = 'vcs#info("(%s)-[%b]", \\"(%s)-[%b|%a]")'
let g:my_host_prompt = stridx(hostname(), '.') > 0
\ ? hostname()[ : stridx(hostname(), '.') - 1]
\ : hostname()
if has('win32') || has('win64')
" Display user name on Windows.
"let g:vimshell_prompt = $USERNAME." % "
let g:vimshell_user_prompt = printf(
\ '"%s\n┌[" .$USERNAME."@".%s. "]" ." - ". "[" .%s. "]"'
\ , '"☁ ". fnamemodify(getcwd(), ":p:h")'
\ , 'g:my_host_prompt'
\ , 'fnamemodify(getcwd(), ":~")'
\ )
else
" Display user name on Linux.
" TODO: $USER . hostname() の省略系を表示できるようにする
let g:vimshell_user_prompt = printf(
\ '"┌[" .$USER."@".%s. "]" ." - ". "[" .%s. "]"'
\ , 'g:my_host_prompt'
\ , 'fnamemodify(getcwd(), ":~")'
\ )
"call vimshell#set_execute_file('bmp,jpg,png,gif', 'gexe eog')
call vimshell#set_execute_file('mp3,m4a,ogg', 'gexe amarok')
let g:vimshell_execute_file_list['zip'] = 'zipinfo'
call vimshell#set_execute_file('tgz,gz', 'gzcat')
call vimshell#set_execute_file('tbz,bz2', 'bzcat')
endif
let g:vimshell_prompt = '└[☁ ] '
"let g:vimshell_right_prompt = 'fnamemodify(getcwd(), ":p:h")'
augroup VimshellFileTypeDetect
autocmd!
autocmd FileType vimshell
\ call vimshell#altercmd#define('g', 'git')
\| call vimshell#altercmd#define('h', 'hg')
\| call vimshell#altercmd#define('i', 'iexe')
\| call vimshell#altercmd#define('l', 'll')
\| call vimshell#altercmd#define('a', 'ls -al')
\| call vimshell#altercmd#define('ll', 'ls -l')
\| call vimshell#altercmd#define('la', 'ls -al')
\| call vimshell#altercmd#define('cl', 'clear')
\| call vimshell#hook#add('chpwd', 'my_chpwd', 'g:my_chpwd')
augroup END
function! g:my_chpwd(args, context)
call vimshell#execute('ls')
endfunction
"endfunction
" }}}
" Plugin: unite.vim {{{
let g:unite_data_directory =
\ get(g:, 'local_unite_data_directory', s:tmpdir . '/unite')
let g:unite_enable_start_insert = 1
" Save session automatically.
" For unite-session.
" Load session automatically.
let g:unite_source_session_enable_auto_save = 1
"autocmd VimEnter * UniteSessionLoad
" window options
let g:unite_winheight = 12
let g:unite_split_rule = 'below'
let g:unite_source_file_mru_limit = 120
let g:unite_update_time = 256
" mru options
let g:unite_source_file_mru_filename_format = ''
let g:unite_source_file_mru_limit = 200
" history options
let g:unite_source_history_yank_enable = 1
let g:unite_source_history_yank_limit = 100
" color options
let g:unite_cursor_line_highlight = 'PmenuSel'
"let g:unite_abbr_highlight = 'TabLine'
" aliases
let g:unite_source_alias_aliases = get(g:, 'unite_source_alias_aliases', {})