-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
616 lines (473 loc) · 16.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
"-----------------------------------
"for dein.vim
"-----------------------------------
if &compatible
set nocompatible
endif
set runtimepath+=~/.vim/dein/repos/github.com/Shougo/dein.vim
call dein#begin(expand('~/.vim/dein'))
call dein#add('Shougo/dein.vim')
" My Bundles here:
" Solarized Colorscheme
call dein#add('altercation/vim-colors-solarized')
" desert colorscheme
call dein#add('fugalh/desert.vim')
" QFixHowm
call dein#add('fuenor/qfixhowm.git')
" Unite and create user interfaces
call dein#add('Shougo/unite.vim')
" Powerful file explorer implemented by Vim script
call dein#add('Shougo/vimfiler')
" Interactive command execution in Vim
call dein#add('Shougo/vimproc', {'build': 'make'})
" Next generation completion framework after neocomplcache.
call dein#add('Shougo/neocomplete')
"Run commands quickly.
call dein#add('thinca/vim-quickrun')
" Vim plugin that displays tags in a window, ordered by scope
call dein#add('majutsushi/tagbar')
" Go development plugin for Vim
call dein#add('fatih/vim-go')
" vim plugin providing godef support
call dein#add('dgryski/vim-godef')
" Extra plugin for golang
call dein#add('vim-jp/vim-go-extra')
" velocity syntax for vim
call dein#add('lepture/vim-velocity')
" Molokai color scheme for Vim
call dein#add('tomasr/molokai')
" A vim theme inspired by Atom's default dark theme
call dein#add('gosukiwi/vim-atom-dark')
" Everforest is a green based color scheme
call dein#add('sainnhe/everforest')
" A dark Vim/Neovim color scheme inspired by Atom's One Dark syntax theme.
call dein#add('joshdick/onedark.vim')
" The colorscheme featuring Japanese traditional colors.
call dein#add('aereal/vim-colors-japanesque')
" A dark color scheme for Vim
call dein#add('w0ng/vim-hybrid')
" vim interface to Web API
call dein#add('mattn/webapi-vim')
" Vim plugin: A framework to read/write fake:path
call dein#add('kana/vim-metarw')
" This plugin provides some functions of Hatena-Blog by using AtomPub API.
call dein#add('moznion/hateblo.vim')
" Realtime preview by Vim. (Markdown, reStructuredText, textile)
call dein#add('kannokanno/previm')
" Open URI with your favorite browser from your most favorite editor
call dein#add('tyru/open-browser.vim')
" CoffeeScript support for vim
call dein#add('kchmck/vim-coffee-script')
" Ease your git workflow within Vim
call dein#add('jreybert/vimagit')
" Vim plugin for the Perl module / CLI script 'ack'
call dein#add('mileszs/ack.vim')
" Dark powered asynchronous completion framework for neovim/Vim8
call dein#add('Shougo/deoplete.nvim')
" Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder.
call dein#add('ctrlpvim/ctrlp.vim')
" Fast CtrlP matcher using Vim's matchfuzzy() without dependencies.
call dein#add('mattn/ctrlp-matchfuzzy')
" Perform the replacement in quickfix.
call dein#add('thinca/vim-qfreplace')
" endwise.vim: wisely add end in ruby, endfunction/endif/more in vim script, etc
call dein#add('tpope/vim-endwise')
" An extensible & universal comment vim-plugin that also handles embedded filetypes
call dein#add('tomtom/tcomment_vim')
" Automatically save changes to disk
call dein#add('vim-scripts/vim-auto-save')
" Vim/Ruby Configuration Files
call dein#add('vim-ruby/vim-ruby')
" rails.vim: Ruby on Rails power tools
call dein#add('tpope/vim-rails')
" rbenv.vim: Minimal rbenv support
call dein#add('tpope/vim-rbenv')
" bundler.vim: Lightweight support for Ruby's Bundler
call dein#add('tpope/vim-bundler')
" A Vim plugin for visually displaying indent levels in code
call dein#add('nathanaelkane/vim-indent-guides')
" neo-snippet plugin
call dein#add('Shougo/neosnippet.vim')
" The standard snippets repository for neosnippet
call dein#add('gotchane/neosnippet-snippets')
" Syntax Highlight for Vue.js components
call dein#add('posva/vim-vue')
" surround.vim: quoting/parenthesizing made simple
call dein#add('tpope/vim-surround')
" Run Rspec specs from Vim
call dein#add('thoughtbot/vim-rspec')
" dispatch.vim: Asynchronous build and test dispatcher
call dein#add('tpope/vim-dispatch')
" killring-alike plugin for neovim and vim 8 with no default mappings
call dein#add('bfredl/nvim-miniyank')
" Unobtrusive scratch window
call dein#add('mtth/scratch.vim')
" keep and restore fcitx state when leaving/re-entering insert mode
call dein#add('vim-scripts/fcitx.vim')
" A unite.vim plugin
call dein#add('ujihisa/unite-colorscheme')
" True Sublime Text style multiple selections for Vim
call dein#add('terryma/vim-multiple-cursors')
" Auto close parentheses and repeat by dot dot dot...
call dein#add('cohama/lexima.vim')
" Support adding git commit prefix
call dein#add('KosukeMizuno/vim-git-commit-prefix')
" Typescript Syntax for Vim
call dein#add('leafgarland/typescript-vim')
" Syntax files for Solidity, the contract-oriented programming language for Ethereum.
call dein#add('tomlion/vim-solidity')
" Vim plugin for metrics, insights, and time tracking automatically generated from your programming activity.
call dein#add('wakatime/vim-wakatime')
" this plugin exists to allow vim to replace the Processing IDE to develop sketches.
call dein#add('sophacles/vim-processing')
" All the lua functions I don't want to write twice.
call dein#add('nvim-lua/plenary.nvim')
" Gaze deeply into unknown regions using the power of the moon.
call dein#add('nvim-telescope/telescope.nvim')
" TabNine For Vim
" call dein#add('codota/tabnine-vim')
if !has('nvim')
call dein#add('roxma/nvim-yarp')
call dein#add('roxma/vim-hug-neovim-rpc')
endif
call dein#end()
call dein#save_state()
if dein#check_install()
call dein#install()
endif
filetype plugin indent on
"-----------------------------------
"for general setting
"-----------------------------------
"行数字を表示
set number
"改行を削除できるようにする
set backspace=2
"swapfileを作らない
set noswapfile
"backupfileを作らない
set nobackup
"undoファイルを作らない
set noundofile
"保存されていないファイルがあるときでも別のファイルを開く
set hidden
"tmpファイルの保存先
"set directory=~/.vim/tmp
"set backupdir=~/.vim/tmp
"set undodir=~/.vim/tmp
"ヤンクをクリップボードにコピー
"set clipboard^=unnamed,unnamedplus
set clipboard+=unnamedplus
"タブの設定
set expandtab
set tabstop=2
set shiftwidth=2
"不可視文字表示形式設定
set list
"読み込み専用ファイルを編集可能に
set modifiable
set write
set lcs=tab:>-,eol:<,trail:-
"ステータスラインの設定 分けて書いた方が見易いと思う
set laststatus=2
set statusline=%n\:%y
set statusline+=[%{(&fenc!=''?&fenc:&enc)}]
set statusline+=[%{Getff()}]
set statusline+=%m%r\ %F%=[%l/%L]
function! Getff()
if &ff == 'unix'
return 'LF'
elseif &ff == 'dos'
return 'CR+LF'
elseif &ff == 'mac'
return 'CR'
else
return '?'
endif
endfunction
" tags path
set tags+=.git/tags
set nocursorline
"-----------------------------------
"for vimrc
"-----------------------------------
nnoremap <Leader>e :e ~/.vimrc<CR>
nnoremap <Leader>1 :source ~/.vimrc<CR>
"-----------------------------------
"for view
"-----------------------------------
"syntax
syntax on
"背景の明暗
"set background=dark
" TrueColor 設定
set termguicolors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
"カラースキームの設定
colorscheme everforest
"yamlの拡張子に変更
autocmd BufRead,BufNewFile *.vm set filetype=velocity
autocmd BufRead,BufNewFile *.template set filetype=yaml
"-----------------------------------
"for edit
"-----------------------------------
"バックスペースで以下を削除可能に
"indent:行頭の空白
"eol: 改行
"start:挿入位置より前の文字
set backspace=indent,eol,start
" 現在日時を入力
nmap <C-h><C-h> <ESC>a<C-r>=strftime("%Y%m%d_")<CR>
" 選択した部分を検索
vnoremap * "zy:let @/ = @z<CR>n
" Split window
nmap ss :split<Return><C-w>w
nmap sv :vsplit<Return><C-w>w
" Move window
map sh <C-w>h
map sk <C-w>k
map sj <C-w>j
map sl <C-w>l
" Move window
nmap st :tabnew<CR>
nmap sn gt
nmap sp gT
"-----------------------------------
"for vimproc
"-----------------------------------
let g:vimproc#download_windows_dll = 1
"-----------------------------------
"for vim-go
"-----------------------------------
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_fmt_autosave = 0
nnoremap mg :GoRun <CR>
nnoremap mf :GoFmt <CR>
"-----------------------------------
"for Neocomplete
"-----------------------------------
"let g:neocomplete#sources#omni#input_patterns.go = '\h\w\.\w*'
"-----------------------------------
"for VimFiler
"-----------------------------------
" ショートカットキー設定
nnoremap <C-l> :VimFiler -split -simple -winwidth=40 -no-quit
nnoremap <F7> :UniteBookmarkAdd
nnoremap <F8> :Unite bookmark
nnoremap mq :VimFilerClose default
nnoremap <C-k> :Scratch <CR>
" 編集中ファイルをエクスプローラで開く
nnoremap <Leader>d :silent ! start . <CR>
" auto_cd有効
let g:vimfiler_enable_auto_cd = 0
" セーフモード無効状態で起動
let g:vimfiler_safe_mode_by_default = 0
" bookmark時の移動
autocmd FileType vimfiler call unite#custom_default_action('directory', 'cd')
"-----------------------------------
"for vim-quickrun
"-----------------------------------
"quickrunでgo testを走らせる
autocmd BufRead,BufNewFile *_test.go set filetype=go.test
let g:quickrun_config = {}
let g:quickrun_config['go.test'] = {'command' : 'go', 'exec' : ['%c test']}
"-----------------------------------
""for Tagbar
"-----------------------------------
let g:tagbar_left = 0
let g:tagbar_autofocus = 1
nmap <F9> :TagbarToggle<CR>
"-----------------------------------
" for QFixHowm
"-----------------------------------
"QFixHowmキーマップ
let QFixHowm_Key = 'g'
"howm_dirはファイルを保存したいディレクトリを設定。
let howm_dir = '~/note/memo'
"howmファイル読込の際、howm_fileencodingに強制設定する
let QFixHowm_ForceEncoding = 1
let howm_fileformat = 'unix'
let howm_filename = '%Y/%m/%Y-%m-%d-%H%M%S.md'
let QFixHowm_DiaryFile = 'diary/%Y/%m/%Y-%m-%d-000000.howm'
" マルチエンコーディングgrepを使用する
let MyGrep_MultiEncoding = 1
"-----------------------------------
" for previm
"-----------------------------------
let g:previm_open_cmd = 'open -a /Applications/Google\ Chrome.app'
augroup PrevimSettings
autocmd!
autocmd BufNewFile,BufRead *.{md,mdwn,mkd,mkdn,mark*} set filetype=markdown
augroup END
"-----------------------------------
" for deplete.nvim
"-----------------------------------
let g:deoplete#enable_at_startup = 1
let g:python3_host_prog = '/usr/local/bin/python3.11'
function! ToggleDeoplete()
if win_gettype(winnr()) ==# 'popup'
call deoplete#disable()
else
call deoplete#enable()
endif
endfunction
augroup toggle_deoplete_on_popup
autocmd!
autocmd CursorMoved,CursorMovedI * call ToggleDeoplete()
augroup END
"-----------------------------------
" for utility command
"-----------------------------------
function! CopyRelativePathToClipboard()
let file_path = expand('%:p')
let dir_name = fnamemodify(file_path, ':h')
let file_name = fnamemodify(file_path, ':t')
let relative_path = substitute(file_path, getcwd().'/', '', '')
if has('macunix')
call system("echo '".relative_path."' | pbcopy")
else
call system("echo '".relative_path."' | xclip -selection clipboard")
endif
echo "Relative path copied to clipboard!"
endfunction
nnoremap <Leader>c :call CopyRelativePathToClipboard()<CR>
function! OpenGithubRepository()
let repository_url = substitute(system("git config --get remote.origin.url"), '\n', '', '')
let repository_url = substitute(repository_url, '\.git$', '', '')
let url = substitute(repository_url, '^git@github\.com:', 'https://github.com/', '')
call system('open '.url)
endfunction
function! OpenGithubFile()
let repository_url = substitute(system("git config --get remote.origin.url"), '\n', '', '')
let repository_url = substitute(repository_url, '\.git$', '', '')
let repository_url = substitute(repository_url, '^git@github\.com:', 'https://github.com/', '')
let file_path = expand('%:p')
let account_name = matchstr(repository_url, 'github\.com\/\zs[^\/]*')
let repo_name = matchstr(repository_url, '\zs[^\/]*\/[^\/]*\ze')
let default_branch = substitute(system("git symbolic-ref refs/remotes/origin/HEAD | awk -F'[/]' '{print $NF}'"), '\n', '', '')
let url = repository_url.'/find/'.default_branch
call system('open '.url)
endfunction
function! SearchFileByGithub()
call CopyRelativePathToClipboard()
call OpenGithubFile()
endfunction
nnoremap <Leader>rr :call OpenGithubRepository()<CR>
nnoremap <Leader>rf :call OpenGithubFile()<CR>
nnoremap <Leader>rs :call SearchFileByGithub()<CR>
"-----------------------------------
" for ack.vim
"-----------------------------------
if executable('rg')
let g:ackprg = 'rg --vimgrep --no-heading --no-ignore-messages'
endif
cnoreabbrev Ack Ack!
vnoremap <Leader>g y:Ack! <C-r>=fnameescape(@")<CR><CR>
"-----------------------------------
" for ctrlp.vim
"-----------------------------------
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
if executable('rg')
let g:ctrlp_user_command = 'rg --files %s'
let g:ctrlp_use_caching = 1
endif
"-----------------------------------
" for telescope
"-----------------------------------
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
function! ToggleDeoplete()
if exists(':Telescope') && match(getcmdline(), 'Telescope find_files') >= 0
call deoplete#disable()
else
call deoplete#enable()
endif
endfunction
augroup toggle_deoplete_on_telescope
autocmd!
autocmd CmdlineEnter : call ToggleDeoplete()
augroup END
"-----------------------------------
" for ale
"-----------------------------------
let g:ale_linters = {'javascript': ['eslint'],}
let g:ale_linters_explicit = 1
let g:ale_fix_on_save = 1
"-----------------------------------
" for vim-rails
"-----------------------------------
let g:rails_ctags_arguments = ['--languages=Ruby --tag-relative --recurse --sort=yes --append=no -f .git/tags']
"-----------------------------------
" for AutoSave
"-----------------------------------
if expand("%:p") =~ 'COMMIT_EDITMSG'
let g:auto_save = 0
else
let g:auto_save = 1
endif
let g:auto_save_events = ["InsertLeave"]
"-----------------------------------
" for vim-indent-guides
"-----------------------------------
let g:indent_guides_enable_on_vim_startup = 1
"-----------------------------------
" for neosnippet
"-----------------------------------
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
let g:neosnippet#scope_aliases = {}
let g:neosnippet#scope_aliases['javascript'] = 'html,javascript'
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.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
"-----------------------------------
" for vim-surround
"-----------------------------------
nmap ff <Plug>Csurround"'
nmap tt <Plug>Csurround'"
"-----------------------------------
" for vim-rspec
"-----------------------------------
let g:rspec_command = "Dispatch bin/rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"-----------------------------------
" for nvim-miniyank
"-----------------------------------
map p <Plug>(miniyank-autoput)
map P <Plug>(miniyank-autoPut)
"-----------------------------------
" for vim-scratch
"-----------------------------------
let g:scratch_filetype = 'markdown'
let g:scratch_autohide = 0
let g:scratch_height = 10
let g:git_commit_prefix_lang = 'en'
"-----------------------------------
" for blamer
"-----------------------------------
let g:blamer_enabled = 1
let g:blamer_delay = 500
"-----------------------------------
" for vim-processing
"-----------------------------------
let g:processing_doc_style = 'web'