This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
3689 lines (3241 loc) · 128 KB
/
init.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
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
"""" motions
" 0 To the first character of the line. |exclusive|
" ^ To the first non-blank character of the line.
" $ To the end of the line. When a count is given also go
" w [count] words forward. |exclusive| motion.
" W [count] WORDS forward. |exclusive| motion.
" e Forward to the end of word [count] |inclusive|.
" E Forward to the end of WORD [count] |inclusive|.
" b [count] words backward. |exclusive| motion.
" B [count] WORDS backward. |exclusive| motion.
" ge Backward to the end of word [count] |inclusive|.
" gE Backward to the end of WORD [count] |inclusive|.
" % Find the next item in this line after or under the cursor and jump to its match.
" ]m go to next start of a method
" ]M go to next end of a method
" [m go to previous start of a method
" [M go to previous end of a method
" [{ jump to beginning of code block (while, switch, if, etc)
" [( jump to the beginning of a parenthesis
" ]} jump to end of code block (while, switch, if, etc)
" ]) jump to the end of a parenthesis
" ]] [count] |section|s forward or to the next '{' in the first column.
" ][ [count] |section|s forward or to the next '}' in the first column.
" [[ [count] |section|s backward or to the previous '{' in the first column
" [] [count] |section|s backward or to the previous '}' in the first column
" CTRL-O go to [count] Older cursor position in jump list
" CTRL-I go to [count] newer cursor position in jump list
" '. go to position where last change was made (in current buffer)
" ( [count] sentences backward
" ) [count] sentences forward
" { [count] paragraphs backward
" } [count] paragraphs forward
" '< To the first line or character of the last selected Visual area
" '> To the last line or character of the last selected Visual area
" g; Go to [count] older position in change list.
" g, Go to [count] newer cursor position in change list.
" c delete character and enter insert mode
" d delete character and enter insert mode
" p paste behind cursor
" P paste in-front/on top cursor
"""" actions
" C delete from the cursor to the end of the line and enter insert mode
" cc delete the whole line and enter insert mode (===S)
" x delete the character under the cursor
" X delete the character in front of the cursor
" D clears all characters in the current line (the line is not deleted)
" dw delete word
" de delete until end of word
" dd delete one line
" dl delete character (alias: "x")
" diw delete inner word
" daw delete a word
" diW delete inner WORD
" daW delete a WORD
" dis delete inner sentence
" das delete a sentence
" dib delete inner '(' ')' block
" dab delete a '(' ')' block
" dip delete inner paragraph
" dap delete a paragraph
" diB delete inner '{' '}' block
" daB delete a '{' '}' block
" d5j delete 5 lines in 'j' direction
" xp transpose 2 characters
" rc replace the character under the cursor with c
"""" read-only registers
" "% current file name
" "# rotation file name
" ". last inserted text
" ": last executed command
" "/ last found pattern
" "Ay any upper case letter APPENDS to register
"""" special register
" "0 'y' copied text is stored in the nameless register `""`, also `"0`. `c`、`d`、`s`、`x` does not override this register.
"""" INSERT MODE KEYS
" <C-h> delete the character before the cursor during insert mode
" <C-w> delete word before the cursor during insert mode
" <C-j> begin new line during insert mode
" <C-t> indent (move right) line one shiftwidth during insert mode
" <C-d> de-indent (move left) line one shiftwidth during insert mode
" <C-R>a pastes the contents of the `a` register
" <C-R>" pastes the contents of the unnamed register (last delete/yank/etc)
"
" zz center line on screen
" zt move current line to top
" zb move current line to bottom
"
" Completion
" <C-x><C-l> - whole lines
" <C-x><C-n> - keywords in the current file
" <C-x><C-i> - keywords in the current and included files
" <C-x><C-f> - file names
" <C-x><C-d> - function names
let base16colorspace=256
set termguicolors
" send change arguments to blackhole registry
nnoremap c "_c
nnoremap C "_C
" copy paragraph
" nnoremap cp vap:t'><CR>
" insert mode paste from the clipboard just like on mac
inoremap <C-v> <C-r>*
" Indent/dedent what you just pasted
nnoremap <leader>< V`]<
nnoremap <leader>> V`]>
" reselect pasted text. gv, reselects the last visual selection
nnoremap gp `[v`]
" scroll through time instead of space TODO (find non-mouse combo)
" map <ScrollWheelUp> :later 10m<CR>
" map <ScrollWheelDown> :earlier 10m<CR>
" Don't lose selection when shifting sidewards
"*** seems to remove the ability to '.' ***
" xnoremap < <gv
" xnoremap > >gv
" move cursor with it
" vnoremap <expr> > ">gv"..&shiftwidth.."l"
" vnoremap <expr> < "<gv"..&shiftwidth.."h"
" move cursor to beginning of line
" vnoremap > >gv^
" vnoremap < <gv^
set shell=/usr/local/bin/bash
set title "displays current file as vim title
set visualbell "kills the bell
set t_vb= "kills the bell
" folds
" toggle folds
nnoremap <space><space> za
vnoremap <space><space> za
" zf#j creates a fold from the cursor down # lines.
" zf/ string creates a fold from the cursor to string .
" zj moves the cursor to the next fold.
" zk moves the cursor to the previous fold.
" za toggle a fold at the cursor.
" zo opens a fold at the cursor.
" zO opens all folds at the cursor.
" zc closes a fold under cursor.
" zm increases the foldlevel by one.
" zM closes all open folds.
" zr decreases the foldlevel by one.
" zR decreases the foldlevel to zero -- all folds will be open.
" zd deletes the fold at the cursor.
" zE deletes all folds.
" [z move to start of open fold.
" ]z move to end of open fold.
" treesitter
set fillchars+=fold:\ " space
" Open files without any folding
set foldlevelstart=99
cnoremap <expr> <c-n> wildmenumode() ? "\<c-n>" : "\<down>"
cnoremap <expr> <c-p> wildmenumode() ? "\<c-p>" : "\<up>"
set wildmode=longest:full,full
set wildoptions=pum
" set wildoptions+=pum
" Enables pseudo-transparency for the popup-menu, 0-100
set pumblend=20
set wildcharm=<Tab>
" set completeopt+=noselect,noinsert,menuone,preview
" set completeopt=menuone,noinsert,noselect,preview
set completeopt=menuone,preview
" ignore case, example: :e TEST.js
set wildignorecase
" don't have vim autocomplete these ever
set wildignore+=tags
set wildignore+=package-lock.json
set wildignore+=**/*.xml
" off for telescope-node_modules usage
" set wildignore+=**/node_modules/*
set wildignore+=**/.git/*
" give low priority to files matching the defined patterns.
set suffixes+=.lock,.scss,.sass,.min.js,.less,.json
let mapleader = ','
" save a shift in normal mode
" nnoremap ; :
" switch back and forth with two most recent files in buffer
" nnoremap <Backspace> <C-^>
" go back to last old buffer
" nnoremap <silent> <bs> <c-o><cr>
" go forward to next newest buffer
" nnoremap <silent> <tab> <c-i<cr>
" nnoremap <Leader><Tab> :buffer<Space><Tab>
" nnoremap <silent> <c-n> :bnext<CR>
" nnoremap <silent> <c-p> :bprev<CR>
" nnoremap <silent> <c-x> :bdelete<CR>
" vim tab navigation
" Next tab: gt
" Prior tab: gT
" Numbered tab: 7gt
nnoremap <leader>tc :tabclose<CR>
nnoremap <leader>tn :tabnew<CR>
" nnoremap <leader>tl :tablast<CR>
nnoremap <leader>to :tabonly<cr>
nnoremap <leader>tm :tabmove<Space>
nnoremap <leader>1 1gt
nnoremap <leader>2 2gt
nnoremap <leader>3 3gt
nnoremap <leader>4 4gt
nnoremap <leader>5 5gt
nnoremap <leader>6 6gt
nnoremap <leader>7 7gt
nnoremap <leader>8 8gt
nnoremap <leader>9 9gt
nnoremap <leader>0 10gt
" Let 'tl' toggle between this and the last accessed tab
let g:lasttab = 1
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
au TabLeave * let g:lasttab = tabpagenr()
" add < and > to matched pairs
set matchpairs+=<:>
" Clear cmd line message after X seconds
function! s:empty_message(timer)
if mode() ==# 'n'
echon ''
endif
endfunction
augroup cmd_msg_cls
autocmd!
autocmd CmdlineLeave : call timer_start(10000, funcref('s:empty_message'))
augroup END
" hide line showing switch in insert/normal mode
set noshowmode
set noruler
set splitright
set splitbelow
set hidden " allows you to abandon a buffer without saving
set smartindent " Keep indentation from previous line
set showbreak=↳
set expandtab " Use softtabstop spaces instead of tab characters
set softtabstop=2 " Indent by 2 spaces when pressing <TAB>
set shiftwidth=2 " Indent by 2 spaces when using >>, <<, == etc.
set showtabline=2 " always display vim tab bar
set number
set relativenumber
set breakindent
set breakindentopt=shift:2
" display line movements unless preceded by a count
" also recording jump points for movements larger than five lines
nnoremap <expr> j v:count ? (v:count > 5 ? "m'" . v:count : '') . 'j' : 'gj'
nnoremap <expr> k v:count ? (v:count > 5 ? "m'" . v:count : '') . 'k' : 'gk'
" use neovim nightly filetype detection
let g:do_filetype_lua = 1
let g:did_load_filetypes = 0
augroup numbertoggle
autocmd!
" try nkakouros-original/numbers.nvim instead?
autocmd BufEnter,FocusGained *.*,.* set relativenumber
autocmd BufLeave,FocusLost *.*,.* set norelativenumber
" or by filetype
" autocmd BufNewFile,BufRead *.myfile setlocal norelativenumber
augroup END
" disable relative numbers
nnoremap <leader>rn :set rnu!<cr>
" Toggle relative line numbers when entering Command mode (helpful for pair programming sessions)
" Open up Command mode ':' -> Partner can look for absolute line number -> Write down number -> Press enter
" autocmd CmdlineEnter * if &number | set norelativenumber | endif | redraw
" autocmd CmdLineLeave * if &number | set relativenumber | endif
" force decimal-based arithmetic on increment/decrement
set nrformats=
" increment and decrement
nnoremap + <C-a>
nnoremap - <C-x>
" visual mode, also
" xnoremap + g<C-a>
" xnoremap - g<C-x>
" dot repetition over visual line selections.
xnoremap . :norm.<CR>
" run macro over visual lines (using qq to record)
xnoremap Q :'<,'>:normal @q<CR>
" https://www.reddit.com/r/neovim/comments/tsol2n/why_macros_are_so_slow_compared_to_emacs/
" overload @ key to execute the macro avoiding any auto command that may be triggred during insert mode or text change
" :noautocmd normal 10000@q
xnoremap @ :<C-U>execute "noautocmd '<,'>norm! " . v:count1 . "@" . getcharstr()<cr>
" backup/undo management
set nobackup
set nowritebackup
set noswapfile " Disable swapfile
" setup persistent undo
set undofile
" search highlighting/behavior
set hlsearch
set incsearch
" allow tab/s-tab to filter with incsearch in-progress
" cnoremap <expr> <Tab> getcmdtype() =~ "[?/]" ? "<c-g>" : "<Tab>"
" cnoremap <expr> <S-Tab> getcmdtype() =~ "[?/]" ? "<c-t>" : "<S-Tab>"
" Make <C-p>/<C-n> act like <Up>/<Down> in cmdline mode, so they can be used to navigate history with partially completed commands
cnoremap <c-p> <up>
cnoremap <c-n> <down>
cnoremap <up> <c-p>
cnoremap <down> <c-n>
" use c-k/j to navigate cmdline menu
cnoremap <c-k> <Left>
cnoremap <c-j> <Right>
" juggling with jumps
nnoremap ' `
set jumpoptions=stack
set ignorecase
set infercase " enhances ignorecase
set smartcase
set inccommand=nosplit "highlight :s in realtime
set diffopt+=vertical,algorithm:patience
" allows block selections to operate across lines regardless of the underlying text
set virtualedit=block
set selection=old
set complete-=t " disable searching tags
" Toggle spell checking on/off
nmap <silent> <leader>ss :set spell!<CR>
set spelllang=en_us
set complete+=kspell
" z=, to get a suggestion
" ]s means go to next misspelling,
" [s is back. When you land on the word
" zw to add it to your Private dictionary
" zuw if you make a mistake to remove it from you dictionary
function! FzfSpellSink(word)
exe 'normal! "_ciw'.a:word
endfunction
function! FzfSpell()
let suggestions = spellsuggest(expand('<cword>'))
return fzf#run({'source': suggestions, 'sink': function('FzfSpellSink'), 'options': '--preview-window hidden', 'down': 20})
endfunction
nnoremap z= :call FzfSpell()<CR>
nmap <silent> <leader>sz :call FzfSpell()<CR>
" keep windows same size when opening/closing splits
set equalalways
augroup STUFFS
autocmd!
" resize panes the host window is resized
autocmd VimResume,VimResized, NvimTreeOpen, NvimTreeClose * wincmd =
autocmd VimResized,VimResume * execute "normal! \<C-w>="
" only highlight cursorline in current active buffer, when not in insert mode
autocmd InsertLeave,WinEnter * set cursorline
autocmd InsertEnter,WinLeave * set nocursorline
" autocmd BufWritePost * if &diff | diffupdate | endif " update diff after save
" go back to previous tab when closing tab
autocmd TabClosed * tabprevious
augroup END
"sessions
set sessionoptions-=buffers
set sessionoptions-=help
set sessionoptions-=folds
" results with those ^: sessionoptions=blank,curdir,tabpages,winsize
" split windows
nnoremap <C-w>- :new<cr>
nnoremap <C-w><bar> :vnew<cr>
function! InsertFilePath()
execute 'normal i'.expand('%:p:h').'/'
endfunction
noremap <leader>ef :call InsertFilePath()<CR>
" open :e based on current file path
noremap <Leader>ep :e <C-R>=expand('%:p:h') . '/' <CR>
" Opens a new tab with the current buffer's path
noremap <leader>eb :tabedit <C-r>=expand("%:p:h")<CR>/
" Prompt to open file with same name, different extension
noremap <leader>er :e <C-R>=expand("%:r")."."<CR>
" Switch CWD to the directory of the open buffer
nnoremap <leader>cd :cd %:p:h<cr>:pwd<cr>
" change directory to folder of current file
nnoremap <leader>cd :cd %:p:h<cr>
" open file under cursor anywhere on line
" https://www.reddit.com/r/vim/comments/mcxha4/remapping_gf_to_open_a_file_from_anywhere_on_the/
nnoremap gf ^f/gf
" open file under cursor in vertical split
map <C-w>f <C-w>vgf
"toggles whether or not the current window is automatically zoomed
function! ToggleMaxWins()
if exists('g:windowMax')
au! maxCurrWin
wincmd =
unlet g:windowMax
else
augroup maxCurrWin
" au BufEnter * wincmd _ | wincmd |
"
" only max it vertically
au! WinEnter * wincmd _
augroup END
do maxCurrWin WinEnter
let g:windowMax=1
endif
endfunction
nnoremap <C-w>m :call ToggleMaxWins()<cr>
" hide the command history buffer. Use fzf :History instead
nnoremap q: <nop>
" disable mouse
set mouse=
" keep foreground commands in sync
" map fg <c-z>
" or the reverse, add this to shell profile
" stty susp undef
" bind '"\C-z":"fg\n"'
" format json
nnoremap <silent> <Leader>jj :set ft=json<CR>:%!jq .<CR>
" format html
" nnoremap <silent> <Leader>ti :%!tidy -config ~/.config/tidy_config.txt %<CR>
" remove smart quotes
" %!iconv -f utf-8 -t ascii//translit
" save with Enter *except* in quickfix buffers
" https://vi.stackexchange.com/questions/3127/how-to-map-enter-to-custom-command-except-in-quick-fix
" nnoremap <expr> <silent> <CR> &buftype ==# "quickfix" ? "\<CR>" : ":write!<CR>"
nnoremap <Enter> :w<Enter>
nnoremap <leader><Enter> :w !sudo tee %<Enter>
" Keep default CR behaviour for quickfix list
autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>
" can check type, not just name like:
" another option
" autocmd FileType qf nnoremap <buffer> <cr> <cr>
" train myself to use better commands
" ZZ - Write current file, if modified, and quit. (:x = :wq = ZZ)
" ZQ - Quit without checking for changes (same as ':q!')
map QQ :qa!<CR>
map QA :qa<CR>
cabbrev q! use ZQ
cabbrev wq use :x or ZZ
cabbrev wq! use :x!
cabbrev wqa use :xa
cabbrev wqa! use :xa!
" speedup :StartTime - :h g:python3_host_prog
let g:python3_host_prog = '/usr/local/bin/python3'
let g:loaded_python_provider = 0
let g:loaded_perl_provider = 0
let g:loaded_ruby_provider = 0
" let g:loaded_ruby_provider = 1 " use language server instead
" let g:loaded_node_provider = 1
call plug#begin('~/.config/nvim/plugged')
" if branch changes from master to main `git remote set-head origin -a` in `~/config/nvim/plugged/[plugin]`
" core code analysis and manipulation
Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'} |
\ Plug 'antoinemadec/coc-fzf' |
\ Plug 'wellle/tmux-complete.vim' " coc completion from open tmux panes
let g:coc_enable_locationlist = 0
" \ 'coc-dash-complete',
" \ 'coc-just-complete',
let g:coc_global_extensions = [
\ 'coc-coverage',
\ 'coc-css',
\ 'coc-cssmodules',
\ 'coc-db',
\ 'coc-docker',
\ 'coc-emmet',
\ 'coc-emoji',
\ 'coc-eslint',
\ 'coc-git',
\ 'coc-html',
\ 'coc-import-cost',
\ 'coc-jest',
\ 'coc-json',
\ 'coc-lists',
\ 'coc-lua',
\ 'coc-markdownlint',
\ 'coc-marketplace',
\ 'coc-pairs',
\ 'coc-prettier',
\ 'coc-pyright',
\ 'coc-react-refactor',
\ 'coc-sh',
\ 'coc-snippets',
\ 'coc-solargraph',
\ 'coc-spell-checker',
\ 'coc-styled-components',
\ 'coc-stylelintplus',
\ 'coc-svg',
\ 'coc-swagger',
\ 'coc-tsserver',
\ 'coc-vimlsp',
\ 'coc-webpack',
\ 'coc-yaml',
\ 'coc-yank'
\ ]
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } |
\ Plug 'junegunn/fzf.vim'
" buffer management
Plug 'AndrewRadev/undoquit.vim'
"<c-w>u reopen windo
"<c-w>U reopen tab with all windows
Plug 'kazhala/close-buffers.nvim'
map <leader>Bdo :BDelete other<CR>
map <leader>Bdh :BDelete hidden<CR>
map <leader>Bda :BDelete all<CR>
map <leader>Bdt :BDelete this<CR>
map <leader>Bdn :BDelete nameless<CR>
" undo tree visualizer
Plug 'simnalamburt/vim-mundo', { 'on': 'MundoToggle' }
nmap <Leader>mt :MundoToggle<CR>
let g:mundo_right=1
Plug 'NTBBloodbath/rest.nvim'
map <leader>rr <Plug>RestNvim
map <leader>rp <Plug>RestNvimPreview
map <leader>rL <Plug>RestNvimLast
Plug 'rmagatti/auto-session'
Plug 'shivamashtikar/tmuxjump.vim'
nmap <leader>jf :TmuxJumpFile<cr>
" :TmuxJumpFile js & :TmuxJumpFirst js
" https://github.com/hkupty/iron.nvim ?
" Plug 'metakirby5/codi.vim'
Plug 'timtyrrell/codi.vim'
let g:codi#aliases = {
\ 'javascriptreact': 'javascript',
\ 'typescriptreact': 'typescript',
\ }
Plug 'preservim/vimux'
let g:VimuxUseNearest = 1
let g:VimuxOrientation = "v"
" Combine VimuxZoomRunner and VimuxInspectRunner in one function.
function! VimuxZoomInspectRunner()
if exists("g:VimuxRunnerIndex")
call VimuxTmux("select-pane -t ".g:VimuxRunnerIndex)
call VimuxTmux("resize-pane -Z -t ".g:VimuxRunnerIndex)
call VimuxTmux("copy-mode")
endif
endfunction
map <Leader>vv :call VimuxZoomInspectRunner()<CR>
map <Leader>vp :VimuxPromptCommand<CR>
map <Leader>vl :VimuxRunLastCommand<CR>
map <Leader>vi :VimuxInspectRunner<CR>
map <leader>vz :VimuxZoomRunner<CR>
map <Leader>vq :VimuxCloseRunner<CR>
map <Leader>v<C-l> :VimuxClearTerminalScreen<CR>
map <Leader>vc :VimuxClearRunnerHistory<CR>
map <Leader>vx :VimuxInterruptRunner<CR>
" REPL usage
function! VimuxSlime()
call VimuxClearTerminalScreen()
call VimuxRunCommand(@v, 0)
call VimuxSendKeys("Enter")
endfunction
" If text is selected, save it in the v buffer and send that buffer it to tmux
vmap <leader>vs "vy :call VimuxSlime()<CR>
" Select current paragraph and send it to tmux
nmap <leader>vs vip<leader>vs<CR>
" send contents of entire buffer to tmux
nmap <leader>vb ggVG<leader>vs<CR>
" run file
nmap <Leader>vf :call VimuxRunCommand("clear; node " . bufname("%"))<CR>
" REPL
" vnoremap <leader>rn :w !node<Enter>
" vnoremap <leader>rr :w !ruby<Enter>
" vnoremap <leader>rp :w !python<Enter>
Plug 'ThePrimeagen/harpoon'
" left index finger
nnoremap <silent>\f :lua require("harpoon.ui").toggle_quick_menu()<CR>
nnoremap <silent>\d :lua require("harpoon.cmd-ui").toggle_quick_menu()<CR>
" lift the finger to do sth "dangerous"
nnoremap <silent>\g :lua require("harpoon.mark").add_file()<CR>
nnoremap <silent>\f :lua require("harpoon.mark").add_file()<CR>
" right home row, no finger lifting required
nnoremap <silent>\j :lua require("harpoon.ui").nav_file(1)<CR>
nnoremap <silent>\k :lua require("harpoon.ui").nav_file(2)<CR>
nnoremap <silent>\l :lua require("harpoon.ui").nav_file(3)<CR>
nnoremap <silent>\; :lua require("harpoon.ui").nav_file(4)<CR>
nnoremap <silent>\n :lua require("harpoon.ui").nav_next()<CR>
nnoremap <silent>\p :lua require("harpoon.ui").nav_prev()<CR>
nnoremap <silent>\tj :lua require("harpoon.tmux").gotoTerminal(1)<CR>
nnoremap <silent>\tk :lua require("harpoon.tmux").gotoTerminal(2)<CR>
nnoremap <silent>\cj :lua require("harpoon.tmux").sendCommand(1, 1)<CR>
nnoremap <silent>\ck :lua require("harpoon.tmux").sendCommand(1, 2)<CR>
Plug 'tpope/vim-dadbod'
Plug 'kristijanhusak/vim-dadbod-ui'
let g:db_ui_show_database_icon = 1
let g:db_ui_use_nerd_fonts = 1
let g:db_ui_force_echo_notifications = 1
" testing
Plug 'vim-test/vim-test'
" debugging
Plug 'mfussenegger/nvim-dap'
" Plug 'plytophogy/vim-virtualenv'
" Plug 'PieterjanMontens/vim-pipenv'
" Plug 'petobens/poet-v'
" Figure out the system Python for Neovim.
if exists("$VIRTUAL_ENV")
let g:python3_host_prog=substitute(system("which -a python3 | head -n2 | tail -n1"), "\n", '', 'g')
else
let g:python3_host_prog=substitute(system("which python3"), "\n", '', 'g')
endif
Plug 'mfussenegger/nvim-dap-python'
Plug 'theHamsta/nvim-dap-virtual-text'
Plug 'rcarriga/nvim-dap-ui'
Plug 'David-Kunz/jester'
" syntax
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'windwp/nvim-ts-autotag'
Plug 'nvim-treesitter/playground', { 'on': ['TSHighlightCapturesUnderCursor', 'TSNodeUnderCursor']}
" :TSHighlightCapturesUnderCursor
" :TSNodeUnderCursor
" R: Refreshes the playground view when focused or reloads the query when the query editor is focused.
" o: Toggles the query editor when the playground is focused.
" a: Toggles visibility of anonymous nodes.
" i: Toggles visibility of highlight groups.
" I: Toggles visibility of the language the node belongs to.
" t: Toggles visibility of injected languages.
" f: Focuses the language tree under the cursor in the playground. The query editor will now be using the focused language.
" F: Unfocuses the currently focused language.
" <cr>: Go to current node in code buffer
Plug 'JoosepAlviste/nvim-ts-context-commentstring'
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
Plug 'mfussenegger/nvim-ts-hint-textobject'
omap <silent> m :<C-U>lua require('tsht').nodes()<CR>
vnoremap <silent> m :lua require('tsht').nodes()<CR>
Plug 'mizlan/iswap.nvim'
nmap <leader>sw <Plug>ISwapWith
" use tree-sitter highlighting for spellchecker
Plug 'lewis6991/spellsitter.nvim'
Plug 'lukas-reineke/indent-blankline.nvim'
" fix blank line color issue
set colorcolumn=99999
if &diff
let g:indent_blankline_enabled = v:false
endif
let g:indent_blankline_use_treesitter = v:true
" default listchars=tab:>,trail:-,nbsp:+
set list listchars=tab:→\ ,space:⋅,trail:•,nbsp:␣,extends:▶,precedes:◀
" extends:⟩,precedes:⟨,tab:│\ ,eol:, tab:<->
let g:indent_blankline_char = '▏'
" let g:indent_blankline_char_blankline = '┆'
" let g:indent_blankline_char_list = ['|', '¦', '┆', '┊']
let g:indent_blankline_filetype_exclude = ['checkhealth', 'NvimTree', 'vim-plug', 'man', 'help', 'lspinfo', '', 'GV', 'git']
let g:indent_blankline_buftype_exclude = ['terminal', 'nofile', 'quickfix']
let g:indent_blankline_bufname_exclude = ['README.md', '.*\.py']
let g:indent_blankline_show_first_indent_level = v:true
let g:indent_blankline_show_trailing_blankline_indent = v:false
let g:indent_blankline_show_current_context = v:true
let g:indent_blankline_show_current_context_start = v:true
let g:indent_blankline_context_patterns = ['declaration', 'expression', 'pattern', 'primary_expression', 'statement', 'switch_body' ,'def', 'class', 'return', '^func', 'method', '^if', 'while', 'jsx_element', 'for', 'object', 'table', 'block', 'arguments', 'else_clause', '^jsx', 'try', 'catch_clause', 'import_statement', 'operation_type', 'with', 'except', 'arguments', 'argument_list', 'dictionary', 'element', 'tuple']
augroup tmuxgroups
autocmd!
autocmd FileType tmux nnoremap <silent><buffer> K :call tmux#man()<CR>
" automatically source tmux config when saved
autocmd BufWritePost .tmux.conf execute ':!tmux source-file %'
augroup END
Plug 'tmux-plugins/vim-tmux'
" https://github.com/nvim-treesitter/nvim-treesitter/issues/1019#issuecomment-812976740
" let g:polyglot_disabled = [
" \ 'bash', 'comment', 'css', 'graphql',
" \ 'html', 'javascript', 'javascriptreact', 'jsdoc', 'json',
" \ 'jsonc', 'jsx', 'lua', 'python', 'regex', 'rspec', 'ruby',
" \ 'sh', 'svg', 'tmux', 'tsx', 'typescript', 'typescriptreact', 'yaml']
Plug 'tpope/vim-sensible'
" Plug 'sheerun/vim-polyglot'
" " Plug 'sheerun/vim-polyglot', { 'commit': '2c5af8f' }
" let g:polyglot_disabled = ['sensible']
" let g:polyglot_disabled = ['ftdetect']
" let g:polyglot_disabled = ['autoindent']
" let g:markdown_fenced_languages = ['ruby', 'vim']
Plug 'z0mbix/vim-shfmt', { 'for': 'sh' }
let g:shfmt_fmt_on_save = 1
Plug 'AndrewRadev/splitjoin.vim'
" gS to split a one-liner into multiple lines
" gJ (with the cursor on the first line of a block) to join a block into a single-line statement.
"removes trailing whitespace on save
Plug 'rondale-sc/vim-spacejam'
let g:spacejam_filetypes = '*'
Plug 'weirongxu/plantuml-previewer.vim'
Plug 'tyru/open-browser.vim'
let g:netrw_nogx = 1 " disable netrw's gx mapping.
let g:openbrowser_default_search = 'duckduckgo'
nmap gx <Plug>(openbrowser-smart-search)
vmap gx <Plug>(openbrowser-smart-search)
" vim .dsl syntax https://github.com/vim/vim/pull/8764
" Plug 'shuntaka9576/preview-swagger.nvim', { 'build': 'yarn install' }
" Draw ASCII diagrams in Neovim.
" Plug 'jbyuki/venn.nvim'
" https://www.reddit.com/r/vim/comments/lwr56a/search_and_replace_camelcase_to_snake_case/
Plug 'tpope/vim-abolish'
" MixedCase (crm)
" camelCase (crc)
" snake_case (crs)
" UPPER_CASE (cru)
" dash-case (cr-)
" Title Case (crt)
Plug 'mileszs/ack.vim'
let g:ackprg = 'rg --vimgrep'
" Don't jump to first match
cnoreabbrev Ack Ack!
" use ripgrep for grep
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat=%f:%l:%c:%m
" grep word under cursor in entire project into quickfix
nnoremap <leader><bs> :Ack! <C-R><C-W><CR>
" grep word under cursor all buffers in current window into quickfix
nnoremap <space><bs> :AckWindow! <C-R><C-W><CR>
" enhanced matchit
let g:loaded_matchit = 1
Plug 'andymass/vim-matchup'
let g:matchup_matchparen_offscreen = {'method': 'popup'}
" ---------------------------------------------~
" LHS RHS Mode Module
" -----------------------------------------------~
" % |<plug>(matchup-%)| nx motion - go forwards to its next matching word
" g% |<plug>(matchup-g%)| nx motion - go backwards to [count]th previous matching word
" [% |<plug>(matchup-[%)| nx motion - Go to [count]th previous outer open word
" ]% |<plug>(matchup-]%)| nx motion - Go to [count]th next outer close word
" z% |<plug>(matchup-z%)| nx motion - Go to inside [count]th nearest block
" a% |<plug>(matchup-a%)| x text_obj - Select an |any-block|
" i% |<plug>(matchup-i%)| x text_obj - Select the inside of an |any-block|
" ds% |<plug>(matchup-ds%)| n surround - Delete {count}th surrounding matching words
" cs% |<plug>(matchup-cs%)| n surround - Change {count}th surrounding matching words
" tab to exit enclosing character
Plug 'abecodes/tabout.nvim'
" s 2char (nvim sneak)
" `s{char}<enter>` is the same as `f{char}`, but works over multiple lines.
Plug 'ggandor/leap.nvim'
Plug 'drmingdrmer/vim-toggle-quickfix'
nmap <Leader>qq <Plug>window:quickfix:loop
Plug 'kevinhwang91/nvim-bqf'
" zf - fzf in quickfix
" zp - toggle full screen preview
" zn or zN - create new quickfix list
" < - previous quickfix list
" > - next quickfix list
" c-x (split)
Plug 'christoomey/vim-tmux-navigator'
" If the tmux window is zoomed, keep it zoomed when moving from Vim to another pane
let g:tmux_navigator_preserve_zoom = 1
Plug 'christoomey/vim-system-copy'
" cp for copying and cv for pasting
" cpiw => copy word into system clipboard
" cpi' => copy inside single quotes to system clipboard
" cvi' => paste inside single quotes from system clipboard
" cP is mapped to copy the current line directly.
" cV is mapped to paste the content of system clipboard to the next line.
" other option: Plug 'ojroques/vim-oscyank'
" Plug 'tpope/vim-bundler' " use 'solargraph bundle' instead
"bundle bopen
Plug 'tpope/vim-commentary'
"gcc - comment out line
"gcap - comment out paragraph
"gcgc - uncomment a set of adjacent commented lines
"Vim sugar for the UNIX shell commands
Plug 'tpope/vim-eunuch'
"json motions
Plug 'tpope/vim-jdaddy'
" ij Text object for innermost JSON number, string, array, object, or keyword (including but not limited to true/false/null).
" aj Text object for outermost JSON object or array.
" gqij Replace the innermost JSON with a pretty printed version.
" gqaj Replace the outermost JSON with a pretty printed version.
" ["x]gwij Merge the JSON from the register into the innermost JSON. Merging extends objects, concatenates strings and arrays, and adds numbers.
" ["x]gwaj Merge the JSON from the register into the outermost JSON.
Plug 'mogelbrod/vim-jsonpath', { 'on': 'JsonPath'}
" :JsonPath: Echoes the path to the identifier under the cursor.
" :JsonPath path.to.prop
" try https://github.com/kana/vim-altr/blob/master/doc/altr.txt ?
Plug 'tpope/vim-projectionist'
"gf support
Plug 'tpope/vim-apathy'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-surround'
"quoting/parenthesizing made simple
" {{{
" mappings to quickly modify surrounding chars like ",],),},',<tag>
" NORMAL MODE:
" ds<SURROUND> to delete surround
" cs<SURROUND><SURROUND> to change surround from/to
" ys<TEXT-OBJECT><SURROUND> to surround text object
" yS<TEXT-OBJECT><SURROUND> to surround text object on new line
" VISUAL MODE:
" S<SURROUND>
" INSERT MODE:
" <C-g>s<SURROUND>
" }}}
" vitSt - add inner tag
" vatSt - add surrounding tag
" vS" : visually surround selected text with "
" yswt : prompt & surround with a html tag
" yswf : prompt & surround with a function call
" ds" : delete surrounding "
" dst : delete surrounding tag (HTML)
" in case I need to unmap them: https://github.com/mgarort/dotvim/blob/e67260d70377c28a0d0a08d8f3733adb05d5d4bd/vimrc#L987-L1000
augroup jsconsolecmds
autocmd!
"wrap in console.log - yswc or yssc TODO: broken also??
" autocmd FileType typescriptreact,javascript,javascriptreact,typescript let b:surround_{char2nr('c')} = 'console.log(\r)'
" autocmd FileType typescriptreact,javascript,javascriptreact,typescript let b:surround_{char2nr('e')} = '${\r}'
" move word under cursor up or down a line wrapped in a console.log
" or use: https://github.com/meain/vim-printer
autocmd FileType typescriptreact,javascript,javascriptreact,typescript nnoremap <buffer> <leader>cO "zyiwOconsole.log(z)<Esc>
autocmd FileType typescriptreact,javascript,javascriptreact,typescript nnoremap <buffer> <leader>co "zyiwoconsole.log(z)<Esc>
augroup END
Plug 'tpope/vim-unimpaired'
" prev conflict/patch: [n , next conflict/patch: ]n , paste toggle: yop
" [<Space> and ]<Space> add newlines before and after the cursor line
" [e and ]e exchange the current line with the one above or below it.
Plug 'tpope/vim-speeddating'
" increment/decrement dates <C-A>/<C-X>
" try https://github.com/wellle/targets.vim ?
" https://github.com/kana/vim-textobj-user/wiki
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-line', { 'on': ['<Plug>(textobj-line-i', '<Plug>(textobj-line-a']}
xmap al <Plug>(textobj-line-a)
omap al <Plug>(textobj-line-a)
xmap il <Plug>(textobj-line-i)
omap il <Plug>(textobj-line-i)
" 'il' ignores leading and trailing spaces. 'al' ignoes EOL
Plug 'kana/vim-textobj-indent', { 'on': ['<Plug>(textobj-indent-i', '<Plug>(textobj-indent-a', '<Plug>(textobj-indent-same-i', '<Plug>(textobj-indent-same-a']}
xmap ai <Plug>(textobj-indent-a)
omap ai <Plug>(textobj-indent-a)
xmap ii <Plug>(textobj-indent-i)
omap ii <Plug>(textobj-indent-i)
xmap aI <Plug>(textobj-indent-same-a)
omap aI <Plug>(textobj-indent-same-a)
xmap iI <Plug>(textobj-indent-same-i)
omap iI <Plug>(textobj-indent-same-i)
Plug 'vimtaku/vim-textobj-keyvalue', {'on': ['<Plug>(textobj-key-a', '<Plug>(textobj-key-i', '<Plug>(textobj-value-a', '<Plug>(textobj-value-i']}
xmap ak <Plug>(textobj-key-a)
omap ak <Plug>(textobj-key-a)
xmap ik <Plug>(textobj-key-i)
omap ik <Plug>(textobj-key-i)
xmap av <Plug>(textobj-value-a)
omap av <Plug>(textobj-value-a)
xmap iv <Plug>(textobj-value-i)
omap iv <Plug>(textobj-value-i)
" Plug 'chaoren/vim-wordmotion'
" Plug 'Julian/vim-textobj-variable-segment'
" iv and av for variable segments, snake_case, camelCase, etc
" Plug 'rhysd/vim-textobj-anyblock', { 'on': ['<Plug>(textobj-anyblock-i', '<Plug>(textobj-anyblock-a']}
" xmap ab <Plug>(textobj-anyblock-a)
" omap ab <Plug>(textobj-anyblock-a)
" xmap ib <Plug>(textobj-anyblock-i)
" omap ib <Plug>(textobj-anyblock-i
" ib is a union of i(, i{, i[, i', i" and i<
" ab is a union of a(, a{, a[, a', a" and a<
" https://github.com/mlaursen/vim-react-snippets#cheatsheet
Plug 'mlaursen/vim-react-snippets', { 'branch': 'main' }
" review linenumber before jump
Plug 'nacro90/numb.nvim'
" git
Plug 'tpope/vim-fugitive' |
\ Plug 'tpope/vim-rhubarb' |
\ Plug 'junegunn/gv.vim'
" 1. Run :G mergetool.
" 2. (If you need a diff view, run :Gvdiffsplit! or any other variant.)
" 3. Resolve the conflicts, then write and stage the result with :Gwrite.
" 4. (Close other windows, if any, with <C-w><C-o>.)
" 5. Go to the next quickfix entry with ]q or :cnext.
" Fugitive Conflict Resolution
" nnoremap <leader>gd :Gvdiff<CR>
" nnoremap gdh :diffget //2<CR> (left key)
" nnoremap gdl :diffget //3<CR> (right key)
" jump conflicts: ]c [c
"
" When I'm in a 3-way diff and hit ,ga, vim opens a new tab and diffs the file in the active window against the common ancestor. When I'm done reading the diff, I just :tabclose and I'm right back to where I was.
" nnoremap <leader>ga :tab sp \| Gvedit :1 \| windo diffthis<CR>
" logs for entire repo
nnoremap <leader>gv :GV<cr>
" logs for entire repo, cleaned up
nnoremap <leader>gV :GV --first-parent -100<cr>
" nnoremap <leader>gV :GV --no-merges --first-parent -100<cr>
" logs for current file
nnoremap <leader>GV :GV! -100<cr>
" gq or q exit
" O opens a new tab instead
" gb for :GBrowse
" ]] and [[ to move between commits
" . to start command-line with :Git [CURSOR] SHA à la fugitive
" https://github.com/tpope/vim-fugitive/issues/1446
" fix older husky versions
let g:fugitive_pty = 0
nnoremap <leader>gb :Git blame<cr>
nnoremap <leader>gB :%Git blame<cr>
" gq close blame, then |:Gedit| to return to work tree version
" <CR> close blame, and jump to patch that added line (or directly to blob for boundary commit)
" o jump to patch or blob in horizontal split