-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
700 lines (541 loc) · 19.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
scriptencoding utf-8
let $VIM_ROOT=$HOME.'/.vim'
"============================================================
" plugin settings
"============================================================
filetype off
filetype plugin indent off
if $GOROOT != ''
set runtimepath+=$GOROOT/misc/vim/
endif
if 0 | endif
if has('vim_starting')
set nocompatible
endif
let s:dein_dir = expand('~/.cache/dein')
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
if &runtimepath !~# '/dein.vim'
if !isdirectory(s:dein_repo_dir)
execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
endif
execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p')
endif
if dein#load_state(s:dein_dir)
call dein#begin(s:dein_dir)
let g:rc_dir = expand('~/.vim/rc')
let s:toml = g:rc_dir . '/dein.toml'
let s:lazy_toml = g:rc_dir . '/dein_lazy.toml'
call dein#load_toml(s:toml, {'lazy': 0})
call dein#load_toml(s:lazy_toml, {'lazy': 1})
call dein#end()
call dein#save_state()
endif
" if dein#check_install(['Shougo/vimproc.vim'])
" call dein#add('Shougo/vimproc.vim', {'build' : 'make'})
" endif
if dein#check_install()
call dein#install()
endif
filetype on
filetype plugin indent on
let g:mapleader = "\<Space>"
let g:vim_json_syntax_conceal = 0
if dein#tap('unite.vim') "{{{
let g:unite_no_default_keyappings = 1
let g:unite_enable_start_insert = 1
nnoremap <silent> <Space>uf :<C-u>Unite -buffer-name=files file file/new<CR>
nnoremap <silent> <Space>un :<C-u>Unite file/new<CR>
nnoremap <silent> <Space>ud :<C-u>Unite directory_mru<CR>
nnoremap <silent> <Space>ub :<C-u>Unite buffer<CR>
nnoremap <silent> <Space>ua :<C-u>Unite -buffer-name=history file_mru<CR>
nnoremap <silent> <Space>us :<C-u>Unite snippet<CR>
nnoremap <silent> <Space>um :<C-u>Unite mapping<CR>
nnoremap <silent> <Space>ur :<C-u>Unite rails<CR>
nnoremap <silent> <Space>uh :<C-u>Unite outline<CR>
augroup UniteCmd
autocmd! UniteCmd
autocmd FileType unite call s:unite_my_settings()
augroup END
function! s:unite_my_settings()
imap <buffer> <C-w> <Plug>(unite_delete_backward_path)
endfunction
endif "}}}
if dein#tap('denite.nvim') "{{{
call denite#custom#map('insert', '<C-n>', '<denite:move_to_next_line>', 'noremap')
call denite#custom#map('insert', '<C-p>', '<denite:move_to_previous_line>', 'noremap')
call denite#custom#map('insert', '<C-a>', '<denite:move_caret_to_head>', 'noremap')
call denite#custom#map('insert', '<C-k>', '<denite:delete_text_after_caret>', 'noremap')
call denite#custom#map('insert', '<C-w>', '<denite:delete_word_before_caret>', 'noremap')
nnoremap <silent> <Space>uf :<C-u>Denite file_rec<CR>
nnoremap <silent> <Space>ub :<C-u>Denite buffer<CR>
endif "}}}
if dein#tap('deoplete.nvim') "{{{
let g:deoplete#enable_at_startup = 1
endif "}}}
let g:neocomplete#enable_at_startup = 1
if dein#tap('neosnippet') "{{{
let g:neosnippet#snippets_directory = $VIM_ROOT.'/snippets'
imap <C-j> <Plug>(neosnippet_expand_or_jump)
smap <C-j> <Plug>(neosnippet_expand_or_jump)
xmap <C-j> <Plug>(neosnippet_expand_target)
nnoremap <silent> <Space>ns :NeoSnippetEdit<CR>
endif "}}}
if dein#tap('neocomplete') "{{{
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#auto_completion_start_length = 3
let g:neocomplete#min_keyword_length = 4
let g:neocomplete#enable_ignore_case = 0
let g:neocomplete#enable_auto_select = 1
let g:neocomplete#enable_camel_case_completion = 0 " input AE -> suggest ArgumentsException
let g:neocomplete#skip_auto_completion_time = '0.3'
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'java' : $VIM_ROOT.'/dict/java14.dict',
\ 'scala' : $VIM_ROOT.'/dict/scala.dict'
\ }
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-n> pumvisible() ? "\<C-n>" : "\<C-x>\<C-o>\<Down>"
inoremap <expr><C-k> "\<C-x>\<C-o>"
" if !exists('g:neocomplete#force_omni_input_patterns')
" let g:neocomplete#force_omni_input_patterns = {}
" endif
" let g:neocomplete#force_omni_input_patterns.go = '[^.[:digit:] *\t]\.'
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
let g:neocomplete#sources#omni#input_patterns.go = '[^.[:digit:] *\t]\.\w*'
" if !exists('g:neocomplete#sources#omni#input_patterns')
" let g:neocomplete#sources#omni#input_patterns = {}
" endif
"
" if !exists('g:neocomplete#sources#omni#functions')
" let g:neocomplete#sources#omni#functions = {}
" endif
"
" if !exists('g:neocomplete#force_omni_input_patterns')
" let g:neocomplete#force_omni_input_patterns = {}
" endif
" Clang complete {{{
let $CLANG_ROOT = "/usr/local/clang_0522"
let g:clang_exe = $CLANG_ROOT . "/bin/clang"
let g:clang_complete_auto = 0
let g:clang_auto_select = 0
let g:clang_conceal_snippets = 1
let g:clang_debug = 0
let g:clang_use_library = 1
let g:clang_library_path = $CLANG_ROOT . "/lib"
" let g:neocomplete#force_omni_input_patterns.c =
" \ '[^.[:digit:] *\t]\%(\.\|->\)'
" let g:neocomplete#force_omni_input_patterns.cpp =
" \ '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
" }}}
" Java complete {{{
augroup JavaComplete
autocmd! JavaComplete
autocmd FileType java :setlocal omnifunc=javacomplete#Complete
autocmd FileType java :setlocal completefunc=javacomplete#CompleteParamsInfo
augroup END
" let g:neocomplete#force_omni_input_patterns.java =
" \ '[^. *\t]\.\h\w*\'
" }}}
" Rsense {{{
" let g:neocomplete#sources#rsense#home_directory = '/usr/local/Cellar/rsense/0.3/libexec'
" let g:neocomplete_omni_patterns.ruby = \ '[^. *\t]\.\w*\|\h\w*::'
" }}}
endif "}}}
if dein#tap('vimproc') "{{{
nnoremap <silent> <Space>vs :<C-u>VimShell<CR>
nnoremap <silent> <Space>vr :<C-u>VimShellInteractive irb<CR>
endif "}}}
if dein#tap('caw.vim') "{{{
silent! nmap <unique> <Space>c <Plug>(caw:i:toggle)
silent! vmap <unique> <Space>c <Plug>(caw:i:toggle)
endif "}}}
if dein#tap('taglist.vim') "{{{
" タグリストを開いた時にフォーカスを移す
let Tlist_GainFocus_On_ToggleOpen = 1
" 余分な情報や空白を表示しない
let Tlist_Compact_Format = 1
" タグリストをハイライトする
let Tlist_Auto_Highlight_Tag = 1
" タグを選択した際にタグリストを閉じる
let Tlist_Close_On_Select = 1
" 現在のファイルのタグリストのみを開く
let Tlist_Show_One_File = 1
" タグリストウィンドウのみしか存在しない時、vimを終了する
let Tlist_Exit_OnlyWindow = 1
" 新しくファイルを開いた際にタグリストを更新する
let Tlist_Auto_Update = 1
" タグリストの幅
let Tlist_WinWidth = 30
let Tlist_def_go_settings = 'go;g:enum;s:struct;u:union;t:type;' .
\ 'v:variable;f:function'
nnoremap <silent> <Space>t :<C-u>TlistToggle<CR>
endif "}}}
if dein#tap('tagbar') "{{{
" let g:tagbar_left = 1
nnoremap <silent> <Space>t :<C-u>TagbarToggle<CR>
endif "}}}
if dein#tap('emmet-vim') "{{{
let g:user_emmet_leader_key = '<C-l>'
let g:user_emmet_settings = {
\ 'lang' : 'ja',
\ 'html' : {
\ 'snippets' : {
\ 'rp' : '<%= | %>'
\ },
\ 'filters' : 'html',
\ 'indentation' : ' '
\ },
\ '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);",
\ },
\ },
\}
endif "}}}
if dein#tap('VimClojure') "{{{
let vimclojure#HighlightBuiltins=1
let vimclojure#HighlightContrib=1
let vimclojure#DynamicHighlighting=1
let vimclojure#ParenRainbow=1
let vimclojure#WantNailgun = 1
let vimclojure#NailgunClient = "ng"
endif "}}}
if dein#tap('vim-quickrun') "{{{
let g:quickrun_no_default_key_mappings = 1
let g:quickrun_config = {}
let g:quickrun_config.c = {
\ 'command': 'clang'
\ }
let g:quickrun_config['cpp/clang++11'] = {
\ 'cmdopt': '--std=c++11 --stdlib=libc++',
\ 'type': 'cpp/clang++11'
\ }
let g:quickrun_config.cpp = {
\ 'command': 'clang++',
\ 'cmdopt' : '-std=c++11 '
\ }
let g:quickrun_config.js = {
\ 'command': 'node'
\ }
silent! nmap <unique> <Space>r <Plug>(quickrun)
nnoremap <silent> <Space>js :<C-u>QuickRun -exec "jshint %S" >buffer:split=vertical<CR>
endif "}}}
if dein#tap('operator-camelize.vim') "{{{
nmap cm <Plug>(operator-camelize-toggle)iw
endif "}}}
if dein#tap('ale') "{{{
let g:ale_lint_on_text_changed = 'never'
let g:ale_linters = {
\ 'go': ['go build'],
\ }
endif "}}}
if dein#tap('syntastic') "{{{
let g:syntastic_mode_map = {
\ 'mode': 'passive',
\ 'active_filetypes': ['c', 'cpp', 'ruby', 'javascript', 'coffee', 'perl', 'go'],
\ 'passive_filetypes': ['html', 'typescript', 'java', 'scala']
\ }
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '⚠'
let g:syntastic_java_javac_options = '-Xlint -J-Dfile.encoding=UTF-8 -J-Duser.language=en'
let g:syntastic_cpp_compiler_exec = 'clang'
let g:syntastic_cpp_compiler_options = '--std=c++11 --stdlib=libc++'
let g:syntastic_enable_perl_checker = 1
let g:syntastic_perl_interpreter = '/Users/naoki.yaguchi/perl5/perlbrew/perls/perl-5.20.2/bin/perl'
let g:syntastic_perl_lib_path = ['./lib', '/Users/naoki.yaguchi/npf/fujiyama-development/donguri/app/lib', '/Users/naoki.yaguchi/npf/fujiyama-development/karasuma/app/lib', '/Users/naoki.yaguchi/npf/fujiyama-development/matoba/app/lib', '/Users/naoki.yaguchi/npf/fujiyama-development/kiyamachi/app/lib', '/Users/naoki.yaguchi/npf/fujiyama-development/kiyamachi/app/t/lib', '/Users/naoki.yaguchi/npf/fujiyama-development/kiyamachi/perlbrew/lib/site_perl/5.20.2']
let g:syntastic_perl_checkers = ['perl', 'podchecker']
let g:syntastic_go_checkers = ['go', 'golint']
endif "}}}
if dein#tap('vim-powerline') "{{{
" let g:Powerline_symbols = 'fancy'
endif "}}}
if dein#tap('colorizer.git') "{{{
let g:colorizer_nomap = 1
nnoremap <Space>a :ColorToggle<CR>
endif "}}}
if dein#tap('ag.vim') "{{{
nnoremap <Space>f :Ag <cword><CR>
endif "}}}
" if dein#tap('vim-multiple-cursors') "{{{
"
" " nmap <C-J> <NOP>
" let g:multi_cursor_use_default_mapping = 0
" let g:multi_cursor_next_key = '<C-n>'
" let g:multi_cursor_prev_key = '<C-p>'
" let g:multi_cursor_skip_key = '<C-x>'
" let g:multi_cursor_quit_key = '<Esc>'
" let g:multi_cursor_start_key='<C-J>'
"
" endif "}}}
if dein#tap('vim-over') "{{{
nnoremap <Space>o :OverCommandLine<CR>%s/
endif "}}}
if dein#tap('a.vim') "{{{
nnoremap <Space>a :A<CR>
endif "}}}
if dein#tap('nerdtree') "{{{
nnoremap <Space>nn :NERDTreeToggle<CR>
endif "}}}
if dein#tap('vim-go') "{{{
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
endif "}}}
if dein#tap('vim-lsp') "{{{
if executable('gopls')
let g:lsp_async_completion = 1
augroup LspGo
au!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'go-lang',
\ 'cmd': {server_info->['gopls', '-mode', 'stdio']},
\ 'whitelist': ['go'],
\ })
autocmd FileType go setlocal omnifunc=lsp#complete
augroup END
endif
endif "}}}
if dein#tap('sonictemplate-vim') "{{{
let g:sonictemplate_vim_template_dir = [
\ '$HOME/.vim/template'
\]
nnoremap <silent> <Leader>a :<C-u>Template procon<CR>
endif "}}}
filetype on
filetype plugin indent on
let g:vim_json_syntax_conceal = 0
"============================================================
" general settings
"============================================================
set helplang=ja " helpを日本語化
set iminsert=0 imsearch=0 " ?
" 前回の編集位置にカーソルを移動させる
augroup PrevCursor
autocmd! PrevCursor
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
" 改行時にコメントを引き継がない
set formatoptions+=mM
augroup LineBreak
autocmd! LineBreak
autocmd FileType * setlocal formatoptions-=ro
augroup END
set browsedir=current " Exploreの初期ディレクトリ
set scrolloff=10 " スクロール時の余白
set autoread " ファイルが書き換えられたら自動で読み直す
set vb t_vb= " ビープ音を鳴らさない
set clipboard+=unnamed
set mouse=a
set path+=/usr/local/include
set path+=/usr/include/c++/4.2.1
set backspace=indent,eol,start
set virtualedit+=block
set foldtext=FoldCCtext()
set foldcolumn=4
set fillchars=vert:\|
set t_Co=256
if !has('nvim')
set ttymouse=xterm2
endif
if !has('gui_running')
set timeout timeoutlen=1000 ttimeoutlen=75
endif
" サーチオプション
"----------------------------------------
set hlsearch " 検索文字をハイライト
set incsearch " インクリメンタルサーチ
set ignorecase " 大文字小文字を無視
set smartcase " 大文字が含まれている場合は大文字小文字を区別
nnoremap <Space><Space> :nohlsearch<CR>
let Grep_Skip_Dirs = '.svn .git'
let Grep_Skip_Files = '*.bak *~ *.swp'
" folding settings
"----------------------------------------
set foldmethod=marker
nnoremap zzc ggVGzc
nnoremap zzo ggVGzo
" エンコーディング
"----------------------------------------
set termencoding=utf-8
set encoding=utf-8
set fenc=utf-8
set fileencodings=utf-8,iso-2022-jp-3,iso-2022-jp,enc-jisx0213,euc-jp,ucs-bom,eucjp-ms,cp932
augroup Encoding
autocmd! Encoding
autocmd BufNew,BufRead,WinEnter COMMIT_EDITMSG setlocal enc=utf-8 fenc=utf-8
augroup END
" 指定したエンコーディングでファイルを開き直す
command! Cp932 edit ++enc=cp932
command! Eucjp edit ++enc=euc-jp
command! Iso2022jp edit ++enc=iso-2022-jp
command! Utf8 edit ++enc=utf-8
command! Jis Iso2022jp
command! Sjis Cp932
set scrolloff=10
" My keymap {{{
inoremap <C-A> <Home>
inoremap <C-E> <End>
nnoremap <silent> <Space>s i<Space><Right><Space><Left><Esc>
smap <C-H> <BS>i
inoremap <C-D> <Del>
inoremap <C-B> <Left>
inoremap <C-F> <Right>
nnoremap j g<Down>
nnoremap k g<Up>
nnoremap gj <Down>
nnoremap gk <Up>
nnoremap " <S-j>
nnoremap <S-j> <Nop>
" Fold {{{
" デフォルトのは使いにくいんで無効化する
nmap zd <NOP>
nmap zD <NOP>
nmap zE <NOP>
nmap zo <NOP>
nmap zO <NOP>
nmap zc <NOP>
nmap zC <NOP>
nmap za <NOP>
nmap zA <NOP>
nmap zv <NOP>
nmap zx <NOP>
nmap zX <NOP>
nmap zm <NOP>
nmap zM <NOP>
nmap zr <NOP>
nmap zR <NOP>
nmap zn <NOP>
nmap zN <NOP>
nmap zi <NOP>
nnoremap zn zM
nnoremap zp zR
nnoremap zh zc
nnoremap zl zo
nnoremap zo zMzv
"}}}
" }}}
" 英字配列キーボード用
"----------------------------------------
noremap ; :
noremap : ;
"============================================================
" appearance settings
"============================================================
set title " 端末のタイトルを表示
set ruler " 行番号と列番号を表示
set showmode " 現在のモードの表示
set number " 行番号表示
set ambiwidth=double " 一部のマルチバイト文字をascii2文字分の幅で表示
set display=uhex " 印字不可能文字を16進数で表示
set laststatus=2 " ステータスラインを常時表示
set listchars=tab:>- " 不可視文字の設定
set titlestring=(」・ω・)」うー!(/・ω・)/にゃー!
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set showmatch " カッコの対応をハイライト
set list " 不可視文字をハイライト
set lazyredraw " スクリプト実行中に画面を再描画しない
set ttyfast " 再描画を高速にする
syntax on
set background=dark
" 特殊な空白のハイライト
if has("syntax")
function! ActivateInvisibleIndicator()
syntax match InvisibleJISX0208Space " " display containedin=ALL
highlight InvisibleJISX0208Space term=underline ctermbg=darkgrey guibg=Blue
syntax match InvisibleTrailedSpace "[ \t]\+$" display containedin=ALL
highlight InvisibleTrailedSpace term=underline ctermbg=Red guibg=Red
endf
augroup invisible
autocmd! invisible
autocmd BufNew,BufRead * call ActivateInvisibleIndicator()
augroup END
endif
"入力モード時、ステータスラインのカラーを変更
augroup InsertHook
autocmd!
autocmd InsertEnter * highlight StatusLine guifg=#ccdc90 guibg=#2E4340
autocmd InsertLeave * highlight StatusLine guifg=#2E4340 guibg=#ccdc90
augroup END
" カーソルの行と列をハイライト
" augroup cch
" autocmd! cch
" autocmd WinLeave * set nocursorcolumn nocursorline
" autocmd WinEnter,BufRead * set cursorcolumn cursorline
" augroup END
"============================================================
" indent settings
"============================================================
syntax on
filetype indent on
colorscheme apprentice
set cindent " Cライクな文法に従いインデント
set expandtab
set ts=2 sw=2 sts=2
augroup TabSize
autocmd! TabSize
autocmd FileType java setlocal ts=4 sw=4 sts=4
autocmd FileType javascript setlocal ts=2 sw=2 sts=2
autocmd FileType perl setlocal ts=4 sw=4 sts=4
autocmd FileType c setlocal ts=4 sw=4 sts=4
autocmd FileType cpp setlocal noexpandtab
autocmd FileType json setlocal ts=4 sw=4 sts=4
autocmd FileType go setlocal noexpandtab ts=4 sw=4 sts=4
augroup END
augroup Go
autocmd FileType go autocmd BufWritePre <buffer> Fmt
augroup END
function! SetMyTab(sz)
exec 'setlocal sw='.a:sz.' ts='.a:sz.' sts='.a:sz
endfunction
command! -nargs=1 Tb call SetMyTab(<args>)
function! FormatJSON()
exec '%s/{/{/g'
exec '%s/\[/[/g'
exec '%s/}/}/g'
exec '%s/\]/]/g'
exec '%s/,/,/g'
exec ':normal gg=G'
endfunction
command! F call FormatJSON()
"============================================================
" complement settings
"============================================================
set wildmenu " 補完をwildmenu化
set complete+=k " 補完に辞書ファイルを追加
set completeopt+=menuone
set completeopt-=preview
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
augroup vimrc-local
autocmd!
autocmd BufNewFile,BufReadPost * call s:vimrc_local(expand('<afile>:p:h'))
autocmd BufReadPre .vimprojects set ft=vim
augroup END
function! s:vimrc_local(loc)
let files = findfile('.vimprojects', escape(a:loc, ' ') . ';', -1)
for i in reverse(filter(files, 'filereadable(v:val)'))
source `=i`
endfor
endfunction