-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
779 lines (714 loc) · 23.6 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
"" Vim Settings
"dein Scripts-----------------------------
if &compatible
set nocompatible " Be iMproved
endif
call plug#begin()
" Plug 'Shougo/deoplete.nvim'
" Plug 'Shougo/denite.nvim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'yuki-yano/fzf-preview.vim', { 'branch': 'release/rpc' }
" Plug 'neoclide/coc.nvim', { 'branch': 'release' }
" Plug 'junegunn/fzf.vim'
" Plug 'antoinemadec/coc-fzf', {'branch': 'release'}
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'lambdalisue/fern.vim'
Plug 'antoinemadec/FixCursorHold.nvim'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'mattn/vim-goimports'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'mattn/emmet-vim'
Plug 'othree/eregex.vim'
Plug 'tyru/open-browser.vim'
" Plug 'tyru/urilib.vim'
Plug 'kchmck/vim-coffee-script'
Plug 'cespare/vim-toml'
Plug 'thinca/vim-localrc'
Plug 'thinca/vim-ref'
Plug 'fuenor/qfixhowm'
Plug 'hail2u/vim-css3-syntax'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'tpope/vim-speeddating'
Plug 'tomtom/tcomment_vim'
Plug 'Lokaltog/vim-easymotion'
Plug 'previm/previm'
Plug 'vim-scripts/surround.vim'
Plug 'vim-scripts/IndentAnything'
Plug 'vim-scripts/grep.vim'
Plug 'vim-scripts/sudo.vim'
Plug 'vim-scripts/renamer.vim'
Plug 'vim-scripts/mru.vim'
Plug 'vim-scripts/xmledit'
Plug 'vim-scripts/matchit.zip'
Plug 'vim-scripts/camelcasemotion'
Plug 'othree/html5.vim'
Plug 'vim-scripts/Better-Javascript-Indentation'
Plug 'vim-scripts/javacomplete'
Plug 'vim-scripts/smartchr'
Plug 'vim-scripts/Source-Explorer-srcexpl.vim'
Plug 'vim-scripts/taglist.vim'
Plug 'vim-scripts/buftabs'
Plug 'vim-scripts/JSON.vim'
Plug 'Townk/vim-autoclose'
Plug 'h1mesuke/vim-alignta'
Plug 'mattn/benchvimrc-vim'
Plug 'nanotech/jellybeans.vim'
Plug 'itchyny/lightline.vim'
Plug 'toyamarinyon/vim-swift'
Plug 'vim-scripts/progressbar-widget'
Plug 'koron/codic-vim'
Plug 'aereal/vim-colors-japanesque'
Plug 'hashivim/vim-terraform'
Plug 'jceb/vim-hier'
Plug 'osyo-manga/vim-watchdogs'
Plug 'glidenote/serverspec-snippets'
Plug 'thinca/vim-quickrun'
Plug 'vim-test/vim-test'
Plug 'osyo-manga/shabadou.vim'
Plug 't9md/vim-textmanip'
Plug 'Shougo/neosnippet'
Plug 'Shougo/neosnippet-snippets'
Plug 'Shougo/vimproc.vim'
" Plug 'Shougo/neobundle.vim'
" Plug 'Shougo/neomru.vim'
Plug 'tpope/vim-fugitive'
Plug 'gregsexton/gitv'
Plug 'rhysd/committia.vim'
Plug 'idanarye/vim-merginal'
Plug 'elixir-editors/vim-elixir'
Plug 'stephpy/vim-yaml'
Plug 'neomake/neomake'
" Plug 'Jagua/vim-denite-ghq'
Plug 'tyru/open-browser-github.vim'
Plug 'ConradIrwin/vim-bracketed-paste'
Plug 'tsandall/vim-rego'
Plug 'editorconfig/editorconfig-vim'
Plug 'thalesmello/lkml.vim'
Plug 'pocke/dicts'
Plug 'Keithbsmiley/rspec.vim'
Plug 'AndrewRadev/switch.vim'
Plug 'mattn/vim-sqlfmt'
Plug 'sebdah/vim-delve'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.4' }
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-telescope/telescope-ui-select.nvim'
call plug#end()
" deoplete.nvim
let g:deoplete#enable_at_startup = 1
let g:coc_node_path = trim(system('which node'))
let g:lsp_log_verbose = 1
let g:lsp_log_file = expand('~/vim-lsp.log')
" for asyncomplete.vim log
let g:asyncomplete_log_file = expand('~/asyncomplete.log')
" fzf
"
set shell=/bin/zsh
let $SHELL = "/bin/zsh"
augroup fzf_preview
autocmd!
autocmd User fzf_preview#rpc#initialized call s:fzf_preview_settings() " fzf_preview#remote#initialized or fzf_preview#coc#initialized
augroup END
function! s:fzf_preview_settings() abort
let g:fzf_preview_fzf_preview_window_option = 'right:50%'
let g:fzf_preview_command = 'bat --color=always --plain {-1}'
endfunction
nnoremap [fzf] <Nop>
nmap <Space>u [fzf]
" vim-lsp
nnoremap <silent> [fzf]b :<C-u>FzfPreviewBuffersRpc<CR>
nnoremap <silent> [fzf]f :<C-u>FzfPreviewProjectFilesRpc<CR>
nnoremap <silent> [fzf]m :<C-u>FzfPreviewProjectMruFilesRpc<CR>
nnoremap <silent> [fzf]ld :<C-u>FzfPreviewVimLspDefinitionRpc<CR>
nnoremap <silent> [fzf]li :<C-u>FzfPreviewVimLspImplementationsRpc<CR>
nnoremap <silent> [fzf]lr :<C-u>FzfPreviewVimLspReferencesRpc<CR>
nnoremap <silent> [fzf]lt :<C-u>FzfPreviewVimLspTypeDefinitionRpc<CR>
nnoremap [fzf]gr :<C-u>FzfPreviewProjectGrepRpc<Space>
xnoremap [fzf]gr "sy:FzfPreviewProjectGrepRpc<Space>-F<Space>"<C-r>=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')<CR>"
" coc
" set tagfunc=CocTagFunc
" nnoremap <silent> [fzf]f :<C-u>CocCommand fzf-preview.ProjectFiles<CR>
" nnoremap <silent> [fzf]m :<C-u>CocCommand fzf-preview.ProjectMruFiles<CR>
" nnoremap <silent> [fzf]ld :<C-u>CocCommand fzf-preview.CocDefinition<CR>
" nnoremap <silent> [fzf]li :<C-u>CocCommand fzf-preview.CocImplementations<CR>
" nnoremap <silent> [fzf]lr :<C-u>CocCommand fzf-preview.CocReferences<CR>
" nnoremap <silent> [fzf]lt :<C-u>CocCommand fzf-preview.CocTypeDefinition<CR>
" nnoremap [fzf]gr :<C-u>CocCommand fzf-preview.ProjectGrep<Space>
" xnoremap [fzf]gr "sy:CocCommand fzf-preview.ProjectGrep<Space>-F<Space>"<C-r>=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')<CR>"
" denite.nvim
"autocmd FileType denite call s:denite_my_settings()
"function! s:denite_my_settings() abort
" nnoremap <silent><buffer><expr> <CR>
" \ denite#do_map('do_action')
" nnoremap <silent><buffer><expr> <TAB>
" \ denite#do_map('do_action', 'tabopen')
" nnoremap <silent><buffer><expr> d
" \ denite#do_map('do_action', 'delete')
" nnoremap <silent><buffer><expr> p
" \ denite#do_map('do_action', 'preview')
" nnoremap <silent><buffer><expr> c
" \ denite#do_map('do_action', 'cd')
" nnoremap <silent><buffer><expr> q
" \ denite#do_map('quit')
" nnoremap <silent><buffer><expr> i
" \ denite#do_map('open_filter_buffer')
" nnoremap <silent><buffer><expr> <Space>
" \ denite#do_map('toggle_select').'j'
"endfunction
"autocmd FileType denite-filter call s:denite_filter_my_settings()
"function! s:denite_filter_my_settings() abort
" imap <silent><buffer> <C-o> <Plug>(denite_filter_quit)
"endfunction
"nnoremap [denite] <Nop>
"nmap <Space>u [denite]
"nnoremap <silent> [denite]b :<C-u>Denite buffer:no-current<CR>
"nnoremap <silent> [denite]t :<C-u>Denite tab<CR>
"nnoremap <silent> [denite]m :<C-u>Denite file_mru<CR>
"nnoremap <silent> [denite]u :<C-u>Denite buffer:no-current tab file_mru file/rec<CR>
"nnoremap <silent> [denite]f :<C-u>DeniteBufferDir file file:new file/rec<CR>
"nnoremap <silent> [denite]g :<C-u>Denite grep<CR>
"if executable('rg')
" call denite#custom#var('file/rec', 'command',
" \ ['rg', '--files', '--glob', '!.git', '--color', 'never'])
" call denite#custom#var('grep', {
" \ 'command': ['rg'],
" \ 'default_opts': ['-i', '--vimgrep', '--no-heading'],
" \ 'recursive_opts': [],
" \ 'pattern_opt': ['--regexp'],
" \ 'separator': ['--'],
" \ 'final_opts': [],
" \ })
"endif
"call denite#custom#var('ghq', 'command',
" \ ['ghq', 'list', '--full-path', '--vcs', 'git'])
"fern
nnoremap <silent> <Space>f :<C-u>Fern .<CR>
" FixCursorHold.nvim
let g:cursorhold_updatetime = 100
" vim-lsp
nnoremap <C-]> :<C-u>LspDefinition<CR>
nnoremap [lsp] <Nop>
nmap <Space>l [lsp]
nnoremap <silent> [lsp]d :<C-u>LspDefinition<CR>
nnoremap <silent> [lsp]pd :<C-u>LspPeekDefinition<CR>
nnoremap <silent> [lsp]i :<C-u>LspImplementation<CR>
nnoremap <silent> [lsp]pi :<C-u>LspPeekImplementation<CR>
" vim-indent-guides
let g:indent_guides_enable_on_vim_startup = 1
" lightline
let g:lightline = {
\ 'colorscheme':'jellybeans'
\ }
" terraform-vim
let g:terraform_fmt_on_save=1
" vim-rego
autocmd bufwritepost *.rego silent !opa fmt -w %
" vim-goimports
let g:goimports_simplify = 1
" 'pocke/dicts')
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'ruby': $HOME . '.vim/bundle/dicts/ruby.dict',
\ }
" swith.vim
nnoremap - :Switch<cr>
autocmd FileType eruby let b:switch_custom_definitions =
\ [
\ ['if', 'unless'],
\ ['while', 'until'],
\ ['.blank?', '.present?'],
\ ['include', 'extend'],
\ ['class', 'module'],
\ ['.inject', '.delete_if'],
\ ['.map', '.map!'],
\ ['attr_accessor', 'attr_reader', 'attr_writer'],
\ [
\ {
\ ':\(\k\+\)\s\+=>': '\1:',
\ '\<\(\k\+\):': ':\1 =>',
\ }
\ ]
\ ]
autocmd FileType rspec let b:switch_custom_definitions =
\ [
\ ['describe', 'context', 'it'],
\ ['before', 'after'],
\ ['get', 'post', 'put', 'delete'],
\ ['\.to_not', '\.to'],
\ ['==', 'eql', 'equal'],
\ { '\([^. ]\+\)\.should\(_not\|\)': 'expect(\1)\.to\2' },
\ { 'expect(\([^. ]\+\))\.to\(_not\|\)': '\1.should\2' },
\ ]
"}}}
filetype plugin indent on
syntax on
colorscheme jellybeans
" colorscheme fairyfloss
"}}}
" Plugins Setting:"{{{
" gitv {{{
autocmd FileType git :setlocal foldlevel=99
" }}}
" textmanip.vim:"{{{
" 行の複製
"xmap <Space>d <Plug>(textmanip-duplicate-down)
"nmap <Space>d <Plug>(textmanip-duplicate-down)
"xmap <Space>D <Plug>(textmanip-duplicate-up)
"nmap <Space>D <Plug>(textmanip-duplicate-up)
" 選択したテキストの移動
xmap <C-k> <Plug>(textmanip-move-up)
xmap <C-j> <Plug>(textmanip-move-down)
xmap <C-h> <Plug>(textmanip-move-left)
xmap <C-l> <Plug>(textmanip-move-right)
"}}}
" YankRing.vim:"{{{
let g:yankring_history_dir = expand('$HOME')
let g:yankring_history_file = '.yankring_history'
nnoremap <silent> <F7> :YRShow<CR>
let g:yankring_max_history = 10
let g:yankring_window_height = 13
"}}}
" buftabs:"{{{
" ステータスラインに表示
" Ctrl+^で直前のバッファへ
let g:buftabs_in_statusline=1
" ファイル名のみ表示
let g:buftabs_only_basename=1
" 現在のバッファをハイライト
let g:buftabs_active_highlight_group="Visual"
" ステータスライン
set statusline=%=\ [%{(&fenc!=''?&fenc:&enc)}/%{&ff}]\[%Y]\[%04l,%04v][%p%%]
"}}}
" neosnippet
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
let g:neosnippet#snippets_directory="~/dotfiles/.vim/snippet"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
"}}}
" alignta: {{{
xnoremap <silent> a= :Alignta =>\=<CR>
xnoremap <silent> a: :Alignta 01 :<CR>
xmap <silent><expr> as mode() !=# 'v' ? ':Alignta \S\+'."\<CR>" : 'as'
xnoremap al :Alignta<Space>
" }}}
" Enable omni completin
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
" open-browser.vim:"{{{
" カーソルがURLならそのURLを開き、それ以外ならその単語でggr
let g:netrw_nogx = 1
nmap gx <Plug>(openbrowser-smart-search)
vmap gx <Plug>(openbrowser-smart-search)
" 別途開いてるHTMLファイルをブラウザで開く
cnoremap gx<CR> :! iron %<CR>
"}}}
" zen-coding:"{{{
let g:user_zen_expandabbr_key = '<c-e>'
" 入力補完有効
" スニペットは<C-e>で展開
let g:use_zen_complete_tag = 1
setlocal omnifunc=zencoding#CompleteTag
let g:user_zen_settings = {
\ 'lang' : 'ja',
\ 'indentation' : ' ',
\ 'html' : {
\ 'filters' : 'html',
\ },
\ 'css' : {
\ 'filters' : 'html, fc',
\ },
\ 'javascript' : {
\ 'snippets' : {
\ 'jq' : "$(function(){\n\t${cursor}${child}\n});",
\ 'jq:each' : "$each(${cursor}, function(index, item){\n\t${child}\n});",
\ 'fn' : "(function(){\n\t${cursor}\n})();",
\ 'tm' : "setTimeout(function(){\n\t${cursor},\n}, 100);",
\ },
\ },
\ 'php' : {
\ 'extends' : 'html',
\ 'filters' : 'html,c',
\ },
\}
"}}}
autocmd FileType quickrun AnsiEsc
let g:quickrun_config = {
\ "ruby.rspec/watchdogs_checker" : {
\ "type" : "watchdogs_checker/rubocop"
\ },
\ "rspec/watchdogs_checker" : {
\ "type" : "watchdogs_checker/rubocop"
\ },
\ "ruby/watchdogs_checker" : {
\ "type" : "watchdogs_checker/rubocop"
\ },
\ "watchdogs_checker/rubocop" : {
\ "cmdopt" : "--format emacs"
\ },
\ "watchdogs_checker/_" : {
\ "outputter/quickfix/open_cmd": "",
\ "hook/echo/enable" : 1,
\ "hook/echo/output_success": "> No Errors Found."
\ },
\ "runner/vimproc/updatetime": 10,
\ "ruby.rspec": {
\ "command": "rspec",
\ "exec": "bundle exec %c",
\ "cmdopt": "-cfd"
\ },
\ "markdown": {
\ "outputter": "browser"
\ }
\}
let g:watchdogs_check_BufWritePost_enables = {
\ "ruby" : 1,
\ "rspec" : 1,
\ "ruby.rspec" : 1,
\ "rspec.ruby" : 1
\}
augroup QRunRSpec
autocmd!
autocmd BufWinEnter,BufNewFile *_spec.rb set filetype=ruby.rspec
augroup END
nnoremap [quickrun] <Nop>
nmap <Space>k [quickrun]
nnoremap <silent> [quickrun]r :call QRunRspecCurrentLine()<CR>
fun! QRunRspecCurrentLine()
let line = line(".")
exe ":QuickRun -exec 'bundle exec %c %s%o' -cmdopt ':" . line . " -cfd'"
endfun
autocmd BufReadPost *_spec.rb call RSpecQuickrun()
" smartchr:"{{{
inoremap <expr> = smartchr#loop('=',' = ',' == ',' === ')
inoremap <expr> , smartchr#loop(',', ', ')
"}}}
" indent-guides:"{{{
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_color_change_percent = 30
let g:indent_guides_guide_size = 1
"}}}
" QFix Hown{{{
set runtimepath+=~/.vim/plugin/qfixapp
let QFixHowm_Key = 'g'
let howm_dir='~/tmp/howm'
let homm_fileencoding='utf-8'
let hown_fileformat='unix'
" ファイル拡張子をmkdにする
let howm_filename = '%Y/%m/%Y-%m-%d-%H%M%S.mkd'
" ファイルタイプをmarkdownにする
let QFixHowm_FileType = 'markdown'
" タイトル記号
let QFixHowm_Title = '#'
"}}}
"{{{ vim-python-virtualenv
" Apply g:pythonworkon to statusline
if exists('g:pythonworkon')
let &statusline='%F%m%r%h%w [FORMAT=%{&ff}][ENC=%{&fileencoding}][TYPE=%Y] [ASCII=\%03.3b] [HEX=\%02.2B] [POS=%04l,%04v][%p%%] [LEN=%L] %= [WORKON=%{pythonworkon}][Git=%{fugitive#statusline()}]'
endif
"}}}
"{{{ easymotion
" ホームポジションに近いキーを使う
let g:EasyMotion_keys='hjklasdfgyuiopqwertnmzxcvbHJKLASDFGYUIOPQWERTNMZXCVB'
" 「'」 + 何かにマッピング
let g:EasyMotion_leader_key="'"
" 1 ストローク選択を優先する
let g:EasyMotion_grouping=1
" カラー設定変更
hi EasyMotionTarget ctermbg=none ctermfg=red
hi EasyMotionShade ctermbg=none ctermfg=blue
"}}}
let g:lsp_settings = {}
let g:lsp_settings['gopls'] = {
\ 'workspace_config': {
\ 'usePlaceholders': v:true,
\ 'analyses': {
\ 'fillstruct': v:true,
\ },
\ },
\ 'initialization_options': {
\ 'usePlaceholders': v:true,
\ 'analyses': {
\ 'fillstruct': v:true,
\ },
\ },
\}
" AnySetting:"{{{
" バックアップ
set backup
if !isdirectory($HOME.'/.backup/')
call mkdir($HOME.'/.backup/')
endif
set backupdir=$HOME/.backup/
if !isdirectory($HOME.'/.swp/')
call mkdir($HOME.'/.swp/')
endif
set swapfile
set directory=$HOME/.swp/
"カーソル行のハイライト
set cursorline
augroup cch
autocmd! cch
autocmd WinLeave * set nocursorline
autocmd WinEnter,BufRead * set cursorline
augroup END
hi clear CursorLine
hi CursorLine gui=underline cterm=underline
"highlight CursorLine ctermfg=Blue ctermbg=black guibg=black
"ESC2回押しでハイライト消去
nmap <ESC><ESC> :nohlsearch<CR><ESC>
"保存時に行末の空白を除去
autocmd BufWritePre * :%s/\s\+$//ge
syntax on
highlight LineNr ctermfg=darkgrey
" Ctrl+Pで連続ペースト
vnoremap <silent> <C-p> "0p<CR>"
"{{{ :バッファ切り替え
nnoremap 1, 1gt<CR>
nnoremap 2, 2gt<CR>
nnoremap 3, 3gt<CR>
nnoremap 4, 4gt<CR>
nnoremap 5, 5gt<CR>
nnoremap 6, 6gt<CR>
nnoremap 7, 7gt<CR>
nnoremap 8, 8gt<CR>
nnoremap 9, 9gt<CR>
"}}}
" 単語移動 : {{{
nnoremap <C-h> b
nnoremap <C-l> w
nnoremap <S-h> ge
nnoremap <S-l> e
nnoremap <C-j> *
nnoremap <C-k> #
"}}}
" 行の折り返し時
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
" ウィンドウの移動 : {{{
nmap gh <C-w>h
nmap gl <C-w>l
nmap gj <C-w>j
nmap gk <C-w>k
"}}}
set autoread "ファイル変更されたら自動的に読み直す
set guioptions-=e
set noerrorbells "エラーベル利用しない
set visualbell
set ttyfast
set wildchar=<TAB> "補完を<Tab>で行う
set laststatus=2 "常にステータスライン表示
set showcmd "コマンドをステータスラインに表示
set cmdheight=1
set showmatch "対応する括弧を表示
set hlsearch "検索結果をハイライト
set expandtab "タブをスペースに置き換える
if !has('nvim')
set antialias
set clipboard=unnamed,autoselect
else
set clipboard+=unnamed
endif
set autoindent "オートインデント
set textwidth=0 " 勝手な改行をふせぐ
set list listchars=tab:>-,trail:_ " 不可視文字の表示
" Tabの画面上での幅
set tabstop=4
set shiftwidth=4
set number "行数表示
set ruler "右下に行,列表示
set incsearch "インクリメンタルサーチ
set ignorecase "大文字小文字区別しない
set smartcase "検索で小文字なら大文字を無視、大文字なら無視しない
set wrapscan "循環検索
set history=1000
set infercase "挿入モードの単語補完で小文字で打った単語でも大文字で補完できるように
set wildmenu "補完候補表示
set helplang=ja
set title "タイトルを表示
set backspace=2 "バックスペースでインデント、改行削除
set foldmethod=marker " 折りたたみ
set wildignorecase " :e でファイル開くとき大文字小文字区別しないで候補を探sす
" 日本語入力:"{{{
let IM_CtrlMode = 1
inoremap <silent> <C-j> <C-r>=IMState('FixMode')<CR>
function! IMCtrl(cmd)
let cmd = a:cmd
if cmd == 'On'
let res = system('xvkbd -text "\[Henkan]" > /dev/null 2>&1')
elseif cmd == 'Off'
let res = system('xvkbd -text "\[Muhenkan]" > /dev/null 2>&1')
elseif cmd == 'Toggle'
let res = system('xvkbd -text "\[Control]\[space]" > /dev/null 2>&1')
endif
return ''
endfunction
"}}}
" change StatusLineColor Insert and Normal:"{{{
au InsertEnter * hi StatusLine guifg=DarkBlue guibg=DarkYellow gui=none ctermfg=Blue ctermbg=DarkRed cterm=none
au InsertLeave * hi StatusLine guifg=DarkBlue guibg=DarkGray gui=none ctermfg=Blue ctermbg=DarkGray cterm=none
"}}}
"{{{ : tab shortcut
" Anywhere SID.
function! s:SID_PREFIX()
return matchstr(expand('<sfile>'), '<SNR>\d\+_\zeSID_PREFIX$')
endfunction
"qqq: でコマンド履歴を開く
"qqq/キーで検索履歴を開く
nnoremap qqq: <Esc>q:
nnoremap qqq/ <Esc>q/
"q:,q/,q?を無効化
nnoremap q: <Nop>
nnoremap q/ <Nop>
nnoremap q? <Nop>
set virtualedit=block
" 連続でインデントサイズを変更
vnoremap < <gv
vnoremap > >gv
"ESCキーを2回押すと終了する
"パス単位で削除,ESC2回で終了
" create dir auto
augroup vimrc-auto-mkdir
autocmd!
autocmd BufWritePre * call s:auto_mkdir(expand('<afile>:p:h'), v:cmdbang)
function! s:auto_mkdir(dir, force)
if !isdirectory(a:dir) && (a:force ||
\ input(printf('"%s" does not exist. Create? [y/N]', a:dir)) =~? '^y\%[es]$')
call mkdir(iconv(a:dir, &encoding, &termencoding), 'p')
endif
endfunction
augroup END
"}}}
" {{{ : function
" {{{: formatjson
command! -nargs=? Jq call s:Jq(<f-args>)
function! s:Jq(...)
if 0 == a:0
let l:arg = "."
else
let l:arg = a:1
endif
execute "%! jq \"" . l:arg . "\""
endfunction
" }}}
" }}}
" AnyLanguagesSetting:"{{{
" HTML setting
autocmd BufNewFile *.html 0r ~/.vim/template/template.html
" Python setting:"{{{
autocmd FileType python setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType python setl tabstop=8 expandtab shiftwidth=4 softtabstop=4 smarttab nosmartindent cindent textwidth=80 colorcolumn=80 autoindent
" Folding
autocmd FileType python setl foldmethod=indent
autocmd FileType python setl foldlevel=99
autocmd BufNewFile *.py 0r ~/.vim/template/template.py
function! AddPyEncoding()
for line in readfile(expand("%"))
if line =~ 'Date'
echo line
endif
endfor
endfunction
autocmd BufReadPost *.py :call AddPyEncoding()
autocmd Filetype cs setl dictionary=~/.vim/dict/unity.dict
"}}}
" Go setting:"{{{
autocmd FileType go setl tabstop=8 shiftwidth=8 noet
autocmd FileType rego setl tabstop=8 shiftwidth=8 noet
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
" }}}
" Ruby setting:"{{{
autocmd BufReadPost,BufNewFile *_spec.rb set filetype=rspec.ruby
autocmd BufReadPost,BufNewFile .pryrc set filetype=ruby
autocmd FileType ruby setl autoindent
autocmd FileType ruby setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType ruby setl tabstop=2 expandtab shiftwidth=2 softtabstop=2
"}}}
" Terraform setting: "{{{
autocmd BufReadPost,BufNewFile *.tf set filetype=terraform
autocmd FileType terraform setl autoindent
autocmd FileType terraform setl tabstop=2 expandtab shiftwidth=2 softtabstop=2
" }}}
" ShellScript setting:"{{{
autocmd FileType shell setl autoindent
autocmd FileType shell setl tabstop=8 expandtab shiftwidth=4 softtabstop=4
autocmd BufNewFile *.sh 0r ~/.vim/template/template.sh
"}}}
" JavaScript setting:"{{{
autocmd FileType javascript setl tabstop=8 expandtab shiftwidth=4 softtabstop=4
au BufRead,BufNewFile,BufReadPre *.coffee set filetype=coffee
autocmd FileType coffee setlocal sw=2 sts=2 ts=2 et
autocmd FileType typescript setl tabstop=2 expandtab shiftwidth=2 softtabstop=2
"}}}
" Perl setting{{{
autocmd BufNewFile *.pl 0r ~/.vim/template/template.pl
autocmd BufNewFile *.pm 0r ~/.vim/template/template.pm
autocmd BufNewFile,BufRead *.psgi set filetype=perl
autocmd BufRead,BufNewFile *.t,*.pm set filetype=perl
autocmd FileType perl,cgi :compiler perl
autocmd FileType perl setl autoindent
autocmd FileType perl setl cinkeys=0{,0},:,!^F,o,O,e
autocmd FileType perl setl formatoptions=tcqr
autocmd FileType perl setl tabstop=4 shiftwidth=4 softtabstop=4 cindent expandtab
"}}}
" PHP setting {{{
au BufReadPost,BufNewFile *.ctp :setl filetype=php
autocmd FileType php setl autoindent
autocmd FileType php setl tabstop=4 shiftwidth=4 softtabstop=4 cindent expandtab
" }}}
" Java setting {{{
au BufReadPost,BufNewFile *.bsh :setl filetype=java
autocmd FileType java setlocal omnifunc=javacomplete#Complete
autocmd FileType java setlocal completefunc=javacomplete#CompleteParamsInfo
autocmd FileType java setl tabstop=8 expandtab shiftwidth=4 tabstop softtabstop=4 smarttab nosmartindent cindent textwidth=80 colorcolumn=80 autoindent
" }}}
autocmd FileType xml setl tabstop=8 expandtab shiftwidth=4 tabstop softtabstop=4 smarttab nosmartindent cindent textwidth=80 colorcolumn=80 autoindent
" Vim setting
autocmd FileType vim setlocal expandtab shiftwidth=2
" Markdown setting
autocmd BufRead,BufNewFile *.mkd setfiletype mkd
autocmd BufRead,BufNewFile *.md setfiletype mkd
autocmd BufNewFile,BufRead *.yml,*.yaml setfiletype yaml
autocmd FileType yaml setlocal expandtab shiftwidth=2
"autocmd FileType elixir autocmd BufWritePost * !mix format <afile>
"{{{: JSON setting use JSON.vim
au! BufRead,BufNewFile *.json set filetype=json
augroup json_autocmd
autocmd!
autocmd FileType json set autoindent
autocmd FileType json set formatoptions=tcq2l
autocmd FileType json set textwidth=78 shiftwidth=2
autocmd FileType json set softtabstop=2 tabstop=8
autocmd FileType json set expandtab
autocmd FileType json set foldmethod=syntax
augroup END
"}}}
"}}}
" Encoding:"{{{
set fileencodings=utf-8,iso-2022-jp-3,iso-2022-jp,euc-jisx0213,euc-jp,ucs-bom,euc-jp,eucjp-ms,cp932
set encoding=utf-8
" 改行コードの自動認識
set fileformats=unix,dos,mac
"if exists('&ambiwidth')
" set ambiwidth=double
"endif
"}}}
if filereadable(expand('~/.vimrc.local'))
source ~/.vimrc.local
endif