-
Notifications
You must be signed in to change notification settings - Fork 3
/
_vimrc
3252 lines (2799 loc) · 93.7 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
if !has('gui') " {{{
finish
endif
" }}}
" neobundle {{{
" Planning to migrate to dein, after finishing migrating from vimshell to deol,
" and migrating from unite to denite, which are still working in progres.
if has('vim_starting')
set runtimepath+=~/.vimbundles/neobundle.vim
endif
call neobundle#begin(expand('~/.vimbundles'))
let g:neobundle#enable_name_conversion = 1
NeoBundle 'Shougo/neobundle.vim'
NeoBundle 'Shougo/neobundle-vim-recipes'
let s:enable_ddc = v:true
if s:enable_ddc
NeoBundle 'vim-denops/denops.vim', 'main'
NeoBundle 'vim-denops/denops-helloworld.vim', 'main'
NeoBundle 'Shougo/ddc.vim', 'main'
NeoBundle 'Shougo/ddc-ui-native', 'main'
NeoBundle 'Shougo/ddc-matcher_head', 'main'
NeoBundle 'Shougo/ddc-sorter_rank', 'main'
NeoBundle 'gamoutatsumi/ddc-sorter_ascii'
NeoBundle 'LumaKernel/ddc-file', 'main'
NeoBundle 'matsui54/ddc-buffer', 'main'
else
NeoBundle 'Shougo/deoplete.nvim', {'depends': [
\ 'roxma/nvim-yarp',
\ 'roxma/vim-hug-neovim-rpc',
\ 'Shougo/neoinclude.vim',
\ 'Shougo/neco-syntax',
\ 'Shougo/neco-vim',
\ 'Shougo/neopairs.vim']}
NeoBundle 'lighttiger2505/deoplete-vim-lsp'
endif
NeoBundle 'Shougo/denite.nvim', {'depends': [
\ 'roxma/nvim-yarp',
\ 'roxma/vim-hug-neovim-rpc']}
NeoBundle 'Shougo/ddu.vim', 'main'
NeoBundle 'Shougo/ddu-ui-ff', 'main'
NeoBundle 'Shougo/ddu-kind-file', 'main'
NeoBundle 'Shougo/ddu-filter-matcher_substring', 'main'
NeoBundle 'matsui54/ddu-source-file_external', 'main'
NeoBundle 'Shougo/unite.vim'
NeoBundle 'Shougo/unite-build'
NeoBundle 'Shougo/vimshell'
NeoBundle 'Shougo/deol.nvim', {'depends': [
\ 'zchee/deoplete-zsh']}
if has('mac')
call neobundle#local("~/.vimbundles2", {},
\ ['vimproc'])
else
NeoBundle 'Shougo/vimproc', {'build': {
\ 'windows': 'tools\\update-dll-mingw',
\ 'cygwin': 'make -f make_cygwin.mak',
\ 'mac': 'make -f make_mac.mak',
\ 'linux': 'make',
\ 'unix': 'gmake'}}
endif
NeoBundle 'Shougo/neosnippet-snippets', {'depends': 'Shougo/neosnippet'}
NeoBundle 'Shougo/context_filetype.vim'
NeoBundle 'eagletmt/ghcmod-vim'
NeoBundle 'thinca/vim-ft-clojure'
NeoBundle 'kana/vim-filetype-haskell'
NeoBundle 'kana/vim-smartchr'
NeoBundle 'cohama/lexima.vim'
NeoBundle 'vim-jp/vital.vim'
NeoBundle 'thinca/vim-ref'
NeoBundle 'veloce/vim-aldmeris'
NeoBundle 'thinca/vim-quickrun'
NeoBundle 'ujihisa/quicklearn'
NeoBundle 'thinca/vim-poslist'
NeoBundle 'trapd00r/neverland-vim-theme'
NeoBundle 'vim-scripts/sudo.vim'
NeoBundle 'eagletmt/neco-ghc'
NeoBundle 'thinca/vim-showtime'
NeoBundle 'thinca/vim-unite-history'
NeoBundle 'chikatoike/concealedyank.vim'
NeoBundle 'ujihisa/vimshell-ssh'
NeoBundle 'ujihisa/ref-hoogle'
NeoBundle 'vim-scripts/zenesque.vim'
NeoBundle 'tyru/open-browser.vim'
NeoBundle 'kossnocorp/perfect.vim'
NeoBundle 'fatih/vim-go'
NeoBundle 'kana/vim-textobj-syntax', {'depends': 'kana/vim-textobj-user'}
NeoBundle 'basyura/J6uil.vim'
NeoBundle 'thinca/vim-fontzoom'
NeoBundle 'vim-scripts/Colour-Sampler-Pack'
NeoBundleLazy 'AndrewRadev/splitjoin.vim', {
\ 'autoload': {'mappings': ['gS', 'gJ']}}
NeoBundle 'git@github.com:ujihisa/unite-ruby-require.vim.git'
NeoBundle 'osyo-manga/jplus'
NeoBundle 'deris/rengbang'
NeoBundle 'lambdalisue/gina.vim'
NeoBundle 'kamichidu/vim-unite-javaimport', {
\ 'depends': [
\ 'kamichidu/vim-javaclasspath']}
NeoBundle 'mopp/autodirmake.vim'
NeoBundle 'vim-scripts/haskell.vim'
NeoBundle 'git@github.com:ujihisa/nclipper.vim.git'
NeoBundle 'tpope/vim-surround'
NeoBundle 'vim-scripts/Rainbow-Parenthsis-Bundle'
NeoBundle 'rhysd/textobj-wiw', {'depends': 'kana/vim-textobj-user'}
NeoBundle 'ujihisa/unite-colorscheme'
NeoBundle 'ujihisa/unite-haskellimport'
NeoBundle 'tsukkee/unite-help'
NeoBundle 'ujihisa/unite-locate'
NeoBundle 'Shougo/unite-outline'
NeoBundle 'derekwyatt/vim-scala'
NeoBundle 'vim-ruby/vim-ruby'
NeoBundleLazy 'thinca/vim-painter', {
\ 'autoload': {
\ 'commands': 'PainterStart',
\ }}
NeoBundleLazy 'Shougo/javacomplete'
NeoBundle 'AndrewRadev/linediff.vim'
NeoBundle 'tyru/caw.vim'
NeoBundle 'ujihisa/ft-cmake'
NeoBundle 'ujihisa/unite-include-reversed'
NeoBundle 'itchyny/calendar.vim'
NeoBundle 'guns/vim-sexp'
NeoBundle 'Shougo/neomru.vim', {
\ 'depends': [
\ 'Shougo/unite.vim']}
NeoBundle 'jimenezrick/vimerl'
NeoBundle 'sickill/vim-monokai'
NeoBundle 'ujihisa/neoclojure.vim'
call neobundle#local("~/.vimbundles", {},
\ ['ft-mongo', 'reversi.vim'])
" NeoBundle 'rbtnn/reversi.vim'
NeoBundle 'chase/vim-ansible-yaml'
NeoBundle 'rbtnn/mario.vim', {
\ 'depends': [
\ 'rbtnn/game_engine.vim'] }
NeoBundle 'rbtnn/puyo.vim'
NeoBundle 'kmnk/vim-unite-giti'
NeoBundle 'kana/vim-operator-replace', {
\ 'depends': [
\ 'kana/vim-operator-user'] }
NeoBundle 'syngan/vim-vimlint', {
\ 'depends': 'ynkdir/vim-vimlparser'}
NeoBundle 'cohama/agit.vim'
NeoBundle 'haya14busa/incsearch.vim'
NeoBundle 'haya14busa/vim-asterisk'
NeoBundle 'thinca/vim-themis'
NeoBundle 'kana/vim-altr'
NeoBundle 'reedes/vim-colors-pencil'
NeoBundle 'yuku-t/vim-ref-ri'
NeoBundle 'elixir-lang/vim-elixir'
NeoBundle 'mhinz/vim-mix-format'
NeoBundle 'johngrib/vim-game-code-break'
NeoBundle 'mrkn/vim-cruby'
NeoBundle 'moznion/vim-ltsv'
NeoBundle 'NLKNguyen/papercolor-theme'
NeoBundle 'koron/translua-vim'
NeoBundle 'leafgarland/typescript-vim'
NeoBundle 'thinca/vim-prettyprint'
NeoBundle 'koron/iferr', {'rtp': 'vim'}
NeoBundle 'coachshea/vim-textobj-markdown'
NeoBundle 'tyru/empty-prompt.vim'
NeoBundle 'kchmck/vim-coffee-script'
NeoBundle 'MaxMEllon/vim-jsx-pretty', {'depends': 'pangloss/vim-javascript'}
NeoBundle 'prabirshrestha/vim-lsp', {'depends': 'prabirshrestha/async.vim'}
" NeoBundle 'prabirshrestha/asyncomplete.vim'
" asyncomplete does not work
NeoBundle 'mattn/vim-lsp-settings'
NeoBundle 'vim-conf-live/pres.vim'
NeoBundle 'machakann/vim-colorscheme-snowtrek'
NeoBundle 'cormacrelf/vim-colors-github'
NeoBundle 'tommcdo/vim-exchange'
NeoBundle 'thinca/vim-breadcrumbs', 'develop'
NeoBundle 'mattn/vim-notification', 'main'
NeoBundle 'hashivim/vim-terraform'
NeoBundle 'github/copilot.vim'
call neobundle#end()
filetype plugin indent on
" }}}
" vimdiff skips vimrc load {{{
if &diff
finish
endif
" }}}
" augroup ujihisa-vimrc {{{
augroup ujihisa-vimrc
autocmd!
augroup END
" }}}
" g:V {{{
if !has_key(g:, 'V')
let g:V = vital#of('vital')
call extend(g:V, g:V.import('Prelude'))
endif
" }}}
" settings {{{
set encoding=utf-8
set fileformats=unix,dos,mac
set ignorecase
set smartcase
set number
set ruler
set expandtab
set hlsearch
set splitbelow
set splitright
set switchbuf=useopen
syntax enable
set wildmode=list:longest
set list
set listchars=tab:>-,trail:-,extends:>,precedes:<
set hidden
set autoread
set notitle
set backspace=indent,eol,start
set modeline
set t_Co=256
set cmdheight=3
" https://vim-jp.org/vim-users-jp/2009/06/26/Hack-32.html
" set directory-=.
set directory=~/tmp/
" https://vim-jp.org/vim-users-jp/2010/07/19/Hack-162.html
if has('persistent_undo')
set undodir=~/.vimundo
augroup ujihisa-vimrc
autocmd BufReadPre ~/* setlocal undofile
augroup END
endif
set noequalalways
set eadirection=ver
set updatetime=500
set timeoutlen=300
set synmaxcol=700
set history=1000
set viminfo+=:1000
set display=lastline
setglobal autoindent
setglobal shiftwidth=2
setglobal tabstop=2
set nrformats+=unsigned
" Some ftplugin sets tw=78 is tw is 0. Set this to extremely high
" so that those ftplugins give up.
" bad e.g. /usr/share/vim/vim74/ftplugin/gitcommit.vim
set textwidth=9999999999999
set nobackup
set spelllang=en,cjk
" MacVim default is 5. Stupid
set scrolloff=0
" if has('balloon_eval')
" set noballooneval
" endif
" }}}
" landscape / portrait detect {{{
function! s:is_display_landscape()
return &lines * 2 < &columns
endfunction
" }}}
" mappings {{{
let g:incsearch#auto_nohlsearch = 1
command! -nargs=0 Amp execute 'normal!' printf('/\<%s\><Cr>', expand('<cword>'))
nnoremap & <Cmd>set hlsearch<Return>:Amp<Cr>
vmap p <Plug>(operator-replace)
vmap P <Plug>(operator-replace)
nnoremap -- :<C-u>e %:h<Cr>
omap <Space>p %
omap <M-9> %
nmap <Space>p %
nmap <M-9> %
vmap <Space>p %
vmap <M-9> %
nnoremap vv <C-v>
"nnoremap ]p p`[=`]
nnoremap <silent>sh <Cmd>call <SID>horizontal_move('h')<Cr>
nnoremap sj <C-w>j
nnoremap sk <C-w>k
nnoremap <silent>sl <Cmd>call <SID>horizontal_move('l')<Cr>
nnoremap <silent>H <Cmd>call <SID>horizontal_move('H')<Cr>
nnoremap sJ <C-w>J
nnoremap sK <C-w>K
nnoremap <silent>L <Cmd>call <SID>horizontal_move('L')<Cr>
nnoremap <M-l> <C-w><C-w>
nnoremap <Tab> <C-w><C-w>
" direction has to be h, l, H, or L
function! s:horizontal_move(direction) abort
execute 'wincmd' a:direction
call <SID>good_width()
endfunction
function! s:good_width()
let size = 84
if winwidth(0) < size
execute "vertical resize" size
endif
endfunction
nnoremap q <NOP>
nnoremap Q q
" for plugins rewrite j/k
nnoremap <C-j> j
nnoremap <C-k> k
nnoremap <Space>w :<C-u>write<Cr>
nnoremap <Space>q :<C-u>quit<Cr>
" nnoremap <Space>q :<C-u>hide<Cr>
nnoremap <Space>Q :<C-u>quit!<Cr>
nnoremap <Space>. <Cmd>OpenVimrcTab<Cr>
"nnoremap <Space>] <C-w>]
noremap <Space>j <C-f>
noremap <Space>k <C-b>
" undoable
inoremap <C-u> <C-g>u<C-u>
inoremap <C-w> <C-g>u<C-w>
inoremap <M-BS> <C-w>
cnoremap <M-BS> <C-w>
"nnoremap <Space>a <Nop>
nnoremap <Space>aa :<C-u>tabnew<CR>:pwd<Cr>:VimShell<Cr>
nnoremap <Space>as :<C-u>tabnew<Cr>:pwd<Cr>:call deol#start({'edit_winheight': 5, 'edit': v:true, 'start_insert': v:true, 'auto_cd': v:true})<Cr>
nnoremap <Space>av :<C-u>tabnew<CR>:cd ~/.vimbundles<Cr>:VimShell<Cr>
nnoremap <Space>an :<C-u>tabnew<CR>:cd ~/<Cr>:VimShell<Cr>
"nnoremap <Space>ac :<C-u>tabclose<CR>
nnoremap <silent> <Space>aj :<C-u>execute 'tabnext' 1 + (tabpagenr() + v:count1 - 1) % tabpagenr('$')<CR>
nnoremap <silent> <M-j> :<C-u>execute 'tabnext' 1 + (tabpagenr() + v:count1 - 1) % tabpagenr('$')<CR>
inoremap <silent> <M-j> <Esc>:execute 'tabnext' 1 + (tabpagenr() + v:count1 - 1) % tabpagenr('$')<CR>
tnoremap <M-j> <Cmd>execute 'tabnext' 1 + (tabpagenr() + v:count1 - 1) % tabpagenr('$')<CR>
nnoremap <Space>ak gT
nnoremap <M-k> gT
inoremap <M-k> <Esc>gT
tnoremap <M-k> <Cmd>tabprevious<Cr>
" Workaround for ;2u issue
tnoremap <S-space> <space>
nnoremap <M-[> :<C-u>e #<Cr>
nnoremap <M-n> :<C-u>NeoSnippetEdit -split<Cr>
nnoremap Y y$
nnoremap co zo
nnoremap cc zc
" use mark `m for <M-a>, and <M-c>
nnoremap <M-a> mmggVG
vnoremap <M-c> "+yG`m
vnoremap Y "+y
"inoremap <expr> k smartchr#one_of('k', "\<Esc>")
" memo:
" MacBook Pro Apple Keyboard (both built-in and bluetooth) Gentoo (with xmodmap?)
" Command = <A-*> and <M-*>
" inoremap <expr><Tab> TabOrCompl()
" function! TabOrCompl()
" return (col('.') == 1 || matchstr(getline('.'), '.', col('.')-2) == "\t") ? "\<C-q>\<Tab>" : "\<C-p>"
" endfunction
nnoremap <Space>s q:set filetype=
nnoremap <Space>S q:set filetype=
nnoremap <Space>sr :<C-u>set filetype=ruby<Cr>
"nnoremap <Space>sm :<C-u>set filetype=markdown<Cr>
"nnoremap <Space>sh :<C-u>set filetype=haskell<Cr>
"nnoremap <Space>sj :<C-u>set filetype=javascript<Cr>
nnoremap <Space>spp :<C-u>set filetype=php<Cr>i<?php<Cr>error_reporting(E_ERROR \| E_WARNING \| E_PARSE \| E_NOTICE \| E_STRICT);<Cr><esc>
"nnoremap <Space>shs :<C-u>set filetype=haskell<Cr>i{-# LANGUAGE OverloadedStrings #-}<Cr>import qualified Data.Text as T<Cr>import qualified Data.Text.IO as T<Cr><Cr>main = do<Cr>print $ <Esc>
nnoremap <Space>shs :<C-u>set filetype=haskell<Cr>imain = do<Cr>print $<Esc>
nnoremap <Space>ssl :<C-u>set filetype=scala<Cr>
nnoremap <Space>scl :<C-u>set filetype=clojure<Cr>
nnoremap <Space>ssh :<C-u>set filetype=sh<Cr>
nnoremap <Space>I $i
"nnoremap <Space>C $C
nnoremap X ^x
nnoremap cp Pjdd
" nnoremap // /^
nnoremap <expr> s* ':%substitute/\<' . expand('<cword>') . '\>/'
nnoremap <Space>n :<C-u>new<Cr>
nnoremap <Space>N :<C-u>call <SID>new_with_the_filetype()<Cr>
function! s:new_with_the_filetype()
let f = &filetype
new
let &filetype = f
endfunction
" visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" paste in insert mode is <C-o>p while paste in command-line mode is <C-r>".
" it's confusing.
cnoremap <C-o>p <C-r>"
cnoremap <M-v> <C-r>+
" for speedup
nnoremap /<C-o>p /<C-r>"
" filetype specific key mappings
silent nnoremap <space>M :<C-u>echo 'space-M Not defined'<Cr>
silent nnoremap <space>m :<C-u>echo 'space-m Not defined'<Cr>
" <C-g> is to swap visual mode and select mode. <C-g> is difficult to type.
" Use Alt-g instead
vnoremap <M-g>g <C-g>
snoremap <M-g>g <C-g>
nnoremap <M-g>f <C-w><C-f>
nmap <M-o> <Plug>(openbrowser-open)
vmap <M-o> <Plug>(openbrowser-open)
nmap <M-S-o> <Plug>(openbrowser-open-incognito)
vmap <M-S-o> <Plug>(openbrowser-open-incognito)
let g:openbrowser_browser_commands = [
\ {"name": 'xdg-open',
\ "args": ["{browser}", "{uri}"]}]
" yank without newlines
vnoremap gy y:<C-u>let @" = substitute(@", "\n\s\*", ' ', 'g')<Cr>
" go insert new line below directly from insert mode
inoremap <M-o> <Esc>o<Esc>
" }}}
" lexima {{{
" let g:lexima_enable_basic_rules = 0
let g:lexima_enable_basic_rules = 0
let g:lexima_enable_newline_rules = 1
let g:lexima_enable_space_rules = 0
let g:lexima_enable_endwise_rules = 0
" jlj = <Esc>
call lexima#add_rule({
\ 'at': 'jl\%#',
\ 'char': 'j',
\ 'input': '<BS><BS><Esc>'})
inoremap <expr> <Plug>(vimrc-lexima-bs) lexima#expand('<Bs>', 'i')
"}}}
" = for completion and <bs> for cancel {{{
inoremap <expr> = pumvisible() ? "\<C-n>" : '='
inoremap <M-=> =
if exists('deoplete#smart_close_popup')
imap <expr> <BS> deoplete#smart_close_popup() . "\<Plug>(vimrc-lexima-bs)"
endif
" }}}
" vimshell {{{
function! EmptyBufferP()
return expand('%') ==# '' && !&modified
endfunction
nmap <Space>v <Plug>(vimshell_split_switch)
nnoremap <Space>t :<C-u>terminal<Cr>
nnoremap <Space><Space>t :terminal<Cr><C-w>T
let g:vimshell_user_prompt = 'fnamemodify(getcwd(), ":~")'
let g:vimshell_prompt = '$ '
let g:vimshell_split_command = 'split'
let g:vimshell_scrollback_limit = 4000
let g:vimshell_interactive_update_time = 400
let g:vimshell_max_command_history = 100000 " default is 1000
let g:vimshell_editor_command = "gvim -u $VIMRUNTIME/defaults.vim -U NONE --nofork" " do not use 'gvim -g --servername=GVIM --remote-tab-wait-silent'
augroup ujihisa-vimrc
autocmd FileType vimshell call s:vimshell_local()
augroup END
function! s:vimshell_local()
imap <buffer><expr> <BS> pumvisible() ?
\ "\<C-y>\<BS>" :
\ "\<Plug>(vimshell_another_delete_backward_char)"
" to use smartinput
" iunmap <buffer> <Bs>
nmap <buffer> j <Plug>(vimshell_next_prompt)
nmap <buffer> k <Plug>(vimshell_previous_prompt)
" deleting <Plug>(vimshell_delete_previous_output)
nunmap <buffer> <C-k>
nmap <buffer> <C-S-k> <Plug>(vimshell_delete_previous_output)
inoremap <buffer> <expr><M-l> unite#sources#vimshell_history#start_complete(!0)
endfunction
if v:false
augroup ujihisa-vimrc
autocmd FileType int-* call s:vimshell_iexe() " TODO
augroup END
function! s:vimshell_iexe()
"imap <buffer> <BS> <Plug>(vimshell_int_another_delete_backward_char)
if 0 " Let's se..
nmap <buffer> j <Plug>(vimshell_int_next_prompt)
nmap <buffer> k <Plug>(vimshell_int_previous_prompt)
endif
inoremap <buffer> <expr><M-l> unite#sources#vimshell_history#start_complete(!0)
endfunction
let g:vimshell_escape_colors = [
\'#3c3c3c', '#ff6666', '#66ff66', '#ffd30a', '#1e95fd', '#ff13ff', '#1bc8c8', '#C0C0C0',
\'#686868', '#ff6666', '#66ff66', '#ffd30a', '#6699ff', '#f820ff', '#4ae2e2', '#ffffff'
\]
endif
" }}}
" tag opens in a new window {{{
function! s:tagjump_in_new_window()
execute "normal! \<C-w>s\<C-]>"
"http://d.hatena.ne.jp/thinca/20110202
"UniteWithCursorWord -immediately -no-start-insert -auto-preview -default-action=split tag
endfunction
function! s:tagjump_or_cr()
if bufname('%') == '[Command Line]' || &buftype == 'quickfix'
return "\<Cr>"
else
return "\<C-]>"
"http://d.hatena.ne.jp/thinca/20110202
"UniteWithCursorWord -immediately -no-start-insert -auto-preview tag
endif
endfunction
nnoremap <C-]> :<C-u>call <SID>tagjump_in_new_window()<Cr>
nnoremap <expr> <Cr> <SID>tagjump_or_cr()
" }}}
" unite-grep {{{
nnoremap SG :<C-u>Unite grep:. -default-action=split<Cr>
nnoremap s<M-g> :<C-u>execute 'Unite grep:.:-iR:' . expand('<cword>') . ' -default-action=split'<Cr>
nnoremap sG <Cmd>execute 'Unite grep:.:-iR:\\b' . expand('<cword>') . '\\b -default-action=split'<Cr>
nnoremap S <nop>
nnoremap sg :<C-u>Unite grep/git:. -default-action=split<Cr>
call unite#custom#source('grep', 'ignore_pattern', '\.rbs$')
" }}}
" {{{ thinca/poslist.vim
nmap <C-o> <Plug>(poslist-prev-pos)
nmap <C-i> <Plug>(poslist-next-pos)
vmap <C-o> <Plug>(poslist-prev-pos)
" }}}
" remote {{{
command! -nargs=1 RunOnVm !run_on_vm <args> %
" }}}
" Neocomplecache/Neocomplete/Deoplete {{{
" https://github.com/Shougo/deoplete.nvim/issues/1013
" set completeopt+=noselect
if !s:enable_ddc
let g:deoplete#enable_at_startup = 1
endif
" see also
" * snippets section
let g:necoghc_enable_detailed_browse = 1
if !s:enable_ddc
function! s:my_cr_function() abort
return deoplete#close_popup() . "\<CR>"
endfunction
if filereadable('/usr/local/opt/python3/bin/python3.6')
let g:python3_host_prog = '/usr/local/opt/python3/bin/python3.6'
endif
" the default fuzzy search = noise
call deoplete#custom#source('file', 'matchers', ['matcher_head'])
call deoplete#custom#source('around', 'matchers', ['matcher_head'])
call deoplete#custom#source('buffer', 'matchers', ['matcher_head'])
call deoplete#custom#source('file', 'enable_buffer_path', v:false)
call deoplete#custom#source('file', 'enable_slash_completion', v:true)
" https://ujihisa.wordpress.com/2020/01/29/how-to-prioritize-deopletes-filename-completion-higher-than-others-but-less-than-vimshell/
call deoplete#custom#source('file', 'rank', 550)
call deoplete#custom#source('vimshell', 'rank', 600)
call deoplete#custom#source('neosnippet', 'rank', 650)
" https://github.com/Shougo/deoplete.nvim/issues/955#issuecomment-477841695
" let g:deoplete#enable_profile = 1
" call deoplete#enable_logging('DEBUG', 'deoplete.log')
call deoplete#custom#option('nofile_complete_filetypes', ['denite-filter', 'vimshell', 'bash'])
endif
" }}}
" thinca's local vimrc https://vim-jp.org/vim-users-jp/2009/12/27/Hack-112.html {{{
" Load settings for eacy location.
augroup ujihisa-vimrc
autocmd BufNewFile,BufReadPost * call s:vimrc_local(expand('<afile>:p:h'))
augroup END
function! s:vimrc_local(loc)
let files = findfile('.vimrc.local', escape(a:loc, ' ') . ';', -1)
for i in reverse(filter(files, 'filereadable(v:val)'))
source `=i`
endfor
endfunction
" }}}
function! OpenVimrcTab() " {{{
tabnew
cd ~/git/config
edit ~/git/config/_vimrc
endfunction
" }}}
" My commands {{{
command! -nargs=0 OpenVimrcTab call OpenVimrcTab()
" }}}
command! SplitNicely call s:split_nicely() " {{{
function! s:split_nicely()
if 80*2 * 15/16 <= winwidth(0) " FIXME: threshold customization
vsplit
else
split
endif
endfunction
" }}}
" unite {{{
if globpath(&rtp, 'plugin/unite.vim') != ''
nnoremap s <Nop>
nnoremap sS :<C-u>Unite file_rec -default-action=split -direction=rightbelow<Cr>
" nnoremap ss :<C-u>Unite file_rec/git file -default-action=split -direction=rightbelow -hide-source-names<Cr>
nnoremap se :<C-u>Unite file_rec/async<Cr>
nnoremap so :<C-u>Unite outline -auto-preview -buffer-name=outline<Cr>
nnoremap sC :<C-u>Unite colorscheme -auto-preview<Cr>
nnoremap sf :<C-u>UniteWithBufferDir file_rec -default-action=split<Cr>
nnoremap sm :<C-u>Unite file_mru -default-action=split<Cr>
nnoremap sb :<C-u>Unite buffer -default-action=split<Cr>
nnoremap sre :<C-u>Unite ref/man ref/hoogle ref/pydoc -default-action=split<Cr>
nnoremap su :<C-u>Unite history/command source command<Cr>
nnoremap sp :<C-u>Unite process -no-split -buffer-name=process<Cr>
nnoremap sq :<C-u>UniteClose build<Cr>
nnoremap sr :<C-u>UniteResume<Cr>
"nnoremap <space>M :Unite -buffer-name=build -no-focus build::
"nnoremap <space>m :<C-u>write<Cr>:Unite -buffer-name=build -no-focus build:<Cr>
endif
augroup ujihisa-vimrc
autocmd GUIEnter *
\ call unite#custom#profile('default', 'context', {
\ 'vertical': 1,
\ 'no_split': !s:is_display_landscape(),
\ 'start_insert': 1})
autocmd VimResized *
\ call unite#custom#profile('default', 'context', {
\ 'vertical': 1,
\ 'no_split': !s:is_display_landscape(),
\ 'start_insert': 1})
augroup END
" I wanted to simply refer the default ignore pattern with using g:unite_source_file_rec_ignore_pattern, but unite sets it lazily.
" here I force unite defining file_rec and referes the default value.
"let s:file_rec_ignore_pattern = (unite#sources#rec#define()[0]['ignore_pattern']) . '\|\$global\|\.class$\|\<target\>'
" added "lib_managed"
if 0
let s:file_rec_ignore_pattern = (unite#sources#rec#define()[0]['ignore_pattern']) . '\|\$global\|\.class$\|\<target\>\|\<lib_managed\>'
call unite#custom#source('file_rec', 'ignore_pattern', s:file_rec_ignore_pattern)
call unite#custom#source('grep', 'ignore_pattern', s:file_rec_ignore_pattern)
else
" let s:unite_file_rec_ignore_globs = unite#sources#rec#define()[0]['ignore_globs'] + ['**/target/**', 'lib_managed']
let s:unite_file_rec_ignore_globs = ['**/target/**', 'lib_managed', '.vagrant/**']
call unite#custom#source('file_rec', 'ignore_globs', s:unite_file_rec_ignore_globs)
let s:unite_grep_ignore_globs = unite#sources#grep#define()['ignore_globs'] + ['**/target/**', 'lib_managed', '.vagrant', './log/*']
call unite#custom#source('grep', 'ignore_globs', s:unite_grep_ignore_globs)
endif
let g:unite_source_file_rec_max_cache_files = 9000
if executable('ag')
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts =
\ '-i --vimgrep --hidden --ignore ' .
\ '''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'' --ignore tags --ignore target'
let g:unite_source_grep_recursive_opt = ''
endif
"let g:unite_quick_match_table = {
" \'a' : 1, 's' : 2, 'd' : 3, 'f' : 4, 'g' : 5, 'h' : 6, 'j' : 7, 'k' : 8, 'l' : 9, ':' : 10,
" \'q' : 11, 'w' : 12, 'e' : 13, 'r' : 14, 't' : 15, 'y' : 16, 'u' : 17, 'i' : 18, 'o' : 19, 'p' : 20,
" \'1' : 21, '2' : 22, '3' : 23, '4' : 24, '5' : 25, '6' : 26, '7' : 27, '8' : 28, '9' : 29, '0' : 30,
" \}
" in other words, it just swaps : and ;
let g:unite_source_process_enable_confirm = 0
function! s:unite_my_settings()
silent! nunmap <buffer> <Up>
silent! nunmap <buffer> <Down>
silent! iunmap <buffer> <Up>
silent! iunmap <buffer> <Down>
silent! iunmap <buffer> <C-o>
silent! nunmap <buffer> <Space>
" swapping q and Q
nmap <buffer> Q <Plug>(unite_exit)
nmap <buffer> q <Plug>(unite_all_exit)
" overwrite p (preview) as print
nmap <buffer> p <Plug>(unite_print_candidate)
endfunction
augroup ujihisa-vimrc
autocmd FileType unite call s:unite_my_settings()
augroup END
" }}}
" Big {{{
"
command! Big wincmd _ | wincmd |
" }}}
if has('mac') " {{{
" Option+Arrow keys
set <xRight>=OC
set <xLeft>=OD
set <xUp>=OA
set <xDown>=OB
nnoremap <xRight> <C-w>>
nnoremap <xLeft> <C-w><LT>
nnoremap <xUp> <C-w>+
nnoremap <xDown> <C-w>-
" Arrow keys
nnoremap [C l
nnoremap [D h
nnoremap [A <C-b>
nnoremap [B <C-f>
" Shift+Arrow keys (actually I cannot use it on a terminal)
nnoremap O2C :bn<Cr>
nnoremap O2D :bp<Cr>
nnoremap O2A i上<Esc>
nnoremap O2B i下<Esc>
" arrow and arrow keys
nnoremap [B[B <C-w>j
nnoremap [A[A <C-w>k
endif " }}}
augroup RubyTrunk " {{{
autocmd!
autocmd BufWinEnter,BufNewFile ~/git/ruby/*.c setl ts=8 noexpandtab
autocmd BufWinEnter,BufNewFile ~/git/ruby/*.y setl ts=8 noexpandtab
"autocmd BufWinEnter,BufNewFile ~/rubies/src/**/*.c setl ts=8 noexpandtab
augroup END
" }}}
" quickrun for thinca {{{
let g:quickrun_no_default_key_mappings = 0 " suspend to map <leader>r
nmap <Space>r <Plug>(quickrun)
vmap <Space>r <Plug>(quickrun)
nmap <Space>R <Plug>(quickrun-op)
let g:quickrun_config = {}
let g:quickrun_config._ = {'runner': 'vimproc', 'split': 'below', 'outputter/buffer/running_mark': ':-)'}
let g:quickrun_config.coffee = {'command': '~/node_modules/.bin/coffee', 'cmdopt': '-pb'}
let g:quickrun_config.asm = {'command': 'gcc', 'exec': ['gcc %s -o ./aaaaa', './aaaaa', 'rm ./aaaaa']}
" let g:quickrun_config.textile = {
" \ 'command': 'redcloth',
" \ 'tempfile': '%{tempname()}.textile',
" \ 'exec': ['%c %s > %s:p:r.html', 'open %s:p:r.html', 'sleep 1', 'rm %s:p:r.html'] }
" let g:quickrun_config['R'] = {'command': 'R', 'exec': ['%c -s --no-save -f %s', ':%s/.\b//g']}
let g:quickrun_config['markdown'] = {'outputter': 'browser'}
let g:quickrun_config.lua = {'type': 'lua/vim'}
let g:quickrun_config.javascript = {'type': 'javascript/nodejs'}
" let s:clojure_libs = split(glob('~/.m2/repository/org/clojure/core.*/*/*.jar'), "\n")
" let g:quickrun_config.clojure = {
" \ 'type': 'clojure/concurrent_process',
" \ 'command': printf(
" \ 'java -cp %s:/usr/share/clojure-1.6/lib/clojure.jar clojure.main',
" \ join(s:clojure_libs, ':'))}
let g:quickrun_config.clojure = {
\ 'runner': 'neoclojure', 'command': 'dummy',
\ 'tempfile': '%{tempname()}.clj'}
" \ 'unnamed_projdir': '/tmp/neoclojure-quickrun'}
" let g:quickrun_config.scala = {
" \ 'cmdopt': g:quickrun#default_config.scala.cmdopt . ' -deprecation'}
" let g:quickrun_config.scala = {'type': 'scala/concurrent_process', 'command': 'scala-2.11'}
let g:quickrun_config.scala = {'type': 'scala/concurrent_process', 'command': 'sbt console'}
let g:quickrun_config.cpp = {
\ 'type': 'cpp/clang++',
\ 'cmdopt': '-std=c++11 -Wall -Wextra'}
let g:quickrun_config.jq = {
\ 'cmdopt': '.'}
" \ 'erlang': {
" \ 'command': 'escript',
" +\ 'exec': ['echo "#!escript\n%%%%! -smp enable -sname quickrun -mnesia debug verbose" > %s.tmp', 'cat %s >> %s.tmp', 'mv %s.tmp %s', '%c %s %a', ':call delete("%s.tmp")', ':call delete("%s")'],
" +\ 'tempfile': '{fnamemodify(tempname(), ":h")}/quickrun',
" \ },
" }}}
" filetype aliases https://vim-jp.org/vim-users-jp/2010/04/10/Hack-138.html {{{
augroup FiletypeAliases
autocmd!
autocmd FileType md set filetype=markdown
autocmd FileType js set filetype=javascript
augroup END
" }}}
" for gina {{{
augroup vimrc-local
autocmd FileType diff nnoremap <buffer> q :<C-u>quit<Cr>
autocmd FileType git nnoremap <buffer> q :<C-u>quit<Cr>
autocmd FileType gina-branch nmap <buffer> <Return> <Plug>(gina-commit-checkout-track)
autocmd FileType gina-branch nmap <buffer> dd <Plug>(gina-branch-delete)
augroup END
" nnoremap <Space>gd :<C-u>execute 'Gina diff --opener=vsplit' expand('%')<Cr>
nnoremap <Space>gd :<C-u>Gina diff --no-prefix --opener=vsplit<Cr>
nnoremap <Space>gD :<C-u>Gina diff --no-prefix --cached --opener=vsplit<Cr>
nnoremap <Space>gs :<C-u>Gina status --opener=vsplit<Cr>
nnoremap <Space>gh :<C-u>Gina show --opener=vsplit<Cr>
nnoremap <Space>gH :<C-u>Gina show HEAD^ --opener=vsplit<Cr>
nnoremap <silent> <Space>ga :<C-u>Gina add %:p<Cr>
nnoremap <Space>gc :<C-u>Gina commit --verbose --opener=vsplit<Cr>
nnoremap <Space>gp :<C-u>Gina!! push -u
nnoremap <Space>go :<C-u>Gina changes HEAD --opener=vsplit<Cr>
nnoremap <Space>gO :<C-u>Gina changes HEAD~ --opener=vsplit<Cr>
nnoremap <Space>gb :<C-u>Gina branch -a --opener=vsplit<Cr>
" Add "--opener=vsplit" to branch/changes/grep/log
call gina#custom#command#option(
\ '/\%(branch\|changes\|grep\|log\)',
\ '--opener', 'vsplit'
\)
call gina#custom#mapping#nmap(
\ 'branch', '<BS>',
\ '<Plug>(gina-branch-delete)'
\)
call gina#custom#mapping#nmap(
\ 'branch', '<S-BS>',
\ '<Plug>(gina-branch-delete-force)'
\)
" }}}
" html {{{
function! s:HtmlEscape()
silent s/&/\&/eg
silent s/</\</eg
silent s/>/\>/eg
endfunction
function! s:HtmlUnEscape()
silent s/</</eg
silent s/>/>/eg
silent s/&/\&/eg
endfunction
vnoremap <silent> <space>e :call <SID>HtmlEscape()<CR>
vnoremap <silent> <space>ue :call <SID>HtmlUnEscape()<CR>
" disable stupid htmlcomplete
augroup ujihisa-vimrc
autocmd FileType html setlocal omnifunc=
augroup END
" }}}
" kana's useful tab function {{{
function! s:move_window_into_tab_page(target_tabpagenr)
" Move the current window into a:target_tabpagenr.
" If a:target_tabpagenr is 0, move into new tab page.
if a:target_tabpagenr < 0 " ignore invalid number.
return
endif
let original_tabnr = tabpagenr()
let target_bufnr = bufnr('')
let window_view = winsaveview()
if a:target_tabpagenr == 0
tabnew
tabmove " Move new tabpage at the last.
execute target_bufnr 'buffer'
let target_tabpagenr = tabpagenr()
else
execute a:target_tabpagenr 'tabnext'
let target_tabpagenr = a:target_tabpagenr
topleft new " FIXME: be customizable?
execute target_bufnr 'buffer'
endif
call winrestview(window_view)
execute original_tabnr 'tabnext'
if 1 < winnr('$')
close
else
enew
endif
execute target_tabpagenr 'tabnext'
endfunction " }}}
" <space>ao move current buffer into a new tab. {{{
"nnoremap <silent> <Space>ao :<C-u>call <SID>move_window_into_tab_page(0)<Cr>
nnoremap <silent> <Space>ao <C-w>T
" }}}
" open lib and corresponding test at a new tab {{{
command! -nargs=1 Lib call s:open_lib_and_corresponding_test(<f-args>)
function! s:open_lib_and_corresponding_test(fname)
execute 'tabnew lib/' . a:fname . '.rb'
execute 'vnew spec/' . a:fname . '_test.rb'
execute "normal \<Plug>(quickrun)\<C-w>J\<C-w>7_"
endfunction " }}}
" gist.vim {{{
let g:gist_clip_command = 'xclip -selection clipboard'
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
" }}}
command! LeftSpace call s:left_space() " {{{
function! s:left_space()
let bufname = printf('[leftspace:%s]', tabpagenr())
let bufnr = bufnr(bufname) " FIXME: escape.
let winnr = bufwinnr(bufnr)
if winnr == -1
" create
execute "topleft 20vnew " . bufname
setlocal nomodifiable
wincmd p
else
" destroy
execute winnr "wincmd w"
wincmd c
wincmd p
endif
endfunction
" }}}
" Substitute all spaces for indentation to underlines {{{
"
" before:
" def aaa
" hi
" end
" after:
" def aaa
" __hi
" end
command! -nargs=0 LeadUnderscores %s/^\s*/\=repeat('_', strlen(submatch(0)))/g
" }}}
" Require secret password file {{{