-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
2659 lines (2138 loc) · 71.2 KB
/
vimrc
File metadata and controls
2659 lines (2138 loc) · 71.2 KB
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
" Settings {{{
" Let's make sure that all the annoying bugs in VI are not displayed in VIM.
set nocompatible
"Faster ESC timeout
set timeout ttimeoutlen=100
"Faster CursorHold and swap file writes
set updatetime=100
set title
if &term == "screen-256color"
set t_ts=]2;
set t_fs=\\
" tmux will send xterm-style keys when its xterm-keys option is on
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
endif
" formatoptions
" https://stackoverflow.com/questions/16030639/vim-formatoptions-or/23326474#23326474
augroup formatoptions
au!
autocmd BufEnter * setlocal formatoptions-=o formatoptions+=nj
augroup END
"set autoindent
set tabstop=2
set shiftwidth=2
set shiftround
set expandtab
"set spell language
set spelllang=en_ca
"set modelines enabled
set modeline
set modelines=5
"Viminfo
set viminfo+=!
"Session options
set sessionoptions=blank,buffers,curdir,folds,globals,help,tabpages,winsize
"Enable mouse
set mouse=a
"Disable right-click popup menu
set mousemodel=extend
"Wrap at start/end of line
set whichwrap+=<,>,[,],h,l
"Disable folding by default
set foldmethod=manual
set foldlevel=999
"Custom Fold Text
set foldtext=CustomFoldText()
fu! CustomFoldText()
"modified from http://www.gregsexton.org/2011/03/improving-the-text-displayed-in-a-fold/
let fs = v:foldstart
while getline(fs) =~ '^\s*$'
let fs = nextnonblank(fs + 1)
endwhile
if fs > v:foldend
let line = getline(v:foldstart)
else
let line = substitute(getline(fs), '\t', repeat(' ', &tabstop), 'g')
endif
let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0)
let foldSize = 1 + v:foldend - v:foldstart
let foldSizeStr = " " . foldSize . " lines "
let foldLevelStr = repeat("+--", v:foldlevel)
let lineCount = line("$")
let foldPercentage = printf("[%.1f", (foldSize*1.0)/lineCount*100) . "%] "
let foldchar = matchstr(&fillchars, 'fold:\zs.')
let expansionString = ' ' . repeat(foldchar, w - strwidth(foldSizeStr.line.foldLevelStr.foldPercentage) - 1)
return line . expansionString . foldSizeStr . foldPercentage . foldLevelStr
endf
"Remove toolbar from GUI vim
set winaltkeys=no
set guioptions-=Te
if has("gui_macvim")
set macmeta
set guifont=Droid_Sans_Mono_for_Powerline:h10
elseif exists('neovim_dot_app')
call MacSetFont('Droid Sans Mono for Powerline', 10)
elseif has("gui_gtk2")
set guifont=Ubuntu\ Mono\ derivative\ Powerline\ 9
endif
"Let VIM figure out the indentation neede in C-style programs - when it can.
set smartindent
set autoindent
set copyindent
"VIM will show the corresponding opening and closing curly brace, bracket or parentesis.
set showmatch
set matchtime=1
"Show incomplete command
set showcmd
"Needed by nvim-cmp
set completeopt=menu,menuone,noselect
"Display the status bar at the bottom
set ruler
"Faster drawing... apparently...
set lazyredraw
"Mostly for a better maximizer
set winminwidth=0
set winminheight=0
"Error bell
set noerrorbells
set visualbell
set t_vb=
"Show cursorline
set cursorline
"Command tab completion behaviour
set wildmode=longest:full,full
"Match words as we type a search string. We may be able to find the word we are looking for before being done typing.
set incsearch
"Highlight matched search
set hlsearch
"Don't wrap to top/bottom of file when searching
set nowrapscan
"Default global substitute
set gdefault
"Be smart about character case while searching
set ignorecase
set smartcase
"Line numbers
set number
set relativenumber
"Add matching pairs for %
set matchpairs+=<:>
"Backspace behaviour
set backspace=indent,eol,start
"Directories
set directory^=~/.vim/swaps//
set backupdir^=~/.vim/backups//
set undodir=~/.vim/undodir//
"Persistent undo file
set undofile
"Syntax highlighting
syntax on
"File type detection and plugin loading
filetype plugin indent on
"Mode is shown in status bar
set noshowmode
"Scroll offset
set scrolloff=5
"Split pane to right when :vsplit
set splitright
"Don't highlight long lines
set synmaxcol=800
"What to show in character list
set list
set listchars=tab:▸\ ,extends:❯,precedes:❮
set showbreak=↪
if has('nvim')
" preview of commands
set inccommand=split
" Alpha blending for pum and floating windows
set pumblend=20
set winblend=20
"Allow up to 3 characters for the sign column
set signcolumn=auto:3
endif
"Paste from system clipboard
set clipboard=unnamed,unnamedplus
"Auto read file changes
set autoread
"Set leader character
let mapleader = "\<Space>"
let maplocalleader = "\\"
"Default filetype=sh to bash syntax
let is_bash=1
if filereadable(expand('~/.venv/bin/python'))
let g:python3_host_prog = '~/.venv/bin/python'
endif
if filereadable(expand('~/.rbenv/shims/ruby'))
let g:ruby_host_prog = '~/.rbenv/shims/ruby'
endif
"}}} Settings
" Plugins {{{
call plug#begin('~/.vim/bundle')
"" File Navigation and Search {{{
Plug 'kkoomen/gfi.vim'
Plug 'thinca/vim-visualstar'
Plug 'dyng/ctrlsf.vim'
let g:ctrlsf_auto_close = 0
let g:ctrlsf_default_view_mode = 'compact'
let g:ctrlsf_populate_qflist = 1
let g:ctrlsf_indent = 2
let g:ctrlsf_winsize = "30%"
let g:ctrlsf_compact_winsize = "30%"
let g:ctrlsf_auto_focus = {
\ "at": "start",
\ }
let g:ctrlsf_mapping = {
\ "split": "<C-S>" ,
\ "vsplit": "<C-V>" ,
\ "tab": { "key": [ "<C-T>" ], "suffix": ":CtrlSFOpen<CR>" },
\ "next": "n",
\ "prev": "N",
\ "fzf" : "<C-f>",
\ }
nmap <leader>c <Plug>CtrlSFPrompt
nnoremap <expr> <leader>C ':CtrlSF ' . ctrlsf#opt#GetOpt("pattern")
vmap <leader>c <Plug>CtrlSFVwordPath
nnoremap <silent> <leader>/c :call <SID>CtrlSFSetSearch()<CR>
function! s:CtrlSFSetSearch()
let @/=ctrlsf#pat#Regex()
call histadd('search', @/)
endfunction
function! g:CtrlSFAfterMainWindowInit()
nnoremap <silent><buffer> <CR> :call <SID>CtrlSFOpenWithPreviousWindow()<CR>
nnoremap <silent><buffer> <C-CR> :call <SID>CtrlSFChooseWindowOpen()<CR>
nnoremap <silent><buffer> ] :call <SID>CtrlSFNextFile('')<CR>
nnoremap <silent><buffer> [ :call <SID>CtrlSFNextFile('b')<CR>
nnoremap <silent><buffer> n :call <SID>CtrlSFNextMatch(1)<CR>
nnoremap <silent><buffer> N :call <SID>CtrlSFNextMatch(0)<CR>
endfunction
function! s:CtrlSFNextMatch(forward)
if @/ == ""
call ctrlsf#NextMatch(a:forward)
return
endif
exec "normal! " . 'Nn'[a:forward]
endfunction
function! s:CtrlSFNextFile(flags)
let curline = getline('.')
let curfile = strpart(curline, 0, stridx(curline, '|'))
call search('^\%(' . curfile . '\)\@!', a:flags)
endfunction
function! s:CtrlSFOpenWithPreviousWindow()
let [file, line, match] = ctrlsf#view#Locate(line('.'))
if empty(file) || empty(line)
return
endif
if g:ctrlsf_confirm_unsaving_quit && !ctrlsf#buf#WarnIfChanged()
return
endif
wincmd p
if bufname('%') !=# file
if &modified && !&hidden
exec 'silent vertical split ' . fnameescape(file)
else
exec 'silent edit ' . fnameescape(file)
endif
endif
let lnum = line.lnum
let col = empty(match)? 0 : match.col
call ctrlsf#win#MoveCursorCentral(lnum, col)
if g:ctrlsf_selected_line_hl =~ 'o'
call ctrlsf#hl#HighlightSelectedLine()
endif
endfunction
function! s:CtrlSFChooseWindowOpen()
let [file, line, match] = ctrlsf#view#Locate(line('.'))
if empty(file) || empty(line)
return
endif
if g:ctrlsf_confirm_unsaving_quit && !ctrlsf#buf#WarnIfChanged()
return
endif
let winnr = input("Window: ")
if !winnr
return
endif
execute winnr . "wincmd w"
if bufname('%') !=# file
if &modified && !&hidden
exec 'silent vertical split ' . fnameescape(file)
else
exec 'silent edit ' . fnameescape(file)
endif
endif
let lnum = line.lnum
let col = empty(match)? 0 : match.col
call ctrlsf#win#MoveCursorCentral(lnum, col)
if g:ctrlsf_selected_line_hl =~ 'o'
call ctrlsf#hl#HighlightSelectedLine()
endif
endfunction
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
nnoremap <C-p> :Files<CR>
nnoremap <leader>gg :call fzf#vim#gitfiles("?", fzf#vim#with_preview({'dir': getcwd(-1), 'placeholder': ''}), 0)<CR>
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit'
\ }
let g:fzf_layout = {
\ 'window': 'call FloatingFZF()'
\ }
fun! FloatingFZF()
let width = float2nr(&columns * 0.8)
let height = float2nr(&lines * 0.4)
let opts = {
\ 'relative': 'editor',
\ 'row': (&lines - height) / 5,
\ 'col': (&columns - width) / 2,
\ 'width': width,
\ 'height': height,
\ 'style': 'minimal'
\ }
" Just hacking, don't think this works...
let g:ss_last_win = get(g:, 'ss_win')
let g:ss_win = nvim_open_win(nvim_create_buf(v:false, v:true), v:true, opts)
tnoremap <buffer> <c-g> <cmd>call fzf#vim#gitfiles("?", fzf#vim#with_preview({'dir': getcwd(-1), 'placeholder': ''}), 0)<CR><cmd>call win_execute(g:ss_last_win, 'close')<CR>
tnoremap <buffer> <c-b> <cmd>call win_execute(g:ss_last_win, 'close')<CR>
endf
" TODO port these over to FZF?
" function! s:CtrlPEnter()
" nnoremap <buffer> <c-y> :call <SID>CtrlPYank()<CR>
" nnoremap <buffer> <c-p> :call <SID>CtrlPPaste()<CR>
" endfunction
"
" function! s:CtrlPYank()
" let lines = <SID>CtrlPGetLines()
"
" if empty(lines)
" return
" endif
"
" let @* = join(lines, "\n")
" endfunction
"
" function! s:CtrlPPaste()
" let lines = <SID>CtrlPGetLines()
"
" if empty(lines)
" return
" endif
"
" exec "normal! a" . join(lines, "\n")
" endfunction
"
" function! s:CtrlPGetLines()
" echo "What modifier? (a|r|i)"
"
" let modify = nr2char(getchar())
"
" if modify == nr2char(27) "escape
" call feedkeys("\<c-e>") " redraw CtrlP prompt
" return
" endif
"
" let lines = []
" let marked = ctrlp#getmarkedlist()
"
" if !empty(marked)
" let lines = values(marked)
" else
" let lines = [ctrlp#getcline()]
" en
"
" cal ctrlp#exit()
"
" call map(lines, {idx, val -> <SID>CtrlPYankFormat(val, modify)})
"
" return lines
" endfunction
"
" let g:ctrlp_yank_path = ''
"
" function! s:CtrlPYankFormat(val, mod)
" if a:mod == "a" || a:mod == "\<c-a>"
" return fnamemodify(a:val, ':p')
" elseif a:mod == "r" || a:mod == "\<c-r>"
" let g:ctrlp_yank_path = fnamemodify(a:val, ':p')
" return <SID>PyEval("os.path.relpath(vim.eval('g:ctrlp_yank_path'), os.path.dirname(vim.current.buffer.name))")
" elseif a:mod == "i" || a:mod == "\<c-i>"
" let g:ctrlp_yank_path = fnamemodify(a:val, ':p')
" let path = <SID>PyEval("os.path.relpath(vim.eval('g:ctrlp_yank_path'), os.path.dirname(vim.current.buffer.name))")
" if path !~ '^\.\.\/'
" let path = "./" . path
" endif
" return fnamemodify(path, ':r')
" endif
"
" return a:val
" endfunction
"
" function! s:PyEval(script)
" if has('python3')
" return py3eval(a:script)
" endif
"
" return pyeval(a:script)
" endfunction
" Plug 'mattn/ctrlp-register'
" nnoremap <leader>pr :CtrlPRegister<CR>
" Plug 'shanesmith/ctrlp-filetype'
" nnoremap <leader>pf :CtrlPFiletype<CR>
" Plug 'nixprime/cpsm', { 'do': 'brew install cmake boost && ./install.sh' }
" Plug 'fisadev/vim-ctrlp-cmdpalette'
Plug 'lambdalisue/fern.vim'
Plug 'lambdalisue/fern-git-status.vim'
Plug 'lambdalisue/fern-hijack.vim'
Plug 'lambdalisue/fern-mapping-git.vim'
Plug 'LumaKernel/fern-mapping-fzf.vim'
let g:fern#renderer#default#leaf_symbol = " "
let g:fern#renderer#default#collapsed_symbol = "▸ "
let g:fern#renderer#default#expanded_symbol = "▾ "
let g:fern#disable_default_mappings = 1
let g:fern#scheme#file#show_absolute_path_on_root_label = 1
highlight link FernGitStained Special
highlight link FernGitModified Special
highlight link FernGitUnmerged Special
highlight link FernGitStaged Type
highlight link FernGitCleaned Type
nnoremap <silent> <C-t> :Fern . -reveal=%<CR>
nnoremap <silent> <leader>tf :Fern . -reveal=%<CR>
nnoremap <silent> <leader>tv :Fern . -reveal=% -opener=vsplit<CR>
nnoremap <silent> <leader>ts :Fern . -reveal=% -opener=split<CR>
nnoremap <silent> <leader>ty :Fern . -reveal=% -opener=tabedit<CR>
command! -nargs=* VFern Fern -opener=vsplit <args>
command! -nargs=* SFern Fern -opener=split <args>
command! -nargs=* TFern Fern -opener=tabedit <args> | call fern#action#call("tcd:root")
function! s:init_fern() abort
nmap <buffer><nowait> h <Plug>(fern-action-collapse)
nmap <buffer><nowait> l <Plug>(fern-action-open-or-expand)
nmap <buffer><nowait> I <Plug>(fern-action-hidden:toggle)
nmap <buffer><nowait> u <Plug>(fern-action-leave)
nmap <buffer><nowait> c <Plug>(fern-action-enter)
nmap <buffer><nowait> C <Plug>(fern-action-tcd:root)
nmap <buffer><nowait> r <Plug>(fern-action-reload)
nmap <buffer><nowait> s <Plug>(fern-action-open:split)
nmap <buffer><nowait> v <Plug>(fern-action-open:vsplit)
nmap <buffer><nowait> t <Plug>(fern-action-open:tabedit)<Plug>(fern-action-tcd)
nmap <buffer><nowait> A <Plug>(fern-action-new-path)
nmap <buffer><nowait> dd <Plug>(fern-action-remove)
nmap <buffer><nowait> yy <Plug>(fern-action-clipboard-copy)
nmap <buffer><nowait> xx <Plug>(fern-action-clipboard-move)
nmap <buffer><nowait> p <Plug>(fern-action-clipboard-paste)
nmap <buffer><nowait> <Tab> <Plug>(fern-action-mark)j
nmap <buffer><nowait> <S-Tab> <Plug>(fern-action-mark)k
nmap <buffer><nowait> << <Plug>(fern-action-git-stage)
nmap <buffer><nowait> >> <Plug>(fern-action-git-unstage)
nmap <buffer><nowait> <C-c> <Plug>(fern-action-cancel)
vmap <buffer><nowait> <Tab> <Plug>(fern-action-mark)
vmap <buffer><nowait> dd <Plug>(fern-action-mark)<Plug>(fern-action-remove)
vmap <buffer><nowait> yy <Plug>(fern-action-mark)<Plug>(fern-action-clipboard-copy)
vmap <buffer><nowait> xx <Plug>(fern-action-mark)<Plug>(fern-action-clipboard-move)
nmap <buffer><nowait> R <Plug>(fern-action-fzf-root-dirs)
nmap <buffer><nowait> <C-g> <Plug>(fern-action-fzf-root-dirs)
nmap <buffer><nowait> P <Plug>(fern-action-focus:parent)
nmap <buffer><nowait> Y <Plug>(fern-action-yank:label)
nmap <buffer><nowait> yp <Plug>(fern-action-yank:path)
" nmap <buffer><silent> <Plug>(fern-action-search) <Plug>(fern-action-ex=)CtrlSF<Space>
nnoremap <buffer><silent> <Plug>(fern-action-search) :<C-u>call <SID>FernSearch()<CR>
nmap <buffer><nowait> S <Plug>(fern-action-search)
endfunction
let g:Fern_mapping_fzf_file_sink = { dict -> execute(printf("FernReveal %s", dict.relative_path)) }
let g:Fern_mapping_fzf_dir_sink = { dict -> execute(printf("FernReveal %s", dict.relative_path)) }
function! s:FernSearch() abort
let helper = fern#helper#new()
if helper.sync.get_scheme() !=# 'file'
throw printf("can only search in 'file' scheme")
endif
let path = helper.sync.get_cursor_node()._path
" when search is initiated through an action choice ('a' keymap) it ends up
" being run with `normal`, in which case feedkeys() won't work, so we break
" it out with an async call.... seems hacky, but it works!
call timer_start(0, { -> feedkeys(":CtrlSF '" . path . "'\<Home>\<C-Right>\<Right>", 'n') })
endfunction
function! s:VimEnterFern()
if exists("s:std_in") || !exists(":Fern")
return
endif
if argc() != 0
if isdirectory(argv(0))
exec "cd" argv(0)
exec "tcd" argv(0)
else
return
endif
endif
Fern . -wait
endfunction
augroup my-fern
autocmd! *
autocmd FileType fern call s:init_fern()
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * ++nested call <SID>VimEnterFern()
augroup END
Plug 'henrik/vim-qargs'
Plug 'chrisbra/Recover.vim'
Plug 'francoiscabrol/ranger.vim'
nnoremap <C-f> :Ranger<CR>
Plug 'rbgrouleff/bclose.vim'
Plug 'tpope/vim-projectionist'
nnoremap <leader>aa :A<CR>
nnoremap <leader>av :AV<CR>
nnoremap <leader>as :AS<CR>
function! s:alternates() abort
let alternates = projectionist#query_file('alternate', {})
let source = []
for path in alternates
call add(source, fnamemodify(path, ':~:.'))
endfor
let options = { 'source': source }
call fzf#run(fzf#wrap('Alternates', options))
endfunction
comm! Alternates :call s:alternates()
"}}}
"" Utilities {{{
Plug 'inkarkat/vim-ingo-library'
Plug 'axvr/zepl.vim'
nmap <silent> gZ gziE
" TODO update to use g:repl_config
augroup zepl
autocmd!
autocmd FileType python let b:repl_config = { 'cmd': 'python3' }
autocmd FileType javascript let b:repl_config = { 'cmd': 'node' }
autocmd FileType clojure let b:repl_config = { 'cmd': 'clj' }
autocmd FileType scheme let b:repl_config = { 'cmd': 'rlwrap csi' }
autocmd FileType lisp let b:repl_config = { 'cmd': 'sbcl' }
autocmd FileType julia let b:repl_config = { 'cmd': 'julia' }
autocmd FileType ruby let b:repl_config = { 'cmd': 'irb' }
augroup END
command! -nargs=? -complete=syntax REPL call <SID>NewRepl(<f-args>)
function! s:NewRepl(...)
let type = a:0 ? a:1 : &ft
exe 'tab Scratch' type
call zepl#start('', 'vert')
stopinsert
wincmd p
endfunction
" Plug 'lambdalisue/gin.vim'
Plug 'tpope/vim-fugitive'
command! GResolve Gwrite | Git mergetool
command! GB execute line('.') . "GBrowse %"
Plug 'rhysd/git-messenger.vim'
nnoremap <leader>gb :GitMessenger<CR>
let g:git_messenger_always_into_popup = 1
let g:git_messenger_floating_win_opts = { 'border': 'rounded' }
function! s:setup_gitmessengerpopup() abort
nmap <buffer> <C-o> o
nmap <buffer> <C-i> O
nmap <buffer> < o
nmap <buffer> > O
endfunction
autocmd FileType gitmessengerpopup call <SID>setup_gitmessengerpopup()
Plug 'tpope/vim-rhubarb'
Plug 'vim-utils/vim-husk'
cnoremap <expr> <M-Left> husk#left()
cnoremap <expr> <M-Right> husk#right()
Plug 'shanesmith/vim-rest-console'
let g:vrc_trigger = '<C-R>'
let g:vrc_show_command = 1
let g:vrc_curl_opts = {
\ '--include': '',
\ '--silent': '',
\ '--show-error': ''
\ }
let g:vrc_auto_format_response_patterns = {
\ 'json': 'jq .'
\ }
let g:vrc_body_preprocessor = 'maybe-dotenv --ignore yq --indent 0 -o json ''(.. | select(tag == "!!str")) |= envsubst(nu)'''
let g:vrc_header_preprocessor = 'sed "s/.*/\"&\"/" | maybe-dotenv --ignore yq ". | envsubst"'
command! RESTTab call <SID>rest_tab()
function! s:rest_tab()
tabnew
setf rest
call append(0, [
\ "# http://example.com",
\ "# Content-Type: application/json",
\ "# POST /foo/bar",
\ "# {\"key\": \"value\"}",
\ "#",
\ "# Ctrl-R to run the query",
\ ""
\ ])
endfunction
"TODO deprecated, check out https://github.com/mg979/vim-visual-multi
" Plug 'terryma/vim-multiple-cursors'
let g:multi_cursor_exit_from_visual_mode = 0
let g:multi_cursor_exit_from_insert_mode = 0
Plug 'mg979/vim-visual-multi'
let g:VM_leader = 'vm'
function! VM_Start()
nnoremap <silent> <Plug>(VM-Exit) :if g:Vm.extend_mode \| call b:VM_Selection.Global.cursor_mode() \| else \| noh \| call vm#reset() \| endif<CR>
endfunction
Plug 'tpope/vim-eunuch'
let g:eunuch_no_maps = 1
Plug 'rhysd/committia.vim'
let g:committia_open_only_vim_starting = 0
let g:committia_hooks = {}
function! g:committia_hooks.diff_open(info)
setlocal number
endfunction
Plug 'AndrewRadev/switch.vim'
let g:switch_mapping = "-"
" TODO handle generics
" const xyzzy = <T>(foo: T): baz => qq
" function xyzzy<T>(foo: T): baz => qq
let g:switch_custom_definitions =
\ [
\ ['left', 'right'],
\ ['top', 'bottom'],
\ ['padding', 'margin'],
\ ['absolute', 'relative', 'fixed'],
\ ['public', 'private', 'protected'],
\ {
\ '\(async \)\?function\s*\(\k\+\)\s*(\([^()]\{-}\))\s*:\s*\([^{]\{-1,}\)\s*{': 'const \2 = \1(\3): \4 => {',
\ '\%(var \|let \|const \)\?\(\k\+\)\s*=\s*\(async \)\?(\([^()]\{-}\))\s*:\s*\([^}]\{-1,}\)\s*=>\s*{': '\2function \1(\3): \4 {',
\ },
\ ]
autocmd FileType ruby let b:switch_definitions =
\ [
\ g:switch_builtins.ruby_hash_style,
\ g:switch_builtins.ruby_oneline_hash,
\ g:switch_builtins.ruby_lambda,
\ g:switch_builtins.rspec_should,
\ g:switch_builtins.rspec_expect,
\ g:switch_builtins.rspec_to,
\ g:switch_builtins.rspec_be_truthy_falsey,
\ g:switch_builtins.ruby_string,
\ g:switch_builtins.ruby_short_blocks,
\ g:switch_builtins.ruby_array_shorthand,
\ g:switch_builtins.ruby_fetch,
\ g:switch_builtins.ruby_assert_nil,
\ ['if', 'unless'],
\ ]
autocmd FileType javascript,typescript,javascriptreact,typescriptreact let b:switch_custom_definitions =
\ [
\ ['test.only(', 'test.skip(', 'test('],
\ ['it.only(', 'it.todo(', 'it('],
\ ]
Plug 'lfilho/cosco.vim'
autocmd FileType javascript,typescript.tsx,typescript,typescriptreact,php,css,scss,java,c,cpp nnoremap <buffer> <silent> ;; :call <SID>custom_cosco()<CR>
autocmd FileType javascript,typescript.tsx,typescript,typescriptreact,php,css,scss,java,c,cpp vnoremap <buffer> <silent> ;; :call cosco#commaOrSemiColon()<CR>
autocmd FileType javascript,typescript.tsx,typescript,typescriptreact,php,css,scss,java,c,cpp inoremap <buffer> <silent> ;; <C-o>:call <SID>custom_cosco()<CR>
function! s:custom_cosco()
let travel = 0
if match(getline('.'), '^\s*$') != -1
let travel = 1
normal! mz
normal! }(
endif
call cosco#commaOrSemiColon()
if travel
normal! `z
delm z
endif
endfunction
Plug 'tpope/vim-unimpaired'
nmap <silent> [p =P
nmap <silent> ]p =p
" TODO update unimpaired plugin?
if exists(":cabove")
nnoremap ]l :<C-u>exec (v:count ? v:count : "")."lbelow"<CR>zv
nnoremap [l :<C-u>exec (v:count ? v:count : "")."labove"<CR>zv
nnoremap ]q :<C-u>exec (v:count ? v:count : "")."cbelow"<CR>zv
nnoremap [q :<C-u>exec (v:count ? v:count : "")."cabove"<CR>zv
endif
" UnconditionalPaste style character or line wise forced paste
function! s:CharPaste(p, ...)
let register = a:0 ? a:1 : v:register
let l:original_reg = getreg(register)
let l:original_reg_type = getregtype(register)
let l:stripped_reg = substitute(l:original_reg, '\v^%(\n|\s)*(.{-})%(\n|\s)*$', '\1', '')
call setreg(register, l:stripped_reg, 'c')
exe 'normal "' . register . a:p
call setreg(register, l:original_reg, l:original_reg_type)
endfunction
function! s:LinePaste(p, ...)
let register = a:0 ? a:1 : v:register
let l:original_reg = getreg(register)
let l:original_reg_type = getregtype(register)
call setreg(register, l:original_reg, 'l')
exe 'normal "' . register . a:p
call setreg(register, l:original_reg, l:original_reg_type)
endfunction
nnoremap <silent> gcp :<c-u>call <SID>CharPaste('p')<cr>
nnoremap <silent> gcP :<c-u>call <SID>CharPaste('P')<cr>
nnoremap <silent> glp :<c-u>call <SID>LinePaste('p')<cr>
nnoremap <silent> glP :<c-u>call <SID>LinePaste('P')<cr>
Plug 'KabbAmine/lazyList.vim'
Plug 'machakann/vim-sandwich'
" disables ib,ab, is and as object mappings so that the tagets plugin can handle them
let g:textobj_sandwich_no_default_key_mappings = 1
" disables sdb and srb, but also sd and sr so we need to redefine them
let g:sandwich_no_default_key_mappings = 1
let g:sandwich#recipes = [
\ {
\ 'buns': ['(', ')'],
\ 'nesting': 1,
\ 'match_syntax': 1,
\ 'input': ['(', 'b'],
\ },
\ {
\ 'buns': ['{', '}'],
\ 'nesting': 1,
\ 'match_syntax': 1,
\ 'skip_break': 1,
\ 'input': ['{', 'B'],
\ },
\ {
\ 'buns': ['#{', '}'],
\ 'nesting': 1,
\ 'match_syntax': 1,
\ 'skip_break': 1,
\ 'input': ['#{'],
\ },
\ {
\ 'buns': ['${', '}'],
\ 'nesting': 1,
\ 'match_syntax': 1,
\ 'skip_break': 1,
\ 'input': ['${'],
\ },
\ {
\ 'external': ['iq', 'aq'],
\ 'noremap': 0,
\ 'action': ['delete'],
\ 'input': ['q']
\ },
\ ]
" Include preceding objects in function (ie: foo.bar())
let g:sandwich#magicchar#f#patterns = [
\ {
\ 'header' : '\<\%(\h\k*\.\)*\h\k*',
\ 'bra' : '(',
\ 'ket' : ')',
\ 'footer' : '',
\ },
\ ]
silent! nmap <unique><silent> S <Plug>(operator-sandwich-add)
silent! xmap <unique><silent> S <Plug>(operator-sandwich-add)
silent! nmap <unique><silent> sd <Plug>(operator-sandwich-delete)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-query-a)
silent! nmap <unique><silent> sda <Plug>(operator-sandwich-delete)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-auto-a)
silent! nmap <unique><silent> sr <Plug>(operator-sandwich-replace)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-query-a)
silent! nmap <unique><silent> sra <Plug>(operator-sandwich-replace)<Plug>(operator-sandwich-release-count)<Plug>(textobj-sandwich-auto-a)
omap S <Plug>(textobj-sandwich-query-a)
xmap is <Plug>(textobj-sandwich-query-i)
xmap as <Plug>(textobj-sandwich-query-a)
omap is <Plug>(textobj-sandwich-query-i)
omap as <Plug>(textobj-sandwich-query-a)
xmap iS <Plug>(textobj-sandwich-auto-i)
xmap aS <Plug>(textobj-sandwich-auto-a)
omap iS <Plug>(textobj-sandwich-auto-i)
omap aS <Plug>(textobj-sandwich-auto-a)
Plug 'tpope/vim-abolish'
Plug 'vim-scripts/ingo-library'
Plug 'embear/vim-localvimrc'
let g:localvimrc_sandbox=0
let g:localvimrc_persistent=1
Plug 'szw/vim-maximizer'
let g:maximizer_default_mapping_key = '<F4>'
Plug 'sjl/gundo.vim'
Plug 'dohsimpson/vim-macroeditor'
Plug 'Konfekt/vim-alias'
Plug 'meain/vim-package-info', { 'do': 'npm install' }
" TODO unmaintained, find new one?
" https://github.com/akinsho/toggleterm.nvim
" https://github.com/voldikss/vim-floaterm
Plug 'kassio/neoterm'
let g:neoterm_default_mod = 'vertical'
"}}}
"" LOLz {{{
Plug 'koron/nyancat-vim'
Plug 'shanesmith/hackertyper.vim'
Plug 'uguu-org/vim-matrix-screensaver'
Plug 'mattn/vim-starwars'
"}}}
"" Display {{{
Plug 'arcticicestudio/nord-vim'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'gf3/molotov'
Plug 'jeffkreeftmeijer/vim-dim', { 'branch': 'main' }
Plug 'vim-scripts/molokai'
Plug 'aonemd/kuroi.vim'
Plug 'gosukiwi/vim-atom-dark'
Plug 'dunstontc/vim-vscode-theme'
Plug 'romainl/Apprentice'
Plug 'navarasu/onedark.nvim'
let g:onedark_config = {'style': 'warm'}
Plug 'rebelot/kanagawa.nvim'
Plug 'sainnhe/everforest'
let g:everforest_background = 'soft'
Plug 'RRethy/vim-illuminate'
Plug 'gcmt/taboo.vim'
let g:taboo_tab_format = "%P%m"
Plug 'vim-airline/vim-airline'
let g:airline_inactive_collapse = 0
let g:airline_powerline_fonts = 1
let g:airline_left_sep = ""
let g:airline_right_sep = ""
let g:airline#extensions#tabline#alt_sep = 1
let g:airline#extensions#tabline#left_sep = ""
let g:airline#extensions#tabline#left_alt_sep = "|"
let g:airline#extensions#tabline#right_sep = ""
let g:airline#extensions#tabline#right_alt_sep = ""
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_splits = 0
let g:airline#extensions#tabline#show_buffers = 0
let g:airline#extensions#tabline#show_close_button = 1
let g:airline#extensions#tabline#tab_nr_type = 1
let g:airline#extensions#tabline#show_tab_type = 0
let g:airline#extensions#tabline#show_tab_count = 0
let g:airline#extensions#hunks#enabled = 0
let g:airline#extensions#branch#enabled = 0
let g:airline#extensions#tmuxline#enabled = 0
let g:airline_section_b = '%{winnr()}'
let g:airline_mode_map = {
\ '__' : '-',
\ 'n' : 'N',
\ 'i' : 'I',
\ 'R' : 'R',
\ 'c' : 'C',
\ 'v' : 'V',
\ 'V' : 'V',
\ '' : 'V',
\ 's' : 'S',