/
.vimrc
1599 lines (1321 loc) · 49.4 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
scriptencoding utf-8
filetype off
filetype plugin indent off
" autocmdのリセット
autocmd!
set number " 行番号を表示する
set cursorline " カーソル行の背景色を変える
" カーソルの設定
" ref: https://stackoverflow.com/a/42118416
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
augroup set_cursorline
autocmd!
autocmd InsertLeave * set cursorline
autocmd InsertEnter * set nocursorline
" reset the cursor on start (for older versions of vim, usually not required)
autocmd VimEnter * silent !echo -ne "\e[2 q"
augroup END
set laststatus=2 " ステータス行を常に表示
set cmdheight=1 " メッセージ表示欄を2行確保
set showmatch " 対応する括弧を強調表示
set matchpairs+=「:」,『:』,(:),【:】,《:》,〈:〉,[:],‘:’,“:”,`:`
set helpheight=998 " ヘルプを画面いっぱいに開く
" set synmaxcol=300 " 長い行の場合、syntaxをoffにする 既定では3000
set list " 不可視文字を表示
set listchars=tab:▸\ ,nbsp:%,trail:_ " 不可視文字の表示記号指定
set t_Co=256 "ターミナルで256色利用
set iskeyword+=?,!,-,@-@ "?,!,@hogeなどをキーワードとする
" " Don't screw up folds when inserting text that might affect them, until
" " leaving insert mode. Foldmethod is local to the window. Protect against
" " screwing up folding when switching between windows.
" augroup switch_folding_method
" autocmd!
" autocmd InsertEnter *
" \ if !exists('w:last_fdm') |
" \ let w:last_fdm=&foldmethod |
" \ setlocal foldmethod=manual |
" \ endif
" autocmd InsertLeave,WinLeave *
" \ if exists('w:last_fdm') |
" \ let &l:foldmethod=w:last_fdm |
" \ unlet w:last_fdm |
" \ endif
" augroup END
set nofoldenable " disable folding
augroup vimrc-highlight
autocmd!
autocmd Syntax off if 10000 > line('$') | syntax sync minlines=1000 | endif
augroup END
" Charset, Line ending -----------------
set fileformats=unix,dos,mac " LF, CRLF, CR
" set ambiwidth=double " UTF-8の□や○でカーソル位置がずれないようにする
" function! s:detect_terminal()
" if &buftype ==# 'terminal' && &filetype ==# ''
" set filetype=terminal
" endif
" endfunction
"
" function! s:set_terminal_option()
" " ここに :terminal のバッファ固有の設定を記述する
" set ambiwidth=single " ズレが発生するので元に戻す
" endfunction
"
" function! s:unset_terminal_option()
" " ここに :terminalから戻った時に設定を戻す
" set ambiwidth=double " UTF-8の□や○でカーソル位置がずれないようにする
" endfunction
"
"
" augroup toggle_terminal_option
" autocmd!
" " BufNew の時点では 'buftype' が設定されていないので timer イベントでごまかすなど…
" autocmd BufNew * call timer_start(0, { -> s:detect_terminal() })
" autocmd BufWinEnter,FileType * call s:unset_terminal_option()
" autocmd BufWinEnter,FileType terminal call s:set_terminal_option()
" augroup END
" set nospell
" カーソル移動系
set backspace=indent,eol,start " Backspaceキーの影響範囲に制限を設けない
set whichwrap=b,s,h,l,<,>,[,] " 行頭行末の左右移動で行をまたぐ
set scrolloff=8 " 上下8行の視界を確保
set sidescrolloff=16 " 左右スクロール時の視界を確保
set sidescroll=1 " 左右スクロールは一文字づつ行う
set lazyredraw " 描画を遅延させる
set ttyfast " カーソル移動高速化
augroup restore_cursor_position
autocmd!
autocmd BufReadPost * " 最後のカーソル位置を復元する
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
augroup END
"File処理関連
set confirm " 保存されていないファイルがあるときは終了前に保存確認
set hidden " 保存されていないファイルがあるときでも別のファイルを開くことが出来る
set nobackup " ファイル保存時にバックアップファイルを作らない
set noswapfile " ファイル編集中にスワップファイルを作らない
set autoread " 外部でファイルに変更がされた場合は読みなおす
augroup vimrc-checktime "window移動/一定時間カーソルが停止した場合に強制的に読みなおす
autocmd!
set updatetime=1000
" autocmd WinEnter,CursorHold * if mode() !=# "c" | checktime | endif " command line はmode()でnを返してしまう
autocmd WinEnter,CursorHold * if !bufexists("[Command Line]") && !bufexists("[コマンドライン]") | checktime | endif
augroup END
"検索関連
set hlsearch " 検索文字列をハイライトする
set incsearch " インクリメンタルサーチを行う
set ignorecase " 大文字と小文字を区別しない
set smartcase " 大文字と小文字が混在した言葉で検索を行った場合に限り、大文字と小文字を区別する
set wrapscan " 最後尾まで検索を終えたら次の検索で先頭に移る
set gdefault " 置換の時 g オプションをデフォルトで有効にする
"選択済テキストで検索
vnoremap // y/<C-R>"<CR>
" 検索後にジャンプした際に検索単語を画面中央に持ってくる
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
" vを二回で行末まで選択
vnoremap v $h
"ビープの設定
"ビープ音すべてを無効にする
set visualbell t_vb=
set noerrorbells "エラーメッセージの表示時にビープを鳴らさない
"コマンドライン設定
" コマンドラインモードでTABキーによるファイル名補完を有効にする
set wildmenu wildmode=list:longest,full
" コマンドラインの履歴を1000件保存する
set history=1000
"履歴に保存する各種設定
set viminfo='100,/50,%,<1000,f50,s100,:100,c,h,!
set viminfo+=n~/.viminfo
" 動作環境との統合
" OSのクリップボードをレジスタ指定無しで Yank, Put 出来るようにする
set clipboard=unnamed,unnamedplus
" インサートモードから抜けると自動的にIMEをオフにする
set iminsert=0
set imsearch=-1
" ESC ESC でハイライトを消す
" nnoremap <silent> <ESC><ESC> :nohlsearch<CR>
nnoremap <silent> <ESC><ESC> :call ClearHighlight()<CR>
"
function! ClearHighlight() abort
call feedkeys(":nohlsearch\<CR>", "n") " searchのハイライトをオフにする
call popup_clear() "ポップアップのクリア
endfunction
" quickhlのハイライトをオフにする
nnoremap <silent> <ESC><ESC><ESC> :call ClearQuickhl()<CR>
function! ClearQuickhl() abort
call quickhl#manual#reset() " quickhlのハイライトをオフにする
call feedkeys(":nohlsearch\<CR>", "n") " searchのハイライトをオフにする
call popup_clear() "ポップアップのクリア
endfunction
" w!! でスーパーユーザーとして保存(sudoが使える環境限定)
cmap w!! w !sudo tee > /dev/null %
"tab/indentの設定
set shellslash
set expandtab " タブ入力を複数の空白入力に置き換える
set tabstop=2 " 画面上でタブ文字が占める幅
set shiftwidth=2 " 自動インデントでずれる幅
set softtabstop=2 " 連続した空白に対してタブキーやバックスペースキーでカーソルが動く幅
set autoindent " 改行時に前の行のインデントを継続する
set smartindent " 改行時に入力された行の末尾に合わせて次の行のインデントを増減する
set indentkeys=!^F,o,O,0<Bar>,0=where " 自動インデントを発動させるタイミングを設定する
" signの幅を予め確保しておく
set signcolumn=yes
" 新しいウィンドウを下に開く
set splitbelow
" 新しいウィンドウを右に開く
set splitright
" 日本語ヘルプを利用する
set helplang=ja,en
".vimrcの編集用
nnoremap <Space>. :<C-u>tabedit $HOME/dotfiles/.vimrc<CR>
nnoremap R :<C-u>source $HOME/.vimrc<CR>
" q: のタイポ抑制
nnoremap q: :q
" 英字キーボードのタイプミス対策
nnoremap ; :
vnoremap ; :
" remap record macro key from q to Q
nnoremap Q q
nnoremap q <Nop>
" マウスのミドルクリックによる貼付けをやめる
map <MiddleMouse> <Nop>
map <2-MiddleMouse> <Nop>
map <3-MiddleMouse> <Nop>
map <4-MiddleMouse> <Nop>
imap <MiddleMouse> <Nop>
imap <2-MiddleMouse> <Nop>
imap <3-MiddleMouse> <Nop>
imap <4-MiddleMouse> <Nop>
"タブの設定
" Tab jump
for n in range(1, 9)
execute 'nnoremap <silent> g'.n ':<C-u>tabnext'.n.'<CR>'
endfor
" tc 新しいタブを右に作る
nnoremap <silent> gc :tabnew<CR>
" tn 新しいタブを一番右に作る
" nnoremap <silent> gn :tablast <bar> tabnew<CR>
" " tx タブを閉じる
nnoremap <silent> gq :tabclose<CR>
nnoremap <silent> gx :tabclose<CR>
nnoremap <silent> gp :tabprevious<CR>
nnoremap <silent> gn :tabnext<CR>
" terminal mode
" " ノーマルモード(コピーできるようにする)
tnoremap <C-w>[ <C-w>N
augroup add_syntax_highlight
autocmd!
"シンタックスハイライトの追加
autocmd BufNewFile,BufRead *.json.jbuilder set filetype=ruby
autocmd BufNewFile,BufRead Gemfile* set filetype=ruby
autocmd BufNewFile,BufRead *.thor set filetype=ruby
autocmd BufNewFile,BufRead *.erb set filetype=eruby
autocmd BufNewFile,BufRead *.slim set filetype=slim
autocmd BufNewFile,BufRead *json.jb set filetype=ruby
" autocmd BufNewFile,BufRead *.scss set filetype=scss.css
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
autocmd BufNewFile,BufRead *.{md,mdwn,mkd,mkdn,mark*} set filetype=markdown
autocmd BufNewFile,BufRead *.vtl set filetype=velocity
autocmd BufRead,BufNewFile *.ts set filetype=typescript
augroup END
" set re=1
set runtimepath+=~/.vim/ftplugin/
" let g:ruby_path = system('echo $HOME/.rbenv/shims')
" 不要なデフォルトプラグインの停止
let g:loaded_gzip = 1
let g:loaded_tar = 1
let g:loaded_tarPlugin = 1
let g:loaded_zip = 1
let g:loaded_zipPlugin = 1
let g:loaded_rrhelper = 1
let g:loaded_2html_plugin = 1
let g:loaded_vimball = 1
let g:loaded_vimballPlugin = 1
let g:loaded_getscript = 1
let g:loaded_getscriptPlugin = 1
" let g:loaded_netrw = 1
" let g:loaded_netrwPlugin = 1
" let g:loaded_netrwSettings = 1
" let g:loaded_netrwFileHandlers = 1
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'tyru/open-browser.vim'
Plug 'itchyny/lightline.vim'
Plug 'AndrewRadev/switch.vim', {'on': ['Switch', 'SwitchReverse']}
Plug 'kana/vim-submode'
Plug 'tyru/caw.vim'
Plug 'osyo-manga/vim-over', { 'on': ['OverCommandLineNoremap', 'OverCommandLineMap', 'OverCommandLine', 'OverCommandLineUnmap']}
" 辞書系
Plug 'thinca/vim-ref', { 'on': ['Ref', 'RefHistory'] }
Plug 'mfumi/ref-dicts-en'
Plug 'tyru/vim-altercmd'
Plug 'ujihisa/neco-look'
" カーソル下をハイライト
Plug 'osyo-manga/vim-brightest'
Plug 't9md/vim-quickhl'
" 括弧補完
" Plug 'cohama/lexima.vim'
" 補完系
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
" Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
" Plug '~/.ghq/github.com/prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'prabirshrestha/asyncomplete-neosnippet.vim'
Plug 'thomasfaingnaert/vim-lsp-snippets'
Plug 'thomasfaingnaert/vim-lsp-neosnippet'
" Plug 'yami-beta/asyncomplete-omni.vim'
" Plug 'Shougo/neco-syntax'
" Plug 'prabirshrestha/asyncomplete-necosyntax.vim'
Plug 'htlsne/asyncomplete-look'
" Plug 'kitagry/asyncomplete-tabnine.vim', { 'do': './install.sh' }
Plug 'github/copilot.vim'
" deno
Plug 'vim-denops/denops.vim'
" Plug 'yuki-yano/fuzzy-motion.vim'
" Plug 'yuki-yano/denops-open-http.vim'
" Plug 'skanehira/denops-silicon.vim'
" Plug 'skanehira/denops-gh.vim'
Plug 'prettier/vim-prettier', {
\ 'do': 'yarn install',
\ 'branch': 'release/1.x',
\ 'for': [
\ 'javascript',
\ 'typescript',
\ 'css',
\ 'less',
\ 'scss',
\ 'json',
\ 'graphql',
\ 'markdown',
\ 'vue',
\ 'lua',
\ 'php',
\ 'python',
\ 'ruby',
\ 'html',
\ 'swift' ] }
" %で閉じタグに飛ぶ
Plug 'tmhedberg/matchit'
Plug 'thinca/vim-quickrun'
" quickfixのエラーメッセージを下部に表示する
Plug 'dannyob/quickfixstatus', {'on': ['QuickfixStatusDisable', 'QuickfixStatusEnable']}
Plug 'anyakichi/vim-qfutil'
" " " 非同期処理でLinterを動かす
" Plug 'w0rp/ale'
"
" " " aleの結果をlightlineに出力
" Plug 'maximbaz/lightline-ale'
" 非同期バッチをTmuxやTerminalに渡して処理出来る
" Plug 'tpope/vim-dispatch', {'on': ['Dispatch', 'FocusDispatch','Spawn', 'Start', 'Copen']}
" テストランナー
Plug 'janko-m/vim-test'
Plug 'jonleighton/vim-test-vimterminal-enhanced'
" インデントの可視化
Plug 'nathanaelkane/vim-indent-guides', {'on': ['IndentGuidesEnable', 'IndentGuidesToggle', 'IndentGuidesDisable', ]}
" " p/Pで貼り付け先のインデントに合わせる
" Plug 'deris/vim-pasta'
" Git/SVNの差分箇所をマークで表示
Plug 'mhinz/vim-signify'
" Git diff用
Plug 'tpope/vim-fugitive', {'on': ['Gdiff']}
" 自動整形プラグイン
Plug 'Chiel92/vim-autoformat'
" PJ毎の稼働時間を記録
Plug 'wakatime/vim-wakatime'
" 自動保存
" Plug 'vim-scripts/vim-auto-save'
Plug '907th/vim-auto-save'
" " 再帰的なfジャンプ
" Plug 'rhysd/clever-f.vim'
" Surround
Plug 'kana/vim-textobj-user'
Plug 'rhysd/vim-textobj-anyblock'
Plug 'kana/vim-textobj-line'
Plug 'fvictorio/vim-textobj-backticks'
Plug 'kana/vim-operator-user'
Plug 'rhysd/vim-operator-surround'
Plug 'tyru/operator-camelize.vim'
Plug 'aymericbeaumet/vim-symlink' | Plug 'moll/vim-bbye' " optional dependency
" Rename
Plug 'qpkorr/vim-renamer', { 'on': 'Renamer'}
" editorconfig
Plug 'editorconfig/editorconfig-vim', { 'on': ['EditorConfigReload']}
" cd project-root
Plug 'airblade/vim-rooter'
" grammar checker
Plug 'rhysd/vim-grammarous'
""Markdown
" syntax
Plug 'rcmdnk/vim-markdown', { 'for': ['markdown'] } | Plug 'godlygeek/tabular' | Plug 'joker1007/vim-markdown-quote-syntax'
" 日本語の句読点をTextObjectの区切りと扱う
Plug 'deton/jasentence.vim', { 'for': ['markdown'] }
" マークダウンをブラウザ上でHTMLレンダリング
Plug 'rhysd/vim-gfm-syntax', { 'for': 'markdown' }
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'plantuml', 'vim-plug']}
Plug 'mattn/vim-maketable' ", { 'for': 'markdown' }
"" Rails
" 規約ベースのコードジャンプ、b:rails_rootを定義
Plug 'tpope/vim-rails' ", { 'for': ['ruby'] }
" slimのsyntax highlight
Plug 'slim-template/vim-slim', { 'for': ['slim'] }
" heredocのハイライト
Plug 'joker1007/vim-ruby-heredoc-syntax', { 'for': ['ruby'] }
"" Golang
Plug 'benmills/vimux' | Plug 'sebdah/vim-delve', { 'for': ['go'] }
" Plug 'mattn/vim-goimports', { 'for': ['go'] }
" Plug 'mattn/vim-gotmpl', { 'for': ['go'] }
Plug 'mattn/vim-gomod', { 'for': ['go'] }
"" python
Plug 'Glench/Vim-Jinja2-Syntax'
"" perl
Plug 'hotchpotch/perldoc-vim', { 'for': ['perl'] }
Plug 'vim-perl/vim-perl', { 'for': ['perl'] }
" php
Plug 'vim-scripts/php.vim-html-enhanced', { 'for': ['php'] }
" html
Plug 'othree/html5.vim', {'for':['html']}
"" javascript
Plug 'elzr/vim-json', {'for':['json']}
Plug 'othree/yajs.vim', {'for':['javascript', 'html']}
Plug 'pangloss/vim-javascript'
Plug 'MaxMEllon/vim-jsx-pretty'
"" typescript
Plug 'leafgarland/typescript-vim', {'for':['typescript', 'tsx']}
" Plug 'Quramy/tsuquyomi', {'for':['typescript', 'tsx']}
Plug 'ianks/vim-tsx', {'for':['typescript', 'tsx']}
" graphql
Plug 'jparise/vim-graphql', {'for':['javascript', 'html', 'graphql']}
" vtl
Plug 'lepture/vim-velocity', { 'for':['velocity', 'vtl'] }
" toml
Plug 'cespare/vim-toml', { 'for': ['toml'] }
" PlantUML
Plug 'aklt/plantuml-syntax', { 'for': ['plantuml'] }
" css
" Plug 'lilydjwg/colorizer'
" Plug 'JulesWang/css.vim', {'for':['scss', 'css']}
" Plug 'hail2u/vim-css3-syntax', {'for':['scss', 'css']}
" Plug 'csscomb/vim-csscomb', {'for':['scss', 'css']}
" Plug 'cakebaker/scss-syntax.vim', {'for':['scss']}
" log
Plug 'powerman/vim-plugin-AnsiEsc'
" colorscheme
Plug 'habamax/vim-habamax'
Plug 'w0ng/vim-hybrid'
Plug 'morhetz/gruvbox'
Plug 'kristijanhusak/vim-hybrid-material'
Plug 'miyakogi/seiya.vim'
" help
Plug 'vim-jp/vimdoc-ja'
Plug 'KabbAmine/zeavim.vim'
" readline lik keybindings
Plug 'tpope/vim-rsi'
"create vim plugin's skeleton
Plug 'mopp/layoutplugin.vim', { 'on' : 'LayoutPlugin'}
"unite like serching interface
Plug 'junegunn/fzf'
Plug 'pbogut/fzf-mru.vim'
"solidity
Plug 'tomlion/vim-solidity'
" nginx
Plug 'chr4/nginx.vim'
" ansible
Plug 'pearofducks/ansible-vim', { 'do': 'cd ./UltiSnips; ./generate.py' }
" terraform
Plug 'hashivim/vim-terraform'
Plug 'direnv/direnv.vim'
" protobuf
Plug 'uarun/vim-protobuf'
Plug 'rbtnn/vim-ambiwidth'
Plug 'vim-skk/skkeleton'
" ローカル管理のPlugin
Plug '~/.ghq/github.com/iberianpig/tig-explorer.vim' | Plug 'rbgrouleff/bclose.vim'
Plug '~/.ghq/github.com/iberianpig/ranger-explorer.vim'
Plug '~/.ghq/github.com/iberianpig/ruby_hl_lvar.vim', { 'for' : ['ruby'] }
" Initialize plugin system
call plug#end()
" Required:
filetype plugin indent on
syntax on
" ...
" 読み込んだプラグインの設定
" ...
" " set background=light "明るめの背景
set background=dark "暗めの背景
"
" " colorschme
"
" " " " hybrid
colorscheme hybrid
let g:seiya_auto_enable=1
" " hybrid-material
let g:hybrid_transparent_background = 1
" colorscheme hybrid_material
" " gruvbox
" colorscheme gruvbox
" カーソル行にアンダーラインを引く(color terminal)
highlight CursorLine cterm=underline ctermfg=NONE ctermbg=NONE
" " エラー箇所の行番号左にSignを表示
" highlight lines in Sy and vimdiff etc.)
highlight DiffAdd cterm=bold ctermbg=none ctermfg=119
highlight DiffDelete cterm=bold ctermbg=none ctermfg=167
highlight DiffChange cterm=bold ctermbg=none ctermfg=227
" " highlight signs in Sy
highlight SignifySignAdd cterm=bold ctermbg=235 ctermfg=155
highlight SignifySignDelete cterm=bold ctermbg=235 ctermfg=196
highlight SignifySignChange cterm=bold ctermbg=235 ctermfg=111
let g:signify_sign_add = '+'
let g:signify_sign_delete = '_'
let g:signify_sign_delete_first_line = '-'
let g:signify_sign_change = '!'
let g:signify_sign_change_delete = g:signify_sign_change . g:signify_sign_delete_first_line
" lightline {{{
" available colorscheme:
" wombat, solarized, powerline, jellybeans, Tomorrow,
" Tomorrow_Night, Tomorrow_Night_Blue, Tomorrow_Night_Eighties,
" PaperColor, seoul256, landscape and 16color
let g:lightline = {
\ 'colorscheme': 'Tomorrow_Night',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], [ 'ctrlpmark'], [ 'currentfunction' ] ],
\ 'right': [[ 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ], ['lsp_errors', 'lsp_warnings', 'lsp_ok'], ['linter_checking', 'linter_errors', 'linter_warnings', 'linter_ok' ]]
\ },
\ 'inactive': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], ['ctrlpmark'] ],
\ 'right': [ [ 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'filename': 'MyFilename',
\ 'fileformat': 'MyFileformat',
\ 'filetype': 'MyFiletype',
\ 'fileencoding': 'MyFileencoding',
\ 'mode': 'MyMode',
\ 'currentworkingdir': 'CurrentWorkingDir',
\ 'percent': 'MyPercent',
\ 'lineinfo': 'MyLineInfo',
\ },
\ 'component_expand': {
\ 'linter_checking': 'lightline#ale#checking',
\ 'linter_warnings': 'lightline#ale#warnings',
\ 'linter_errors': 'lightline#ale#errors',
\ 'linter_ok': 'lightline#ale#ok',
\ 'lsp_warnings': 'LightlineLSPWarnings',
\ 'lsp_errors': 'LightlineLSPErrors',
\ 'lsp_ok': 'LightlineLSPOk',
\ },
\ 'component_type': {
\ 'linter_checking': 'left',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error',
\ 'linter_ok': 'left',
\ 'lsp_warnings': 'warning',
\ 'lsp_errors': 'error',
\ 'lsp_ok': 'middle',
\ },
\ 'tabline': {
\ 'left': [ [ 'tabs' ] ],
\ 'right': [ [ 'currentworkingdir' ] ],
\ },
\}
function! MyModified()
return &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! MyPercent()
return (100 * line('.') / line('$')) . '%'
endfunction
function! MyLineInfo()
return printf('%3d:%-2d', line('.'), col('.'))
endfunction
function! MyReadonly()
return &readonly ? 'RO' : ''
endfunction
function! MyFilename()
let fname = expand('%:t')
return fname ==# 'ControlP' ? g:lightline.ctrlp_item :
\ fname ==# '__Tagbar__' ? g:lightline.fname :
\ fname =~? '__Gundo\|NERD_tree' ? '' :
\ &filetype ==# 'vimfiler' ? vimfiler#get_status_string() :
\ &filetype ==# 'unite' ? unite#get_status_string() :
\ &filetype ==# 'vimshell' ? vimshell#get_status_string() :
\ ('' !=# MyReadonly() ? MyReadonly() . ' ' : '') .
\ ('' !=# fname ? MyStatusPath() . '/' . fname : '[No Name]') .
\ ('' !=# MyModified() ? ' ' . MyModified() : '')
endfunction
function! MyStatusPath()
if exists('b:my_status_path')
return b:my_status_path
endif
let path = expand('%:p:h')
let gpath = finddir('.git', path . ';.;')
if gpath ==# ''
let gpath = findfile('Rakefile', path . ';')
endif
if gpath ==# ''
let b:my_status_path = fnamemodify(path, ':~:h')
return b:my_status_path
endif
if gpath ==# '.git' || gpath ==# 'Rakefile'
let b:my_status_path = fnamemodify(path, ':t')
else
let gpath = fnamemodify(gpath, ':h:h') . '/'
let b:my_status_path = substitute(path, gpath, '', '')
endif
return b:my_status_path
endfunction
function! MyFileformat()
return winwidth(0) > 70 ? (&fileformat) : ''
endfunction
function! MyFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! MyFileencoding()
return winwidth(0) > 70 ? (strlen(&fileencoding) ? &fileencoding : &encoding) : ''
endfunction
function! MyMode()
return winwidth(0) > 70 ? lightline#mode() : ''
endfunction
function! CurrentWorkingDir()
return fnamemodify(getcwd(),':')
endfunction
"}}}
" enable ruby & rails snippet only rails file
function! s:RailsSnippet()
if exists('b:rails_root') && (&filetype ==# 'ruby')
:NeoSnippetSource ~/.vim/snippets/rails.snip
endif
endfunction
function! s:RSpecSnippet()
if (expand('%') =~# '_spec\.rb$') || (expand('%') =~# '^spec.*\.rb$')
:NeoSnippetSource ~/.vim/snippets/rspec.snip
endif
endfunction
function! s:MinitestSnippet()
if (expand('%') =~# '_test\.rb$') || (expand('%') =~# '^test.*\.rb$')
:NeoSnippetSource ~/.vim/snippets/minitest.snip
endif
endfunction
augroup rails_snippet
autocmd!
au BufEnter * call s:RailsSnippet()
au BufEnter * call s:RSpecSnippet()
au BufEnter * call s:MinitestSnippet()
augroup END
" vim-rails
" let g:rails_projections = {
" \ "app/uploaders/*_uploader.rb": {
" \ "command": "uploader",
" \ "template":
" \ ["class {camelcase|capitalize|colons}Uploader < "
" \ . "CarrierWave::Uploader::Base", "end"],
" \ "test": [
" \ "test/unit/{}_uploader_test.rb",
" \ "spec/models/{}_uploader_spec.rb"
" \ ],
" \ "rubyMacro": ["process", "version"]
" \ },
" \ "features/support/*.rb": {"command": "support"},
" \ "features/support/env.rb": {"command": "support"}}
let g:rails_projections = {
\ "app/controllers/*_controller.rb": {
\ "affinity": "controller",
\ "template": [
\ "class {camelcase|capitalize|colons}Controller < ApplicationController",
\ "end"
\ ],
\ "type": "controller",
\ "test": [
\ "spec/controllers/{}_controller_spec.rb",
\ "spec/requests/{}_spec.rb"
\ ],
\ "alternate": [
\ "spec/requests/{}_spec.rb",
\ "spec/controllers/{}_controller_spec.rb",
\ ],
\ },
\ "spec/requests/*_spec.rb": {
\ "affinity": "controller",
\ "alternate": [
\ "app/controllers/{}_controller.rb",
\ ],
\ "controller": [
\ "app/controllers/{}_controller.rb",
\ ],
\ },
\ "app/services/*.rb": {
\ "affinity": "service",
\ "template": [
\ "class {camelcase|capitalize|colons}",
\ "end"
\ ],
\ "type": "services",
\ "test": [
\ "spec/services/{}_spec.rb",
\ ],
\ "alternate": [
\ "spec/services/{}_spec.rb",
\ ],
\ },
\}
"" switch
nnoremap - :Switch<cr>
"" submode.vim
" http://d.hatena.ne.jp/thinca/20130131/1359567419
" ウィンドウサイズの変更キーを簡易化する
" [C-w],[+]または、[C-w],[-]
call submode#enter_with('winsize', 'n', '', '<C-w>L', '<C-w>>')
call submode#enter_with('winsize', 'n', '', '<C-w>H', '<C-w><')
call submode#enter_with('winsize', 'n', '', '<C-w>J', '<C-w>-')
call submode#enter_with('winsize', 'n', '', '<C-w>K', '<C-w>+')
call submode#map('winsize', 'n', '', 'L', '<C-w>>')
call submode#map('winsize', 'n', '', 'H', '<C-w><')
call submode#map('winsize', 'n', '', 'J', '<C-w>-')
call submode#map('winsize', 'n', '', 'K', '<C-w>+')
"" over.vim
" over.vimの起動
nnoremap <silent> <C-s> :OverCommandLine<CR>%s;<C-r><C-w>;;<Left><C-r><C-w>
vnoremap <silent> <C-s> y:OverCommandLine<CR>%s;<C-r>";;<Left><C-r>"
vnoremap <silent> :s :OverCommandLine<CR>s;;<Left>
" カーソル下の単語をハイライト付きで置換
nnoremap s :OverCommandLine<CR>%s;<C-r><C-w>;;<Left>
" コピーした文字列をハイライト付きで置換
vnoremap s y:OverCommandLine<CR>%s;<C-r>=substitute(@0, ';', ';', 'g')<CR>//<Left>
" <C-v> 時に特殊文字を挿入
OverCommandLineMap <C-v> <C-q>
" fzf
" quickfixに流す
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
copen
cc
endfunction
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-o': 'edit',
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit' }
let g:fzf_layout = { 'down': '~25%' }
"" fzf-filemru
let g:fzf_filemru_bufwrite=1
nnoremap [fzf] <Nop>
nnoremap <Space> [fzf]
nmap <Space> [fzf]
vnoremap <Space> <Nop>
vmap <Space> [fzf]
" スペースキーとaキーでカレントディレクトリを表示
" nnoremap <expr> <silent> [fzf]a ":Files<CR>".expand('%:h')
" スペースキーとmキーでプロジェクト内で最近開いたファイル一覧を表示
let g:fzf_mru_relative = 1
nnoremap <silent> [fzf]m :FZFMru<cr>
nnoremap <silent> [fzf]M :History<cr>
nnoremap <silent> [fzf]<CR> :GitFiles<CR>
" "スペースキーとbキーでバッファを表示
" nnoremap <silent> [fzf]b :Buffers<CR>
nnoremap <silent> [fzf]b :Buffers<cr>
nnoremap <silent> [fzf]h :<C-u>Helptags<CR>
nnoremap <silent> [fzf]r :call fzf#run(fzf#wrap({'source': 'ghq list --full-path', 'sink': 'edit' }))<CR>
" カーソル下のパスを開く"
nnoremap <silent> [fzf] gF
" コマンドを検索
nnoremap <silent> [fzf]: :<C-u>Commands<CR>
nnoremap <silent> [fzf]; :<C-u>Commands<CR>
" markdownの設定
" see /usr/share/vim/vim80/syntax/*.vim
let g:markdown_fenced_languages = ['ruby', 'json', 'vim', 'sh', 'javascript']
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_conceal = 0
" markdown-preview
let g:mkdp_filetypes = ['markdown', 'plantuml']
augroup LeaderR
autocmd!
autocmd BufEnter * call s:loadLeaderRMapping()
augroup END
" Switch QuickRun / MarkdownPreview
function! s:loadLeaderRMapping()
if index(g:mkdp_filetypes, &ft) < 0
nnoremap <Leader>r :QuickRun<CR>
vnoremap <Leader>r :QuickRun<CR>
else
nnoremap <Leader>r :MarkdownPreview<CR>
endif
endfunction
" quickrun
" let ruby_bundle_hook = {'kind': 'hook', 'name': 'ruby_bundle'}
" function ruby_bundle_hook.on_normalized(session, context) abort
" if getcwd() !=# $HOME && isdirectory('.bundle')
" let a:session.config.exec =
" \ map(copy(a:session.config.exec), 's:bundle_exec(v:val)')
" endif
" endfunction
" function s:bundle_exec(cmd) abort
" return substitute(a:cmd, '\ze%c', 'bundle exec ', '')
" endfunction
" call quickrun#module#register(ruby_bundle_hook, 1)
augroup quickrun
autocmd!
autocmd FileType quickrun AnsiEsc
augroup END
let g:quickrun_config = get(g:, 'quickrun_config', {})
let g:quickrun_config._ = {
\ 'runner' : 'terminal',
\ 'hook/close_quickfix/enable_hook_loaded' : 1,
\ 'hook/close_quickfix/enable_success' : 1,
\ 'hook/close_buffer/enable_hook_loaded' : 1,
\ 'hook/close_buffer/enable_failure' : 1,
\ 'hook/inu/enable' : 1,
\ 'hook/inu/wait' : 1,
\ 'outputter' : 'multi:buffer:quickfix',
\ 'outputter/buffer/split' : 'botright',
\ 'outputter/quickfix/open_cmd' : 'copen',
\ }
let g:quickrun_config.html = {
\ "command" : "cat",
\ "outputter" : "browser",
\}
" テキストブラウザのインストールが必要
" sudo apt-get install lynx
" 辞書定義
let g:ref_source_webdict_sites = {
\ 'je': {
\ 'url': 'http://eow.alc.co.jp/search?q=%s',
\ },
\ 'ej': {
\ 'url': 'http://eow.alc.co.jp/search?q=%s',
\ },
\ 'alc': {
\ 'url': 'http://eow.alc.co.jp/search?q=%s',
\ },
\ }
" デフォルトサイト
let g:ref_source_webdict_sites.default = 'ej'
" 出力に対するフィルタ
" 最初の数行邪魔なので削除
" function! g:ref_source_webdict_sites.je.filter(output)
" " return join(split(a:output, "\n")[60 :], "\n")