/
plugin-settings.vim
764 lines (661 loc) · 25.5 KB
/
plugin-settings.vim
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
" 別ファイルに置いてた設定たち
" .config/nvim/plugins/airline.vim {{{
" let g:airline_theme = 'gruvbox'
" let g:airline_theme = 'dracula'
let g:airline_theme = 'sol'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_tabs = 0
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#buffer_idx_format = {
\ '0': '0:',
\ '1': '1:',
\ '2': '2:',
\ '3': '3:',
\ '4': '4:',
\ '5': '5:',
\ '6': '6:',
\ '7': '7:',
\ '8': '8:',
\ '9': '9:'
\}
nmap sp <Plug>AirlineSelectPrevTab
nmap sn <Plug>AirlineSelectNextTab
" 謎のエラーが出る
" nmap <expr> s<Space> "<Plug>AirlineSelectTab" . v:count
nmap 1s<Space> <Plug>AirlineSelectTab1
nmap 2s<Space> <Plug>AirlineSelectTab2
nmap 3s<Space> <Plug>AirlineSelectTab3
nmap 4s<Space> <Plug>AirlineSelectTab4
nmap 5s<Space> <Plug>AirlineSelectTab5
nmap 6s<Space> <Plug>AirlineSelectTab6
nmap 7s<Space> <Plug>AirlineSelectTab7
nmap 8s<Space> <Plug>AirlineSelectTab8
nmap 9s<Space> <Plug>AirlineSelectTab9
" let g:airline#extensions#whitespace#mixed_indent_algo = 1
" let g:airline#extensions#tabline#buffer_nr_show = 1
" }}}
" .config/nvim/plugins/coc-settings.vim {{{
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gr <Plug>(coc-references)
nmap <silent> <Space>r <Plug>(coc-rename)
nmap <silent> K :call CocAction('doHover')<CR>
" nmap <Space><Space>p :CocList -A --normal yank<CR>
nmap <silent> <Space>j :call CocAction('diagnosticNext')<CR>
nmap <silent> <Space>k :call CocAction('diagnosticPrevious')<CR>
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:airline_section_error = '%{airline#util#wrap(airline#extensions#coc#get_error(),0)}'
let g:airline_section_warning = '%{airline#util#wrap(airline#extensions#coc#get_warning(),0)}'
" let g:LanguageClient_serverCommands = {
"\ 'julia': ['/Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia']}
augroup rc_coc
autocmd!
autocmd Filetype java nnoremap <Space>i :CocCommand java.action.organizeImports<CR>
augroup END
" Use <C-j> for jump to next placeholder, it's default of coc.nvim
let g:coc_snippet_next = '<C-j>'
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim
let g:coc_snippet_prev = '<C-k>'
imap <C-q> <Plug>(coc-snippets-expand)
" }}}
" .config/nvim/plugins/de_file_xpl.vim {{{
" もし作成してなかったら ~/.defxsessions を作成する
" そして defx を開く際にセッションファイルを指定する
"
let g:defx_sessions_file = $HOME . '/.defxsessions'
let g:defx_ignored_files = '.git,__pycache__,.mypy_cache'
" floating window の設定
let s:denite_win_width_percent = 0.7
let s:denite_win_height_percent = 0.7
" Change denite default options
function! ResizeDefxFloatingWindow()
call defx#custom#option('_', {
\ 'split': 'floating',
\ 'winwidth': float2nr(&columns * s:denite_win_width_percent),
\ 'wincol': float2nr((&columns - (&columns * s:denite_win_width_percent)) / 2),
\ 'winheight': float2nr(&lines * s:denite_win_height_percent),
\ 'winrow': float2nr((&lines - (&lines * s:denite_win_height_percent)) / 2),
\ })
endfunction
call ResizeDefxFloatingWindow()
call defx#custom#column('filename', {
\ 'min_width': float2nr(&columns * s:denite_win_width_percent - 30),
\ 'max_width': float2nr(&columns * s:denite_win_width_percent - 30),
\ })
nnoremap <expr><silent> sz ":Defx " . "-columns=git:indent:icons:filename "
\ . "-buffer-name=leftw "
\ . "-session-file=" . g:defx_sessions_file . " "
\ . "-ignored-files=" . g:defx_ignored_files . " "
\ . "-resume "
\ . "-toggle -split=vertical -winwidth=30 -direction=topleft<CR>"
nnoremap <expr><silent> sf ":Defx " . "-columns=git:indent:icons:filename:type:size:time "
\ . "-buffer-name=float "
\ . "-session-file=" . g:defx_sessions_file . " "
\ . "-ignored-files=" . g:defx_ignored_files . " "
\ . "-resume "
\ . "-toggle <CR>"
if getftype(g:defx_sessions_file) != "file"
call writefile(["{}"], g:defx_sessions_file)
echo "Created .defxsessions file to home directory."
endif
augroup rc_defx
autocmd!
autocmd FileType defx call s:defx_my_settings()
autocmd FileType defx set nonumber
autocmd FileType defx set signcolumn=no
augroup END
function! s:defx_my_settings() abort
let bufkind = strpart(bufname(""), 7, 5)
if (bufkind == "float")
nnoremap <nowait><silent><buffer><expr> <CR>
\ defx#is_directory()? defx#do_action('drop') :
\ defx#do_action('multi', ['drop', 'quit'])
nnoremap <silent><buffer><expr> l
\ defx#is_directory()? defx#do_action('drop') :
\ defx#do_action('multi', ['drop', 'quit'])
else
nnoremap <nowait><silent><buffer><expr> <CR>
\ defx#do_action('drop')
nnoremap <silent><buffer><expr> l
\ defx#do_action('drop')
endif
" Define mappings
nnoremap <silent><buffer><expr> cc
\ defx#do_action('copy')
nnoremap <silent><nowait><buffer><expr> m
\ defx#do_action('move')
nnoremap <silent><buffer><expr> p
\ defx#do_action('paste')
nnoremap <silent><nowait><buffer><expr> t
\ defx#do_action('open_or_close_tree')
nnoremap <silent><buffer><expr> T
\ defx#do_action('open_tree_recursive')
nnoremap <silent><buffer><expr> w
\ defx#do_action('add_session')
nnoremap <silent><buffer><expr> E
\ defx#do_action('open', 'vsplit')
nnoremap <silent><buffer><expr> P
\ defx#do_action('open', 'pedit')
nnoremap <silent><buffer><expr> K
\ defx#do_action('new_directory')
nnoremap <silent><buffer><expr> o
\ defx#do_action('new_file')
nnoremap <silent><buffer><expr> M
\ defx#do_action('new_multiple_files')
nnoremap <silent><buffer><expr> C
\ defx#do_action('toggle_columns',
\ 'mark:filename:type:size:time')
nnoremap <silent><buffer><expr> S
\ defx#do_action('toggle_sort', 'time')
nnoremap <silent><buffer><expr> dd
\ defx#do_action('remove')
nnoremap <silent><buffer><expr> r
\ defx#do_action('rename')
nnoremap <silent><buffer><expr> !
\ defx#do_action('execute_command')
nnoremap <silent><buffer><expr> x
\ defx#do_action('execute_system')
nnoremap <silent><buffer><expr> yy
\ defx#do_action('yank_path')
nnoremap <silent><buffer><expr> .
\ defx#do_action('toggle_ignored_files')
nnoremap <silent><buffer><expr> ;
\ defx#do_action('repeat')
nnoremap <silent><buffer><expr> h
\ defx#do_action('cd', ['..'])
nnoremap <silent><buffer><expr> ~
\ defx#do_action('cd')
nnoremap <silent><buffer><expr> q
\ defx#do_action('quit')
nnoremap <silent><nowait><buffer><expr> <Space>
\ defx#do_action('toggle_select') . 'j'
nnoremap <silent><buffer><expr> *
\ defx#do_action('toggle_select_all')
nnoremap <silent><buffer><expr> j
\ line('.') == line('$') ? 'gg' : 'j'
nnoremap <silent><buffer><expr> k
\ line('.') == 1 ? 'G' : 'k'
nnoremap <silent><buffer><expr> <C-l>
\ defx#do_action('redraw')
nnoremap <silent><buffer><expr> <C-g>
\ defx#do_action('print')
nnoremap <silent><buffer><expr> cd
\ defx#do_action('change_vim_cwd')
nnoremap <nowait><buffer> f :DefxLineSearch<Space>
nnoremap <nowait><buffer> F :DefxLineBackSearch<Space>
endfunction
call defx#custom#column('mark', {
\ 'readonly_icon': '✗',
\ 'selected_icon': '✓',
\ })
command! -nargs=1 DefxLineSearch let @m=escape(<q-args>, '/\') | call search('\v^✹?\s*\S (\*|\|){1,2}\V\zs'. @m)
command! -nargs=1 DefxLineBackSearch let @m=escape(<q-args>, '/\') | call search('\v^✹?\s*\S (\*|\|){1,2}\V\zs'. @m, 'b')
" }}}
" .config/nvim/plugins/dein-firenvim.vim {{{
" vim:fdm=marker:
" Required:
" set runtimepath+=$HOME/.cache/dein/repos/github.com/Shougo/dein.vim
" https://qiita.com/kawaz/items/ee725f6214f91337b42b
" dein自体の自動インストール
let s:cache_home = empty($XDG_CACHE_HOME) ? expand('~/.cache') : $XDG_CACHE_HOME
let s:dein_dir = s:cache_home . '/dein'
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
if !isdirectory(s:dein_repo_dir)
call system('git clone https://github.com/Shougo/dein.vim ' . shellescape(s:dein_repo_dir))
endif
let &runtimepath = s:dein_repo_dir .",". &runtimepath
" プラグイン読み込み&キャッシュ作成
" Required:
if dein#load_state('$HOME/.cache/dein')
call dein#begin('$HOME/.cache/dein')
" disable plugins
call dein#disable('vim-airline/vim-airline')
call dein#disable('vim-airline/vim-airline-themes')
call dein#disable('monaqa/smooth-scroll')
call dein#disable('thinca/vim-splash')
call dein#disable('gruvbox-community/gruvbox')
call dein#disable('rhysd/rust-doc.vim')
call dein#disable('thinca/vim-quickrun')
call dein#disable('Shougo/vimproc.vim')
call dein#disable('previm/previm')
call dein#disable('lambdalisue/gina.vim')
call dein#disable('xolox/vim-session')
call dein#disable('xolox/vim-misc')
call dein#disable('tpope/vim-rhubarb')
call dein#disable('syusui-s/scrapbox-vim')
call dein#disable('wsdjeg/dein-ui.vim')
call dein#disable('raghur/vim-ghost')
" Let dein manage dein
" Required:
call dein#add('$HOME/.cache/dein/repos/github.com/Shougo/dein.vim')
" firenvim
" call dein#add('glacambre/firenvim',
"\ {
"\ 'hook_post_update': { _ -> firenvim#install(0) },
"\ 'hook_add': 'source ~/.config/nvim/plugins/firenvim.vim',
"\ 'merged': 0
"\ })
" プラグインリストを収めた TOML ファイル
" 予め TOML ファイル(後述)を用意しておく
let g:rc_dir = expand('~/.config/nvim/plugins/rc')
let s:toml = g:rc_dir . '/dein.toml'
let s:lazy_toml = g:rc_dir . '/dein_lazy.toml'
" TOML を読み込み、キャッシュしておく
call dein#load_toml(s:toml, {'lazy': 0})
call dein#load_toml(s:lazy_toml, {'lazy': 1})
" Required:
call dein#end()
call dein#save_state()
endif
" Required だけど init.vim でやってるから別にいい
" filetype plugin indent on
" syntax enable
" If you want to install not installed plugins on startup.
if dein#check_install()
call dein#install()
endif
" }}}
" .config/nvim/plugins/dein.vim {{{
" Required:
" set runtimepath+=$HOME/.cache/dein/repos/github.com/Shougo/dein.vim
" https://qiita.com/kawaz/items/ee725f6214f91337b42b
" dein自体の自動インストール
let s:cache_home = empty($XDG_CACHE_HOME) ? expand('~/.cache') : $XDG_CACHE_HOME
let s:dein_dir = s:cache_home . '/dein'
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
if !isdirectory(s:dein_repo_dir)
call system('git clone https://github.com/Shougo/dein.vim ' . shellescape(s:dein_repo_dir))
endif
let &runtimepath = s:dein_repo_dir .",". &runtimepath
" プラグイン読み込み&キャッシュ作成
" Required:
if dein#load_state('$HOME/.cache/dein')
call dein#begin('$HOME/.cache/dein')
" Let dein manage dein
" Required:
call dein#add('$HOME/.cache/dein/repos/github.com/Shougo/dein.vim')
" プラグインリストを収めた TOML ファイル
" 予め TOML ファイル(後述)を用意しておく
let g:rc_dir = expand('~/.config/nvim/plugins/rc')
let s:toml = g:rc_dir . '/dein.toml'
let s:lazy_toml = g:rc_dir . '/dein_lazy.toml'
" TOML を読み込み、キャッシュしておく
call dein#load_toml(s:toml, {'lazy': 0})
call dein#load_toml(s:lazy_toml, {'lazy': 1})
" Required:
call dein#end()
call dein#save_state()
endif
" Required だけど init.vim でやってるから別にいい
" filetype plugin indent on
" syntax enable
" If you want to install not installed plugins on startup.
if dein#check_install()
call dein#install()
endif
" }}}
" .config/nvim/plugins/denite.vim {{{
nnoremap sb :Denite buffer -sorters=sorter/word<CR>
nnoremap sg :Denite grep -buffer-name=search-buffer-denite<CR>
nnoremap sG :Denite -resume -buffer-name=search-buffer-denite<CR>
nnoremap s] :<C-u>Denite -resume -buffer-name=search-buffer-denite -select=+1 -immediately<CR>
nnoremap s[ :<C-u>Denite -resume -buffer-name=search-buffer-denite -select=-1 -immediately<CR>
nnoremap so :Denite file/rec -buffer-name=search-file-denite<CR>
nnoremap sO :Denite file/rec -resume -buffer-name=search-file-denite<CR>
autocmd FileType rust nnoremap <buffer> <CR>d :Denite rust/doc<CR>
" floating window の設定
let s:denite_win_width_percent = 0.85
let s:denite_win_height_percent = 0.7
function! ResizeDeniteFloatingWindow()
call denite#custom#option('_', {
\ 'split': 'floating',
\ 'winwidth': float2nr(&columns * s:denite_win_width_percent),
\ 'wincol': float2nr((&columns - (&columns * s:denite_win_width_percent)) / 2),
\ 'winheight': float2nr(&lines * s:denite_win_height_percent),
\ 'winrow': float2nr((&lines - (&lines * s:denite_win_height_percent)) / 2),
\ 'prompt': "❯"
\ })
endfunction
call ResizeDeniteFloatingWindow()
let s:ignore_globs = [ '.git/', '.ropeproject/', '__pycache__/',
\ 'venv/', 'images/', '*.min.*', 'img/', 'fonts/',
\ '*.aux', '*.bbl', '*.blg', '*.dvi', '*.fdb_latexmk', '*.fls', '*.synctex.gz', '*.toc',
\ '*.out', '*.snm', '*.nav',
\ '*.pdf', '*.eps', '*.svg',
\ '*.png', '*.jpg', '*.jpeg', '*.bmp',
\ 'searchindex.js',
\ '*.ipynb',
\ ]
" そもそも ag のレベルで検索対象からはずす
call denite#custom#var('file/rec', 'command', [
\ 'pt',
\ '--follow',
\ ] + map(deepcopy(s:ignore_globs), { k, v -> '--ignore=' . v }) + [
\ '--nocolor',
\ '--nogroup',
\ '--hidden',
\ '-g',
\ ''
\ ])
" call denite#custom#var('buffer', 'exclude_unlisted', '0')
call denite#custom#var('grep', 'command', ['pt'])
call denite#custom#var('grep', 'default_opts',
\ ['-i', '--nogroup', '--nocolor', '--smart-case', '--hidden'])
call denite#custom#var('grep', 'recursive_opts', [])
call denite#custom#var('grep', 'pattern_opt', [])
call denite#custom#var('grep', 'separator', ['--'])
call denite#custom#var('grep', 'final_opts', [])
" matcher/ignore_globs 以外のお好みの matcher を指定する
call denite#custom#source('file/rec', 'matchers', ['matcher/substring'])
" 他のソース向けに ignore_globs 自体は初期化
call denite#custom#filter('matcher/ignore_globs', 'ignore_globs', s:ignore_globs)
call denite#custom#source('grep',
\ 'matchers', ['converter/abbr_word', 'matcher_fuzzy', 'matcher/ignore_globs'],
\ )
call denite#custom#source('file/rec',
\ 'matchers', ['matcher_fuzzy', 'matcher/ignore_globs'])
call denite#custom#var('buffer', 'date_format', '')
call denite#custom#source('buffer', 'matchers', ['converter/abbr_word', 'matcher/substring'])
augroup rc_denite
autocmd!
autocmd FileType denite call s:denite_my_settings()
augroup END
function! s:denite_my_settings() abort
nnoremap <nowait><silent><buffer><expr> <CR>
\ denite#do_map('do_action')
nnoremap <silent><nowait><buffer><expr> d
\ denite#do_map('do_action', 'delete')
nnoremap <silent><buffer><expr> p
\ denite#do_map('do_action', 'preview')
nnoremap <silent><buffer><expr> q
\ denite#do_map('quit')
nnoremap <silent><buffer><expr> i
\ denite#do_map('open_filter_buffer')
nnoremap <silent><nowait><buffer><expr> t
\ denite#do_map('toggle_select')
nnoremap <silent><nowait><buffer><expr> <Space>
\ denite#do_map('toggle_select') . "j"
nnoremap <silent><nowait><buffer><expr> yy
\ denite#do_map('do_action', 'yank')
endfunction
" }}}
" .config/nvim/plugins/fern.vim {{{
let g:fern#disable_default_mappings = 1
let g:fern#default_hidden = 1
nnoremap sf :<C-u>Fern . -drawer -toggle<CR>
augroup rc_fern
autocmd!
autocmd FileType fern set nonumber
autocmd FileType fern set signcolumn=no
autocmd FileType fern set foldcolumn=0
autocmd FileType fern call s:fern_settings()
augroup END
function s:fern_settings()
" move cwd, open file
nmap <buffer> l <Plug>(fern-action-enter)
nmap <buffer> <C-h> <Plug>(fern-action-leave)
nmap <nowait><buffer> <CR> <Plug>(fern-action-open)
nmap <buffer> e <Plug>(fern-action-open)
nmap <buffer> <BS> <Plug>(fern-action-leave)
" expand/collapse tree
nmap <nowait><buffer> t <Plug>(fern-action-expand)
nmap <nowait><buffer> T <Plug>(fern-action-collapse)
" move, remove, copy...
nmap <buffer> dd <Plug>(fern-action-trash)
endfunction
" }}}
" .config/nvim/plugins/firenvim.vim {{{
let g:firenvim_config = {
\ 'globalSettings': {
\ 'alt': 'all',
\ },
\ 'localSettings': {
\ '.*': {
\ 'cmdline': 'neovim',
\ 'priority': 0,
\ 'selector': 'textarea',
\ 'takeover': 'never',
\ },
\ }
\ }
augroup Firenvim
autocmd!
autocmd BufEnter play.golang.org_*.txt set filetype=go
autocmd BufEnter play.rust-lang.org_*.txt set filetype=rust
autocmd BufEnter github.com_*.txt set filetype=markdown
autocmd BufEnter localhost_notebooks*.txt set filetype=python
autocmd BufEnter localhost_notebooks*.txt let b:coc_diagnostic_disable = 1
augroup END
" }}}
" .config/nvim/plugins/fugitive.vim {{{
nnoremap <Space>g :G<CR>
let g:nremap = {'s': '<Nop>'}
augroup rc_fugitive
autocmd!
autocmd FileType fugitive call s:fugitive_my_settings()
augroup END
function! s:fugitive_my_settings() abort
nmap <buffer> u -
endfunction
" }}}
" .config/nvim/plugins/gina.vim {{{
nnoremap <Space>g :<C-u>Gina status -s --opener=split<CR>
" }}}
" .config/nvim/plugins/go.vim {{{
let g:go_fmt_autosave = 0
let g:go_fmt_command = "goimports"
let g:go_fmt_fail_silently = 1
let g:go_highlight_types = 1
let g:go_doc_popup_window = 1
" let g:go_auto_type_info = 1
" let g:go_auto_sameids = 1
augroup rc_go
autocmd!
autocmd FileType go call s:go_my_settings()
augroup END
function! s:go_my_settings() abort
noremap <buffer> s] :cnext<CR>
noremap <buffer> s[ :cprev<CR>
nmap <buffer> <CR>b :<C-u>call <SID>build_go_files()<CR>
noremap <buffer> <CR>r :GoRun<CR>
noremap <buffer> <CR>t :GoTest<CR>
noremap <buffer> <CR>f :GoTestFunc<CR>
noremap <buffer> <CR>g :GoFmt<CR>
noremap <buffer> <CR>i :GoImports<CR>
nmap <CR>c <Plug>(go-coverage-toggle):set list!<CR>
" nnoremap <CR>d :Denite decls<CR>
nnoremap <CR>d :GoDebugStart<CR>
endfunction
" run :GoBuild or :GoTestCompile based on the go file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#test#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
" }}}
" .config/nvim/plugins/lexima.vim {{{
call lexima#add_rule({'at': '\%#[-0-9a-zA-Z_]', 'char': '{', 'input': '{'})
call lexima#add_rule({'at': '\%#\\', 'char': '{', 'input': '{', 'filetype': ['latex', 'tex']})
call lexima#add_rule({'char': '$', 'input_after': '$', 'filetype': ['latex', 'tex']})
call lexima#add_rule({'char': '$', 'at': '\%#\$', 'leave': 1, 'filetype': ['latex', 'tex']})
call lexima#add_rule({'char': '<BS>', 'at': '\$\%#\$', 'delete': 1, 'filetype': ['latex', 'tex']})
" call lexima#add_rule({'char': '\{', 'input_after': '\}', 'filetype': ['latex', 'tex']})
" call lexima#add_rule({'char': '}', 'at': '\\\%#}', 'leave': 1, 'filetype': ['latex', 'tex']})
" call lexima#add_rule({'char': '<BS>', 'at': '\\\{\%#\\\}', 'input': '<BS><BS><DEL><DEL>', 'filetype': ['latex', 'tex']})
call lexima#add_rule({'char': "'", 'input': "'", 'filetype': ['latex', 'tex', 'satysfi']})
" call lexima#add_rule({'input_after': '>', 'char': '<', 'filetype': ['satysfi']})
" call lexima#add_rule({'char': '<', 'at': '\\\%#', 'filetype': ['satysfi']})
" call lexima#add_rule({'char': '>', 'leave': 1, 'at': '\%#>', 'filetype': ['satysfi']})
" call lexima#add_rule({'char': '<BS>', 'at': '<\%#>', 'delete': 1, 'filetype': ['satysfi']})
call lexima#add_rule({'char': '``', 'input_after': '``', 'filetype': ['rst']})
" call lexima#add_rule({'char': "(", 'input_after': ")"})
" call lexima#add_rule({'char': ")", 'at': "\%#)", 'leave': 1})
" call lexima#add_rule({'char': '<BS>', 'at': '(\%#)', 'delete': 1})
" }}}
" .config/nvim/plugins/quickrun.vim {{{
let g:quickrun_config = get(g:, 'quickrun_config', {})
let g:quickrun_config._ = {
\ 'runner': 'vimproc',
\ 'runner/vimproc/updatetime': 40,
\ 'outputter': 'error',
\ 'outputter/error/success': 'buffer',
\ 'outputter/error/error': 'quickfix',
\ 'hook/close_quickfix/enable_exit': 1
\ }
let quickrun_config['jupytext'] = {
\ 'command': 'jupytext',
\ 'exec': '%c %o %a',
\ 'cmdopt': '--update --to notebook',
\ 'outputter/error/success': 'null',
\ 'outputter/error/error': 'buffer',
\ }
let quickrun_config['satysfi'] = {
\ 'command': 'satysfi',
\ 'exec': '%c %a',
\ 'outputter/error/success': 'null',
\ 'outputter/error/error': 'buffer',
\ }
let quickrun_config['satysfi-debug'] = {
\ 'command': 'satysfi',
\ 'exec': '%c %a %o',
\ 'cmdopt': '--debug-show-bbox --debug-show-space --debug-show-block-bbox --debug-show-block-space',
\ 'outputter/error/success': 'null',
\ 'outputter/error/error': 'buffer',
\ }
" example; :QuickRun rsync -args /Users/mogami/work/path-of-project remote:work/sync-mac
let g:quickrun_config['rsync'] = {
\ 'command': 'rsync',
\ 'cmdopt': '-C --filter=":- .gitignore" --exclude ".git" -acvz --delete -e ssh',
\ 'exec': '%c %o %a',
\ 'outputter/error/success': 'null',
\ }
augroup rc_quickrun
autocmd!
autocmd BufRead,BufNewFile *.saty nnoremap <buffer> <CR>q :QuickRun satysfi -args %{expand("%")}<CR>
autocmd BufRead,BufNewFile *.saty nnoremap <buffer> <CR>Q :QuickRun satysfi-debug -args %{expand("%")}<CR>
autocmd FileType python nnoremap <buffer> <CR>q :QuickRun jupytext -args %{expand("%")}<CR>
augroup END
" }}}
" .config/nvim/plugins/sandwich.vim {{{
" 従来のキーマッピングを保存
nmap ds <Plug>(operator-sandwich-delete)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-query-a)
nmap dsb <Plug>(operator-sandwich-delete)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-auto-a)
nmap cs <Plug>(operator-sandwich-replace)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-query-a)
nmap csb <Plug>(operator-sandwich-replace)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-auto-a)
let g:sandwich#recipes = deepcopy(g:sandwich#default_recipes)
" runtime macros/sandwich/keymap/surround.vim
" 開きカッコを指定したときの挙動を自分好みに
let g:sandwich#recipes += [
\ {'buns': [' {', '} '], 'nesting': 1, 'match_syntax': 1,
\ 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['{']},
\
\ {'buns': [' [', '] '], 'nesting': 1, 'match_syntax': 1,
\ 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['[']},
\
\ {'buns': [' (', ') '], 'nesting': 1, 'match_syntax': 1,
\ 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['(']},
\
\ {'buns': ['\s*{', '}\s*'], 'nesting': 1, 'regex': 1,
\ 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'],
\ 'action': ['delete'], 'input': ['{']},
\
\ {'buns': ['\s*\[', '\]\s*'], 'nesting': 1, 'regex': 1,
\ 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'],
\ 'action': ['delete'], 'input': ['[']},
\
\ {'buns': ['\s*(', ')\s*'], 'nesting': 1, 'regex': 1,
\ 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'],
\ 'action': ['delete'], 'input': ['(']},
\ ]
" 日本語のカッコ
let g:sandwich#recipes += [
\ {'buns': ['(', ')'], 'nesting': 1, 'input': ['j(', 'j)', 'jp']},
\ {'buns': ['「', '」'], 'nesting': 1, 'input': ['j[', 'j]', 'jb']},
\ {'buns': ['『', '』'], 'nesting': 1, 'input': ['j{', 'j}', 'jB']},
\ {'buns': ['【', '】'], 'nesting': 1, 'input': ['j<', 'j>', 'jk']},
\ ]
" Escaped parens
let g:sandwich#recipes += [
\ {'buns': ['\{', '\}'], 'nesting': 1, 'input': ['\{', '\}']},
\ {'buns': ['\(', '\)'], 'nesting': 1, 'input': ['\(', '\)']},
\ {'buns': ['\[', '\]'], 'nesting': 1, 'input': ['\[', '\]']},
\ ]
let g:sandwich#recipes += [
\ {'buns': ['`', ' <>`_'], 'nesting': 0, 'input': ['l'], 'filetype': ['rst']},
\ {'buns': ['` <', '>`_'], 'nesting': 0, 'input': ['L'], 'filetype': ['rst']},
\ ]
" }}}
" .config/nvim/plugins/vim-textobj-user.vim {{{
call textobj#user#plugin('line', {
\ '-': {
\ 'select-a-function': 'CurrentLineA',
\ 'select-a': 'al',
\ 'select-i-function': 'CurrentLineI',
\ 'select-i': 'il',
\ },
\ })
function! CurrentLineA()
normal! 0
let head_pos = getpos('.')
normal! $
let tail_pos = getpos('.')
return ['v', head_pos, tail_pos]
endfunction
function! CurrentLineI()
normal! ^
let head_pos = getpos('.')
normal! g_
let tail_pos = getpos('.')
let non_blank_char_exists_p = getline('.')[head_pos[2] - 1] !~# '\s'
return
\ non_blank_char_exists_p
\ ? ['v', head_pos, tail_pos]
\ : 0
endfunction
call textobj#user#plugin('jbraces', {
\ 'parens': {
\ 'pattern': ['(', ')'],
\ 'select-a': 'aj)', 'select-i': 'ij)'
\ },
\ 'braces': {
\ 'pattern': ['「', '」'],
\ 'select-a': 'aj[', 'select-i': 'ij]'
\ },
\ 'double-braces': {
\ 'pattern': ['『', '』'],
\ 'select-a': 'aj{', 'select-i': 'ij}'
\ },
\ 'lenticular-bracket': {
\ 'pattern': ['【', '】'],
\ 'select-a': 'aj<', 'select-i': 'ij>'
\ },
\})
augroup rc_textobj_user
autocmd!
autocmd filetype tex call textobj#user#plugin('texquote', {
\ 'signle': {
\ 'pattern': ['`', "'"],
\ 'select-a': 'aq', 'select-i': 'iq'
\ },
\ 'double': {
\ 'pattern': ['``', "''"],
\ 'select-a': 'aQ', 'select-i': 'iQ'
\ },
\ })
augroup END
" }}}