-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
4090 lines (3514 loc) · 134 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
set nocompatible
set encoding=utf-8
set showcmd
" Tried to set this up here but vim-sleuth fails to pick this up
set tabstop=4
" 4 spaces can be argued (2 encourages nesting code too much, 3 is insanity)
" and sometimes we work with code using tabs &shrug;
set autoindent
" set foldmethod=indent
filetype plugin indent on
call plug#begin('~/.vim/plugged')
Plug 'github/copilot.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" annoying that i need to set this but this makes it work from tmux
let g:oscyank_term = 'default'
Plug 'ojroques/vim-oscyank', {'branch': 'main'}
" Plug 'ojroques/nvim-osc52'
Plug 'prabirshrestha/async.vim'
Plug 'andymass/vim-visput'
Plug 'powerman/vim-plugin-AnsiEsc'
Plug 'fidian/hexmode'
Plug 'rizzatti/dash.vim'
Plug 'chrisbra/csv.vim'
Plug 'chamindra/marvim'
let g:marvim_store = $HOME . '/.vim/marvim'
let g:marvim_find_key = '<F1>'
let g:marvim_store_key = 'ms' " change store key from <F3> to 'ms'
Plug 'martinda/Jenkinsfile-vim-syntax'
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': [ 'markdown', 'vim-plug' ] }
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
let $NVIM_MKDP_LOG_FILE = $HOME . '/.tmp/mkdp-log.log'
let $NVIM_MKDP_LOG_LEVEL = 'debug'
let g:mkdp_echo_preview_url = 1
Plug 'brgmnn/vim-opencl'
let g:vim_markdown_folding_disabled = 1
let g:csv_hiGroup = 'CursorColumn'
let g:csv_highlight_column = 'y'
Plug 'jreybert/vimagit'
" Plug 'liuchengxu/vista.vim'
" if !has('nvim')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" for coc.nvim
" au FileType c,cpp,objc,objcpp set cmdheight=2
set updatetime=300
set shortmess+=c
set backup
set nowritebackup
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position.
" Coc only does snippet and additional edit on confirm.
" inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Or use `complete_info` if your vim support it, like:
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
"
" let g:coc_enable_locationlist = 0
" autocmd User CocLocationsChange CocList --normal location
" new way to complete on enter
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use `[g` and `]g` to navigate diagnostics
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
" satisfies my need for commanded go to def split, this replaces Select mode
nnoremap gh :call CocAction('jumpDefinition', 'split')<CR>
" vert split go to def, replaces gv which selects previous selection
nnoremap gv :call CocAction('jumpDefinition', 'vsplit')<CR>
" new tab go to def, replaces original vim bind for going to next tab, which is good to know, and
" which i will use on clean systems, but i already have F2 and tab and ctrl+pgdn for that.
nnoremap gt :call CocAction('jumpDefinition', 'tabe')<CR>
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
if has('nvim')
let g:coc_snippet_next = '<c-tab>'
let g:coc_snippet_prev = '<c-s-tab>'
else
imap <F23> <Plug>(coc-snippets-expand-jump)
let g:coc_snippet_next = '<F23>'
let g:coc_snippet_prev = '<F22>'
endif
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
autocmd CursorHold * silent if !exists('s:vimHelperServerJobDead') | call async#job#send(s:vimHelperServerJob, "hov:".expand('<cword>')."#".line(".").":".col(".")."\n") | endif
" always show the signatures when possible
" au CursorHoldI * sil call CocActionAsync('showSignatureHelp')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
xmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescriptreact,typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
" autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` to fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" use `:OR` for organize import of current buffer
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add status line support, for integration with other plugin, checkout `:h coc-status`
" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
nnoremap ? :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" endif " if not nvim
if has('nvim')
" Plug 'neovim/nvim-lsp'
" Plug 'ervandew/supertab'
" Plug 'haorenW1025/completion-nvim'
endif
Plug 'jackguo380/vim-lsp-cxx-highlight'
" let g:lsp_cxx_hl_log_file = '/tmp/vim-lsp-cxx-hl.log'
" let g:lsp_cxx_hl_verbose_log = 1
let g:lsp_cxx_hl_use_text_props = 1
" Load on nothing
" Plug 'SirVer/ultisnips', { 'on': [] }
" Plug 'Valloric/YouCompleteMe', { 'on': [] }
" Plug 'scrooloose/syntastic', { 'on': [] }
" Plug 'Shougo/neocomplete.vim'
" Plug 'w0rp/ale'
Plug 'chrisbra/Colorizer'
Plug 'majutsushi/tagbar', { 'on': ['Tagbar'] }
" Plug 'xavierd/clang_complete'
let s:LoadExpensivePluginsHasBeenRun = 0
function! LoadExpensive()
if !(s:LoadExpensivePluginsHasBeenRun)
echom 'loadexpensive'
" call plug#load('ultisnips')
call plug#load('tagbar')
" call plug#load('clang_complete')
autocmd! load_expensive
let s:LoadExpensivePluginsHasBeenRun = 1
endif
endfun
augroup load_expensive
autocmd!
autocmd InsertEnter * call LoadExpensive()
augroup END
Plug 'maxbrunsfeld/vim-yankstack'
" Yankstack actually not expensive... this way to lazyload isnt good. (lose
" first yanks)
", { 'on': ['<Plug>yankstack_substitute_older_paste',
"'<Plug>yankstack_substitute_newer_paste'] }
" autocmd! User vim-yankstack call InitYankStack()
Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' }
Plug 'rhysd/clever-f.vim'
Plug 'rhysd/conflict-marker.vim'
Plug 'editorconfig/editorconfig-vim'
" Plug 'rhysd/git-messenger.vim'
" The below is a functional replacement for git-messenger, much simple, works only in vim for now
" tho. got from someone's comment on git-messenger github issues.
if !has('nvim')
nmap <silent><Leader>b :call setbufvar(winbufnr(popup_atcursor(split(system("git log -n 1 -L " . line(".") . ",+1:" . expand("%:p")), "\n"), { "padding": [1,1,1,1], "pos": "botleft", "wrap": 0 })), "&filetype", "git")<CR>
endif
" Plug 'leafgarland/typescript-vim'
" Plug 'peitalin/vim-jsx-typescript'
" Plug 'neoclide/vim-jsx-improve'
" Plug 'chemzqm/vim-jsx-improve'
" let g:jsx_improve_motion_disable = 1
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeFind', 'NERDTreeToggle'] }
" Plug 'ctrlpvim/ctrlp.vim'
Plug 'vim-scripts/diffchanges.vim'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-obsession'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-abolish' " this is the plug that does crc,crm,crs,cru (convert variable case e.g. camelCase MixedCase snake_case)
" Plug 'mi60dev/image.vim'
" Plug 'tpope/vim-afterimage'
" Plug 'rust-lang/rust.vim'
" Plug 'tpope/vim-endwise'
" Plug 'vim-perl/vim-perl'
" Plug 'mattn/emmet-vim'
" Plug 'unphased/git-time-lapse'
" Plug 'vim-scripts/yaifa.vim'
Plug 'nathanaelkane/vim-indent-guides'
" if has('nvim')
" au TermEnter * IndentGuidesDisable
" au TermLeave * IndentGuidesEnable
" endif
" Plug 'wellle/context.vim'
Plug 'wellle/targets.vim'
Plug 'metakirby5/codi.vim'
" TODO: replace hicursorwords with a more straightforward impl such as
" https://github.com/hotoo/highlight-cursor-word.vim/blob/master/plugin/highlight.vim
" Update, tried it, didn't fucking work.
Plug 'unphased/HiCursorWords'
Plug 'dimasg/vim-mark', { 'on': '<Plug>MarkSet' }
" Bundle 'kien/rainbow_parentheses.vim'
Plug 'mhinz/vim-signify'
Plug 'pangloss/vim-javascript'
Plug 'othree/html5.vim'
" Plug 'jelera/vim-javascript-syntax'
Plug 'beyondmarc/glsl.vim'
"Bundle 'kana/vim-smartinput'
Plug 'honza/vim-snippets'
" Bundle 'oblitum/rainbow'
" Plug 'marijnh/tern_for_vim'
"
" Plug 'unphased/vim-airline'
" Plug 'vim-airline/vim-airline-themes'
Plug 'itchyny/lightline.vim'
" Plug 'mengelbrecht/lightline-bufferline'
" Plug 'prettier/vim-prettier', {
" \ 'do': 'npm install',
" \ 'branch': 'release/1.x',
" \ 'for': [
" \ 'javascript',
" \ 'typescript',
" \ 'css',
" \ 'less',
" \ 'scss',
" \ 'json',
" \ 'graphql',
" \ 'markdown',
" \ 'vue',
" \ 'lua',
" \ 'php',
" \ 'python',
" \ 'ruby',
" \ 'html',
" \ 'swift' ] }
" Plug 'lfilho/cosco.vim'
" let g:auto_comma_or_semicolon = 1
" let g:cosco_ignore_comment_lines = 1
" nnoremap <Leader>; :AutoCommaOrSemiColonToggle
" let g:cosco_filetype_blacklist = ['vim', 'bash']
" python integration seems to not work without this sometimes, i found this
" when i was compiling vim myself on ubuntu 18.04
if has('python3')
python3 import vim
endif
autocmd FileType c,cpp,cs,java setlocal commentstring=//\ %s
let g:lightline = { }
let g:lightline.colorscheme = 'powerline'
let g:lightline.enable = {
\ 'tabline': 1
\ }
let g:lightline.tabline = {
\ 'left': [ [ 'tabs' ] ] }
" \ 'right': [ ['buffers'] ] }
let g:lightline.tab = {
\ 'active': [ 'tabwinct', 'filename', 'tabmod', 'readonly' ],
\ 'inactive': [ 'tabwinct', 'filename', 'tabmod' ]
\ }
let g:lightline.active = {
\ 'left': [ [ 'modified', 'mode', 'paste' ],
\ [ 'relativepathtrunc', 'cocstatus', 'gitbranch', 'readonly'] ],
\ 'right': [ [ 'percent' ],
\ [ 'lineinfo', 'charposition', 'filesize', 'charvaluehex' ],
\ [ 'fileformatenc', 'filetype' ] ] }
let g:lightline.inactive = {
\ 'left': [ [ 'modified' ], [ 'relativepathtrunc' ] ] }
let g:lightline.tab_component_function = {
\ 'tabwinct': 'TabWinCt',
\ 'tabmod': 'TabAnyModified'
\ }
let g:lightline.component_function = {
\ 'gitbranch': 'GitBranch',
\ 'filesize': 'FileSize',
\ 'filetype': 'FileTypeFun',
\ 'cocstatus': 'coc#status',
\ 'fileformatenc': 'FileFormatEncFun'
\ }
let g:lightline.component_expand = {
\ 'buffers': 'lightline#bufferline#buffers'
\ }
let g:lightline.component_type = {
\ 'buffers': 'tabsel'
\ }
let g:lightline.component_raw = {'buffers': 1}
let g:lightline.component = {
\ 'mode': '%{lightline#mode()}',
\ 'absolutepath': '%F',
\ 'relativepathtrunc': '%f',
\ 'filename': '%t',
\ 'modified': '%M',
\ 'bufnum': '%n',
\ 'paste': '%{&paste?"PASTE":""}',
\ 'readonly': '%R',
\ 'charvalue': '%b',
\ 'charvaluehex': '0x%02B',
\ 'charposition': '%o',
\ 'fileencoding': '%{&fenc!=#""?&fenc:&enc}',
\ 'fileformat': '%{&ff}',
\ 'percent': '%2p%%%<',
\ 'percentwin': '%P',
\ 'spell': '%{&spell?&spelllang:""}',
\ 'lineinfo': '%l/%L:%c%V',
\ 'line': '%l',
\ 'column': '%c%V',
\ 'close': '%999X X ',
\ }
let g:lightline#bufferline#clickable = 1
let g:lightline#bufferline#show_number = 2
let g:lightline#bufferline#right_aligned = 1
let g:lightline#bufferline#more_buffers = '…'
function! GitBranch()
let branch = FugitiveHead()
if len(branch) > 0
return " " . branch " powerline branch glyph prepended when on actual branch
else
return "Detached " . FugitiveHead(7)
endif
endfun
function! TabWinCt(n) abort
let n = tabpagewinnr(a:n, '$')
if (n == 1)
return ''
else
return n
endif
endfun
function! TabAnyModified(n) abort
let winct = tabpagewinnr(a:n, '$')
let modified = 0
while winct > 0
if gettabwinvar(a:n, winct, '&modified')
return '+'
endif
let winct -= 1
endwhile
return ''
endfunction
function! FileSize()
if winwidth(0) < 100
return ''
endif
let bytes = getfsize(expand("%:p"))
if bytes <= 0
return ''
endif
if bytes < 65536
return bytes
elseif bytes < 67108864
return (bytes / 1024) . "K"
else
return (bytes / 1048576) . "M"
endif
endfunction
function! FileTypeFun()
return winwidth(0) > 80 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! FileFormatEncFun()
return winwidth(0) > 80 ? &fileformat : ''
endfunction
" Plug 'derekwyatt/vim-fswitch'
" Plug 'wakatime/vim-wakatime'
" Plug 'kshenoy/vim-signature'
" Plug 'jiangmiao/auto-pairs'
" Plug 'Raimondi/delimitMate'
"Plug 'mxw/vim-jsx'
"Plug 'rstacruz/vim-closer'
" Plug 'cohama/lexima.vim'
" Plug 'fatih/vim-go'
Plug 'tmux-plugins/vim-tmux'
Plug 'unphased/vim-unimpaired'
Plug 'vim-scripts/camelcasemotion'
Plug 'vim-scripts/ingo-library' " needed for EnhancedJumps
Plug 'vim-scripts/EnhancedJumps'
Plug 'inkarkat/vim-SyntaxRange'
" Plug 'inkarkat/vim-IndentConsistencyCop'
Plug 't9md/vim-textmanip', { 'on': [ '<Plug>(textmanip-move-down)', '<Plug>(textmanip-move-up)', '<Plug>(textmanip-move-left)', '<Plug>(textmanip-move-right)', '<Plug>(textmanip-toggle-mode)', '<Plug>(textmanip-toggle-mode)', ] }
" Plug 'junegunn/vim-easy-align'
Plug 'vim-scripts/Align'
" Plug 'octol/vim-cpp-enhanced-highlight' " this broke way too often on modern c++ files. Really problematic angle bracket handling. Trying it again.
" Plug 'unphased/Cpp11-Syntax-Support'
" apparently a somewhat-working extension from base cpp stuff. At least it isnt
" a breaking one.
" Plug 'Mizuchi/STL-Syntax'
Plug 'unphased/vim-html-escape' " my master has gdefault detecting tweak
" Plug 'rking/ag.vim'
" Plug 'kana/vim-textobj-user'
Plug 'Ron89/thesaurus_query.vim'
Plug 'AndrewRadev/switch.vim'
Plug 'AndrewRadev/sideways.vim'
Plug 'AndrewRadev/linediff.vim'
Plug 'AndrewRadev/splitjoin.vim'
" Plug 'AndrewRadev/inline_edit.vim'
" Plug 'AndrewRadev/whitespaste.vim'
" Plug 'sickill/vim-pasta'
" superceded by Colorizer
" Plug 'ap/vim-css-color'
" Plug 'Xuyuanp/nerdtree-git-plugin'
" Plug 'chrisbra/NrrwRgn'
Plug 'https://github.com/wesQ3/vim-windowswap'
Plug 'sbdchd/neoformat'
" Plug 'anowlcalledjosh/conflict-marker.vim', { 'branch': 'diff3' }
" use unimpaired for conflict markers: ]n [n
Plug 'elzr/vim-json'
" Plug 'Shougo/echodoc.vim'
" Plug 'myhere/vim-nodejs-complete'
call plug#end()
let g:switch_custom_definitions =
\ [
\ {
\ '\<\(\l\)\(\l\+\(\u\l\+\)\+\)\>': '\=toupper(submatch(1)) . submatch(2)',
\ '\<\(\u\l\+\)\(\u\l\+\)\+\>': "\\=tolower(substitute(submatch(0), '\\(\\l\\)\\(\\u\\)', '\\1_\\2', 'g'))",
\ '\<\(\l\+\)\(_\l\+\)\+\>': '\U\0',
\ '\<\(\u\+\)\(_\u\+\)\+\>': "\\=tolower(substitute(submatch(0), '_', '-', 'g'))",
\ '\<\(\l\+\)\(-\l\+\)\+\>': "\\=substitute(submatch(0), '-\\(\\l\\)', '\\u\\1', 'g')",
\ }
\ ]
" This entry duplicates builtins (true <-> false), but being here gives it an appropriate priority
au FileType cpp let g:switch_custom_definitions = [
\ switch#Words(['public', 'private']),
\ switch#Words(['first', 'second']),
\ switch#Words(['true', 'false']),
\ {
\ 'const \([A-Za-z][A-Za-z0-9_:<>]*\)&': '\1',
\ '\%(const \)\@!\([A-Za-z][A-Za-z0-9_:<>]*\)' : 'const \1&'
\ }
\ ] + g:switch_custom_definitions
" highest priority defs are prepended last here
let g:switch_custom_definitions = [
\ switch#NormalizedCase(['show', 'hide']),
\ switch#NormalizedCase(['add', 'remove']),
\ switch#NormalizedCase(['before', 'after']),
\ switch#NormalizedCase(['begin', 'end']),
\ switch#NormalizedCaseWords(['yes', 'no']),
\ switch#NormalizedCaseWords(['on', 'off']),
\ switch#NormalizedCaseWords(['error', 'warn', 'info']),
\ ] + g:switch_custom_definitions
" let g:switch_find_smallest_match = 1
function! s:async_job_handler(job_id, data, event_type)
echom 'Async job handler report ========='
echom a:job_id . ' ' . a:event_type
echom join(a:data, "\n")
if a:event_type == 'exit'
let s:vimHelperServerJobDead = 1
endif
endfunction
function! s:async_job_stdout_handler(job_id, data, event_type)
echom 'Async job stdout ========='
echom a:job_id . ' ' . a:event_type
echom join(a:data, "\n")
endfunction
function! s:async_job_stderr_handler(job_id, data, event_type)
echom 'Async job stderr ========='
echom a:job_id . ' ' . a:event_type
echom join(a:data, "\n")
endfunction
let s:vimHelperServerJob = async#job#start([
\ "bash", "-c",
\ "(cd ~/util; node -r ts-node/register vimhelper_server.ts " . getpid() . ")"],
\ {'on_exit':
\ function('s:async_job_handler'), 'on_stderr': function('s:async_job_stderr_handler'),
\ 'on_stdout': function('s:async_job_stdout_handler')})
" custom lightline palette fuckery (to make the inactive pane bars more readable)
let s:palette = g:lightline#colorscheme#powerline#palette
let s:palette.inactive.left = [
\ ['#262626', '#606060', 235, 241],
\ ['#9e9e9e', '#303030', 247, 236]
\ ]
" if has('nvim')
if 0
set omnifunc=v:lua.vim.lsp.omnifunc
nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> gd <cmd>lua vim.lsp.buf.declaration()<CR>
nnoremap <silent> ? <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> 2gd <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> 3gd <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> 1gd <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
echo 'nvim_lsp setting up ccls'
lua vim.lsp.set_log_level("debug")
lua << EOF
require'nvim_lsp'.ccls.setup{
-- the following settings are not working. i ended up getting shit working using a .ccls file at the end of the day.
init_options = { highlight = { lsRanges = true }}
}
require'nvim_lsp'.vimls.setup{}
require'nvim_lsp'.pyls.setup{}
EOF
" supertab
" let g:SuperTabDefaultCompletionType = 'context'
" autocmd FileType *
" \ if &omnifunc != '' |
" \ call SuperTabChain(&omnifunc, "<c-n>") |
" \ endif
" " Use completion-nvim in every buffer
" autocmd BufEnter * lua require'completion'.on_attach()
" " Use <Tab> and <S-Tab> to navigate through popup menu
" inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
" inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" " Set completeopt to have a better completion experience
" set completeopt=menuone,noinsert,noselect
" " Avoid showing message extra message when using completion
" set shortmess+=c
" let g:completion_enable_auto_popup = 0
" function! s:check_back_space() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~ '\s'
" endfunction
" inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ completion#trigger_completion()
endif
" dunno if i want to bring back tabnine.
call coc#add_extension('coc-json', 'coc-snippets', 'coc-pyright', 'coc-tsserver', 'coc-vimlsp', 'coc-emmet', 'coc-eslint', 'coc-diagnostic', 'coc-prettier', 'coc-clangd', 'coc-sh', 'coc-tailwindcss', 'coc-svg')
" function! CheckBatteryTabNine(timer)
" call system('onbatt')
" echom 'cbtn: ret '.v:shell_error
" if v:shell_error
" echom 'Not on battery: Enabling coc-tabnine when entering buffers.'
" " let l:z = CocAction('extensionStats')
" " echo 'extensionStats: '.l:z
" call CocAction('activeExtension', 'coc-tabnine')
" else
" echom 'On battery: Disabling coc-tabnine when entering buffers.'
" call CocAction('deactivateExtension', 'coc-tabnine')
" endif
" endfun
" autocmd VimEnter * call timer_start(3000, "CheckBatteryTabNine")
" autocmd VimEnter * call CheckBatteryTabNine()
" TODO make this detect and use zeal for linux and dash on mac
" nnoremap <F5> :Dash!<CR>
" we can talk about bringing the dash/zeal hotkey back but it's just not used that much
" Unfortunately header to source direction does not seem to work that well here either, weird.
au filetype cpp nnoremap <F5> :CocCommand clangd.switchSourceHeader<CR>
" ensures (from vim) that tmux config works right for title
if &term == "tmux-256color-italic"
set t_ts=]0;
set t_fs=
endif
set title
" suppresses "Thanks for flying Vim", though I'd like to know why it fails at restoring original
" title.
set titleold=
" To use echodoc, you must increase 'cmdheight' value.
" set cmdheight=2
" let g:echodoc_enable_at_startup = 1
if has('nvim')
autocmd BufEnter * let &titlestring = "NVIM " . expand("%:t")
" autocmd BufEnter * highlight LspDiagnosticsError ctermbg=88 guibg=#870000
" autocmd BufEnter * highlight LspDiagnosticsWarning ctermbg=11 guibg=#878700
" autocmd BufEnter * highlight LspDiagnosticInformation ctermbg=242 guibg=#303030
" autocmd BufEnter * highlight LspDiagnosticHint ctermbg=88 guibg=#870000
" autocmd BufEnter * highlight LspReferenceText ctermbg=88 guibg=#870000
else
autocmd BufEnter * let &titlestring = "VIM " . expand("%:t")
endif
" Bundle 'Decho'
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" These are file extension filetype settings
au! BufRead,BufNewFile *.esp set ft=perl
au! BufRead,BufNewFile *.mm set ft=objcpp
au! BufRead,BufNewFile *.mlp set ft=xml
au! BufNewFile,BufRead *.vsh,*.fsh,*.vp,*.fp,*.gp,*.vs,*.fs,*.gs,*.tcs,*.tes,*.cs,*.vert,*.frag,*.geom,*.tess,*.shd,*.gls,*.glsl set ft=glsl440
au! BufNewFile,BufReadPost *.md set filetype=markdown
au! BufRead,BufNewFile CUDA*.in,*.cuda,*.cu,*.cuh set ft=cuda
" customize it for my usual workflow
autocmd FileType gitcommit setlocal nosmartindent | setlocal formatoptions-=tcl
au filetype markdown setlocal nosmartindent | setlocal formatoptions-=a
au filetype markdown vmap ` S`
au filetype crontab set formatoptions=
" this thing needs work
" nnoremap <Leader>g :call TimeLapse()<CR>
" nnoremap <Leader>e :silent !p4 edit %:p<CR>:redraw!<CR>
nnoremap <Leader>R :silent redraw!<CR>
" noequalalways somehow breaks coc.nvim references menu under clangd. very emphatic &shrug;
" set noequalalways
" let g:neocomplete#enable_at_startup = 1
" let g:neocomplete#min_keyword_length = 3
" let g:neocomplete#enable_fuzzy_completion = 1
" if !exists('g:neocomplete#keyword_patterns')
" let g:neocomplete#keyword_patterns = {}
" endif
" let g:neocomplete#keyword_patterns['javascript'] = '[@#.]\?[[:alpha:]_:-][[:alnum:]_:-]*'
" autocmd FileType javascript set formatprg=prettier\ --stdin
" this is unsafe (syntax errors and bad line wrapping)
" neocomplete: bind tab for similar behavior to YCM
" inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<S-TAB>"
" These are apparently the defacto terminal codes for Ctrl+Tab and Ctrl+Shift+Tab
" but Vim has no knowledge of it. so here i am adding it to the fastkey
" repertoire, but skipping F24 and F25 because the actual vitality plugin uses
" this method specifically on F24 and F25
if !has('nvim')
set <F24>=/
" this is something i found and is cool but forgot to use. It takes word under the cursor and
" makes a s-expression to replace it with something that you can immediately start typing. TODO:
" Use this method for the smart logic i use for enter key and such things. i think its more
" convoluted than this.
nnoremap <F24> :%s/\<<c-r><c-w>\>//g<left><left>
" c-tab
set <F23>=[27;5;9~
" s-c-tab
set <F22>=[27;6;9~
set <F19>=,
set <F14>=<
" ctrl+del
set <F13>=[3;5~
inoremap <F13> <C-o>de
set <F21>=
nnoremap <F21> B
inoremap <F21> <C-\><C-o>db
else
" nvim gets more nuanced binds
inoremap <C-Del> <C-o>de
inoremap <S-Del> <C-o>dw
inoremap <M-Del> <C-o>dW
nnoremap <C-Del> de
nnoremap <S-Del> dw
nnoremap <M-Del> dW
nnoremap <M-BS> B
nnoremap <M-/> :%s/\<<c-r><c-w>\>//g<left><left>
endif
" " Ultisnips settings (to have it work together with YCM)
" if has('nvim')
" let g:UltiSnipsExpandTrigger="<C-TAB>"
" let g:UltiSnipsJumpForwardTrigger="<C-TAB>"
" let g:UltiSnipsJumpBackwardTrigger="<C-S-TAB>"
" " Just set to something so that c-tab wont be used (needed for nvim)
" let g:UltiSnipsListSnippets="<M-c>"
" else
" " I believe default <c-tab> binding fails to work on vim so this just ends
" " up working the way i want
" let g:UltiSnipsExpandTrigger="<F23>"
" let g:UltiSnipsJumpForwardTrigger="<F23>"
" let g:UltiSnipsJumpBackwardTrigger="<F22>"
" endif
" " Using Ctrl Tab to fire the snippets. Shift tab is taken by YCM.
" " the weird custom mapping doesn't really seem to help anything and I cannot
" " figure out how to get it to respond to tab properly, so it should be an easy
" " enough thing to get used to to use Ctrl+(Shift+)Tab to control snips. Should
" " even allow seamless use of YCM while entering an ultisnip segment, so this is
" " pretty much near perfect for snippets since too much overloading is confusing
" " anyway.
" let g:UltiSnipsEditSplit="vertical"
" " let g:UltiSnipsSnippetDirectories = ["UltiSnips"]
" indent guides plugin
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_auto_colors = 0
let g:indent_guides_start_level = 1
let g:indent_guides_guide_size = 1
" " customizing the vim-signature bindings (to un-delay the backtick)
" let g:SignatureMap = {
" \ 'Leader' : "m",
" \ 'PlaceNextMark' : "m,",
" \ 'ToggleMarkAtLine' : "m.",
" \ 'PurgeMarksAtLine' : "m-",
" \ 'DeleteMark' : "dm",
" \ 'PurgeMarks' : "m<Space>",
" \ 'PurgeMarkers' : "m<BS>",
" \ 'GotoNextSpotAlpha' : "']",
" \ 'GotoPrevSpotAlpha' : "'[",
" \ 'GotoNextLineByPos' : "]'",
" \ 'GotoPrevLineByPos' : "['",
" \ 'GotoNextSpotByPos' : "]`",
" \ 'GotoPrevSpotByPos' : "[`",
" \ 'GotoNextMarker' : "[+",
" \ 'GotoPrevMarker' : "[-",
" \ 'GotoNextMarkerAny' : "]=",
" \ 'GotoPrevMarkerAny' : "[=",
" \ 'ListLocalMarks' : "m/",
" \ 'ListLocalMarkers' : "m?"
" \ }
nnoremap <F4> :UndotreeToggle<CR>
inoremap <F4> <ESC>:UndotreeToggle<CR>
let g:undotree_RelativeTimestamp = 0
" These C-V and C-C mappings are for fakeclip, but fakeclip doesn't work on
" OSX and I never really seem to do much copying and pasting
" nmap <C-V> "*p
" vmap <C-C> "*y
" The new way to do copypaste is with + register -- I already have it set up to
" have visual mode y yank to OS X pasteboard.
nnoremap <Leader>L :autocmd!<CR>:so $MYVIMRC<CR>:runtime! after/plugin/*.vim<CR>:runtime! after/ftplugin/*.vim<CR>
" for camelcasemotion, bringing back the original , by triggering it with ,,
" the comma repeats last t/f/T/F, which is *still* completely useless... Here's
" the thing. There's nothing useful to bind comma to, because comma is used
" with camelcasemotion in normal mode because it's still marginally useful that
" way.
" nnoremap ,, ;
" xnoremap ,, ;
" onoremap ,, ;
" now no longer really needed with cleverf
" for use with bkad's cmm. i went back because i found a bug
" call camelcasemotion#CreateMotionMappings(',')
" add some cases so that certain common keystrokes when used from visual mode
" (which i often land in) will do what i would want it to do
xmap <C-P> <ESC><C-P>
omap <C-P> <ESC><C-P>
" remapping keys for EnhancedJumps: I cant let tab get mapped. Since curly
" braces are conveniently available as hopping by paragraphs is not useful for
" me, this example given by the doc will work out well.
nmap { <Plug>EnhancedJumpsOlder
nmap } <Plug>EnhancedJumpsNewer
nmap g{ <Plug>EnhancedJumpsLocalOlder
nmap g} <Plug>EnhancedJumpsLocalNewer
nmap <Leader>{ <Plug>EnhancedJumpsRemoteOlder
nmap <Leader>} <Plug>EnhancedJumpsRemoteNewer
" some possible conflict with :redir
let g:EnhancedJumps_CaptureJumpMessages = 0
set hlsearch
set incsearch
set showmatch " May be overly conspicuous and unnecessary
set backspace=2
set sidescroll=2
set sidescrolloff=3
" fast terminal (this is for escape code wait time for escape code based keys)
set ttimeout
set ttimeoutlen=3
" set t_Co=256
" set term=screen-256color-italic
if !has('nvim')
set ttymouse=xterm2
endif
syntax on
set number
set numberwidth=2
set laststatus=2
set undodir=~/.tmp
set ignorecase
set smartcase
set gdefault " Reverses meaning of /g in regex
" Bringing this back because it helps in some files. lets see what it breaks
set smartindent
" I took out smartindent but this does not hurt (?) to make sure it never is on for python
au! FileType python setl nosmartindent
set expandtab
set smarttab
set autoread
augroup checktime_augroup
au!
if !has("gui_running")
"silent! necessary otherwise throws errors when using command
"line window.
autocmd BufEnter * silent! checktime
" autocmd CursorHold * silent! checktime
" autocmd CursorHoldI * silent! checktime
"these two _may_ slow things down. Remove if they do.
"autocmd CursorMoved * silent! checktime
"autocmd CursorMovedI * silent! checktime
endif
augroup END
augroup yank_saving_group
" autocmd! CursorHold * noautocmd call YankSave()
" autocmd! CursorHoldI * call YankSave()
augroup END
let g:yank_save_buffer = ''
function! YankSave()
" yank into pbcopy if @@ has changed.
let yanked = substitute(@@, '\n', '\\n', 'g')
if g:yank_save_buffer != yanked
echom "running YankSave update!"
let poscursor=getpos('.')
let g:yank_save_buffer = yanked
" this converts @@ into a bash single-quoted string by doing two
" transformations, turning single quotes inside @@ into '"'"', which is
" how you insert a single quote into a bash single quoted string, and
" the newlines which show as NULs in the variable into escaped newlines
" which are how to make the newlines work in the bash string. Then pipe
" into pbcopy.
silent exec "!echo '" . substitute(escape(substitute(@@, "'", "'\"'\"'", 'g'), '!\#%'), '\n', '\\n', 'g') . "' | pbcopy"
call setpos('.', poscursor)
endif
endfun
" This stuff is cool, but is subject to vim's own ex substitutions, for
" a subset of the ones it does, which is reasonably safe even when tested on
" this vimrc itself (which is a minefield for this, if there ever was one).
" With that being said it is not a perfectly correct operation, because e.g.
" something like <afile> will get converted in the pbcopy. So, I am
" contemplating switching this approach for writing to a temp file first in
" order to make it correct.
if &term =~ '256color'
" Disable Background Color Erase (BCE) so that color schemes
" work properly when Vim is used inside tmux and GNU screen.
" See also http://snk.tuxfamily.org/log/vim-256color-bce.html
set t_ut=
endif
" prevent the damn commandlist from coming up. One day when i prevent the enter
" bind from working in this window i can bring it back and actually use it. but
" until then...
" nnoremap q: <Nop>
" this has a problem though: q now has a delay even when used to stop
" a recording. argh.
colorscheme Tomorrow-Night-Eighties
hi LineNr ctermfg=242
" overrides the linenr set by above colorscheme.
"set listchars=tab:→\ ,extends:>,precedes:<,trail:·,nbsp:◆
set listchars=tab:→\ ,extends:»,precedes:«,trail:·,nbsp:◆