-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path.vimrc
More file actions
1528 lines (1358 loc) · 49.2 KB
/
Copy path.vimrc
File metadata and controls
1528 lines (1358 loc) · 49.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
" Base configuration {{{
" Encoding. Required for powerline fonts (at least with gVim: https://vi.stackexchange.com/q/20136/21251)
" Might be dependent on window-specific overrides.
set encoding=utf-8
set fileencoding=utf-8
set termencoding=utf-8
set nocompatible " be iMproved, required
filetype off " required
let g:ODebugVim = 0
if g:ODebugVim
call ch_logfile($HOME .. "/.log/vim-" .. strftime("%FT%T") .. ".txt", "ao")
endif
if has("win32unix")
finish
endif
let g:python3_host_prog = 'python3'
" }}}
" Folding {{{
set foldmethod=marker
" set nofoldenable
nnoremap <leader>ft :set foldenable!
nnoremap <leader>fe :set foldenable
nnoremap <leader>fd :set nofoldenable
augroup folding
au!
autocmd FileType vim setlocal foldenable
autocmd FileType markdown setlocal nofoldenable
augroup END
augroup config
au!
autocmd FileType markdown setlocal conceallevel=0
" Prevent the buggy and annoying builtin HTML omnifunc from taking effect
autocmd FileType markdown setlocal complete=FCompletePath,t,.,w,b
augroup END
augroup SpecialFiles
au!
autocmd FileType fern call glyph_palette#apply()
autocmd FileType fall-list call glyph_palette#apply()
autocmd FileType nerdtree,startify call glyph_palette#apply()
augroup END
" }}}
" System compatibility {{{
" Root code location
let g:ODevDir = 0
" Root
let g:OVimDevDir = 0
if isdirectory("/mnt/LinuxData")
let g:ODevDir = "/mnt/LinuxData/"
elseif isdirectory($HOME .. "/programming/vim")
let g:ODevDir = $HOME .. "/"
elseif $SSH_TTY != ""
let g:ODevDir = $HOME .. "/"
let g:OVimDevDir = g:ODevDir .. "programming/"
endif
if type(g:OVimDevDir) == v:t_number && type(g:ODevDir) == v:t_string
" Assuming the general directory scheme is maintained anyway
" Can be customized separately though.
let g:OVimDevDir = g:ODevDir .. 'programming/vim/'
endif
let g:Print = "Vimrc messages:\n"
fun! s:SilentPrint(message)
let g:Print ..= "\n" .. a:message
endfun
command! Messages echo g:Print
fun! s:LocalOption(localPath, remotePath)
if (type(g:OVimDevDir) == v:t_number || !isdirectory(g:OVimDevDir .. a:localPath))
exec "Plug '" .. a:remotePath .. "'"
call s:SilentPrint("Using remote path: " .. a:remotePath)
else
exec "Plug '" .. g:OVimDevDir .. a:localPath .. "'"
call s:SilentPrint("Using local path: " .. g:OVimDevDir .. a:localPath)
endif
endfun
" }}}
" Plugins {{{
call plug#begin('~/.vim/plugged')
" Local debug {{{
if isdirectory(g:OVimDevDir .. "PluginScience")
exec "Plug '" .. g:OVimDevDir .. "PluginScience" .. "'"
endif
" }}}
" Navigation {{{
" Fern {{{
" Upstream fern has default-enabled coderabbitai (slop machine) for PR
" reviews, so changes cannot be default-trusted anymore
" 2025-09-28: all repos forked (I already had fern.vim forked, and
" vim-nerdfont was forked to fix a bug)
Plug 'LunarWatcher/vim-nerdfont'
call s:LocalOption("fern.vim", "LunarWatcher/fern.vim")
Plug 'LunarWatcher/vim-fern-hijack'
Plug 'LunarWatcher/vim-glyph-palette'
if executable("git")
call s:LocalOption("vim-fern-git-status", "LunarWatcher/vim-fern-git-status")
endif
" }}}
" zefei appears to be gone (last activity in 2022), so these were switched
" over to a fork I made. Won't be maintaining as long as it works, but need to
" make sure it stays available and that account control doesn't fall into the
" wrong hands.
call s:LocalOption('vim-wintabs', 'LunarWatcher/vim-wintabs')
" }}}
" Fuzzy finder {{{
if has('win32')
" Windows note: Some Assembly Required:tm:
" Install FZF manually. This can be done with either
" `go get -u github.com/junegunn/fzf`, or by installing
" one of the pre-built binaries manually.
Plug 'junegunn/fzf'
else
Plug 'junegunn/fzf', { 'do': './install --all' }
endif
Plug 'junegunn/fzf.vim'
" }}}
" Themes and colors {{{
" Temporary until https://github.com/NLKNguyen/papercolor-theme/pull/203 is
" merged
call s:LocalOption("papercolor.vim", "LunarWatcher/papercolor.vim")
" Plug 'NLKNguyen/papercolor-theme'
Plug 'rhysd/conflict-marker.vim'
" }}}
" Language highlighting {{{
" Speed up load
let g:loaded_sensible = 1
let g:polyglot_disabled = [ 'markdown' ]
Plug 'sheerun/vim-polyglot'
Plug 'bfrg/vim-c-cpp-modern', {'for': 'cpp'}
" Mostly unused, but gets to live for now. Might be worth trying out some
" alternatives so I can stop installing texlive-full as part of my dotfiles
" setup
Plug 'lervag/vimtex', {'for': 'tex'}
" }}}
" Various coding-related utils {{{
" Fallback: tomtom/tcomment_vim
Plug 'tpope/vim-commentary'
Plug 'liuchengxu/vista.vim'
Plug 'tpope/vim-surround'
Plug 'mg979/vim-visual-multi', { 'commit': 'a6975e7c1ee157615bbc80fc25e4392f71c344d4' }
"Plug 'skywind3000/asyncrun.vim'
"Plug 'skywind3000/asynctasks.vim'
" Primarily used at work, and in some large open-source projects
Plug 'editorconfig/editorconfig-vim'
" }}}
" Editor utils {{{
Plug 'skywind3000/vim-quickui'
" }}}
" Text extensions {{{
call s:LocalOption("img-paste.vim", "LunarWatcher/img-paste.vim")
" }}}
" Coding utilities {{{
" Extended % matching
Plug 'chrisbra/matchit'
let UseJSShit = 0
if UseJSShit == 0
call s:LocalOption('lsp', 'yegappan/lsp')
else
Plug 'neoclide/coc.nvim', {'branch': 'release'}
endif
"Plug 'LunarWatcher/lsp', {'branch': 'allow-bare-omnicomplete'}
if has("python3")
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" I had to give this a double name because
" 1. I'm lazy
" 2. just vim-snippets results in vim-plug not being sure what to do with
" honza/vim-snippets, because BrOKeN InstALlAtion.
" Would be a lot easier if vim-plug preserved the username in the path.
" 3. Telling people to manually rename either repo with plugin manager
" config is stupid
call s:LocalOption("lunarwatcher-vim-snippets", 'LunarWatcher/lunarwatcher-vim-snippets')
endif
" }}}
" Lightline {{{
" Plug 'itchyny/lightline.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" }}}
" Git integration {{{
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
" }}}
" General every-day use {{{
Plug 'tpope/vim-speeddating'
call s:LocalOption('auto-pairs', 'LunarWatcher/auto-pairs')
call s:LocalOption('Dawn', 'LunarWatcher/Dawn')
Plug 'mbbill/undotree'
if !has("win32") && !has("win32unix")
Plug 'puremourning/vimspector'
endif
" }}}
" Search {{{
Plug 'LunarWatcher/traces.vim'
" }}}
" Font-related stuff {{{
"set guifont=Source\ Code\ Pro\ for\ Powerline:h11:cANSI " Source Code Pro <3
"set guifontwide=Source\ Code\ Pro\ for\ Powerline:h11:cANSI " gvim
" Sauce Code Pro is Source Code Pro, but with added symbols (compared to the
" powerline variant as well)
"
try
if has("win32")
" The Nerd Fonts are broken on windows.
" https://github.com/ryanoasis/nerd-fonts/issues/269
" Up since 2018, "patched" in 2020
" As of 2022, it's still broken.
"set guifont=SauceCodePro\ NF:h11
" ... and to add insult to injury, as of 2022, the powerline variant
" does not display properly. No fucking clue what the problem is, but
" it looks like no anti-aliasing or something? Fuck if I know. All I
" know is that it's hideous to look at, and painfully hard to read
"set guifont=Source\ Code\ Pro\ for\ Powerline:h11
" The point in any case... default SCP
" Thanks for nothing, Windows
set guifont=Source\ Code\ Pro:h12
elseif has("unix")
set guifont=SauceCodePro\ Nerd\ Font\ 12
endif
catch
echom "Failed to find SauceCodePro - falling back to SourceCodePro, and disabling devicons"
if has("win32")
" We were supposed to fall back to powerline if we didn't have nerd
" fonts, but that likely being pointless aside (on linux installs, the
" font always exists), we have nothing to fall back on.
"
" We could fall back on plain SCP here, but we can't do that now that
" SCP is the only workin font on this godforesaken shitty OS. (Why am
" I even doing this to myself?)
echoerr "Options exhausted; install Source Code Pro directly"
elseif has("unix")
if !has("gui_running")
set guifont=Source\ Code\ Pro\ for\ Powerline\ 12
else
set guifont=Source\ Code\ Pro\ for\ Powerline:h12
endif
endif
endtry
" }}}
" Meta plugins {{{
"Plug 'tweekmonster/startuptime.vim'
Plug 'thinca/vim-themis'
Plug 'tpope/vim-repeat'
call s:LocalOption("helpwriter.vim", "LunarWatcher/helpwriter.vim")
call s:LocalOption("vim9cord", "LunarWatcher/vim9cord")
call s:LocalOption("vimrc-modules", "LunarWatcher/vimrc-modules")
" }}}
call plug#end()
" }}}
" Plugin config {{{
" Vim9cord (testing) {{{
"let g:Vim9cordButtons = [
"{}
"]
let g:Vim9cordAltDetails = "I don't have a problem, I can quit any time I want :3"
" }}}
" Plug mapping {{{
nnoremap <leader>pi <esc>:PlugInstall<cr>
nnoremap <leader>pc <esc>:PlugClean<cr>
if !has("win32")
nnoremap <leader>pu :PlugUpdate<cr>:VimspectorUpdate<cr>
else
" Vimspector is not supported on windows
nnoremap <leader>pu :PlugUpdate<cr>
endif
nnoremap <F8> :Vista!!<cr>
" }}}
" vim-visual-multi config {{{
nmap <C-LeftMouse> <Plug>(VM-Mouse-Cursor)
nmap <C-RightMouse> <Plug>(VM-Mouse-Word)
nmap <M-C-RightMouse> <Plug>(VM-Mouse-Column)
" }}}
" Autocomplete {{{
set shortmess+=c
set signcolumn=yes
set updatetime=100
" Code actions {{{
" Coc.nvim {{{
fun! LoadCocNvim()
map <leader>qa <Plug>(coc-codeaction-cursor)
nmap <leader>qA <Plug>(coc-codeaction)
vmap <leader>qA <Plug>(coc-codeaction-selected)
map <leader>qs <Plug>(coc-codeaction-source)
map <leader>qF <Plug>(coc-codeaction-file)
map <leader>ql <Plug>(coc-codeaction-line)
nmap <leader>qr <Plug>(coc-codeaction-refactor)
vmap <leader>qr <Plug>(coc-codeaction-refactor-selected)
nmap <leader>qf <Plug>(coc-fix-current)
inoremap <silent><expr> <c-space> coc#refresh()
nmap <leader>rn <Plug>(coc-rename)
nmap <silent> <leader>rd <Plug>(coc-definition)
nmap <silent> <leader>rD <Plug>(coc-declaration)
nmap <silent> <leader>rr <Plug>(coc-references)
nmap <silent> <leader>ri <Plug>(coc-implementation)
nmap <silent> <leader>rt <Plug>(coc-type-definition)
nmap <silent> <leader>rf <Plug>(coc-format)
vmap <silent> <leader>rf <Plug>(coc-format-selected)
" Fix scrolling in popups
nnoremap <silent><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
" Show docs
" I also like that this doesn't show up automatically. YCM was wayyyyyyyy too
" aggressive in showing documentation.
nnoremap <silent> K :call CocActionAsync('doHover')<cr>
" Restarting is the only way to fix an issue with some popups not
" disappearing. Focusing and quitting the popup could also be an option, but
" fuuuuuuuck that
nnoremap <silent> <leader>rc :call CocRestart<cr>
nnoremap <silent> <leader>hp :call coc#float#close_all()<cr>
endfun
" }}}
" Yegappan/lsp {{{
fun CompletePath(findstart, base)
let currIdx = col('.')
" This does not account for paths with spaces, but it's a start
let matchColStart = match(
\ getline('.')[:currIdx],
\ '\v([^ "' .. "'" .. '(){}[\]]+([/\\][^ {}[\]]*)+|\.*[/\\][^ {}[\]]*)$'
\ )
if (a:findstart == 1)
if (matchColStart < 0 || matchColStart == currIdx)
return -2
endif
return matchColStart - 0
elseif (a:findstart == 0)
" Required, or /* style comments result `glob("/**")`, which means
" indexing the entire disk. For obvious reasons, we don't want this
" There's probably other characters that should be escaped too.
if (a:base->stridx('*') >= 0)
return #{ words: [], refresh: "always" }
endif
let fileDir = expand('%:h')
" Find files relative to the current file
" The way this is currently handled also means /<path> also gets
" handled relative to the current path, which I kinda like
let relative = globpath(fileDir, a:base .. "*", 0, 1)
\ ->map('{ "word": v:val[' .. (len(fileDir) + 1) .. ':], "kind": "[Path]", "menu": isdirectory(v:val) ? "Folder" : "File" }')
" Find relative to / or cwd or whatever. globpath() does not handle
" those cases
let absolute = glob(a:base .. "*", 0, 1)
\ ->map('{ "word": v:val, "kind": "[Path]", "menu": isdirectory(v:val) ? "Folder" : "File" }')
let matches = []->extend(relative)->extend(absolute)
if (len(matches) == 0)
return #{ words: [], refresh: "always" }
endif
" call add(out, "BASE: " .. a:base)
return #{
\ words: matches,
\ refresh: "always"
\ }
endif
endfun
fun PreloadYegappanLsp()
" TODO:
" * LspSymbolSearch
" * LspSuperTypeHierarchy
" * LspSubTypeHierarchy
" * LspSwitchSourceHeader (\cp replacement)
" * Investigate if there's a way to change the popup so it's wider
" Note to self: as far as I can tell, yegappan/lsp is much less committal
" than coc.nvim, and much more automagic. I actually want this.
" The two things we need to care about appear to be :LspCodeLens and
" :LspCodeAction. Both of them present options, unless provided with an
" index. It may make more sense to turn \qf into :LspCodeAction 0 or
" whatever, but this is fine for now.
" I also need to get LunarWatcher/lsp-installer.vim9 to work, because I
" only have clangd right now, and it doesn't support code lens for
" whatever reason, so no file actions.
" Really disappointing, but the same lack of functionality is present in
" coc.nvim - this is not the plugin's fault, it's clangd. The
" functionality might be provided by other linters or something instead.
" I've been meaning to integrate "import what you use" or whatever it's
" called again, just haven't got that far.
nmap <leader>qa :LspCodeLens<cr>
nmap <leader>qf :LspCodeAction<cr>
nmap <leader>qd :LspDiagCurrent<cr>
" autoComplete force trigger (currently disabled)
" inoremap <C-space> <C-\><C-o>:call lsp#completion#LspComplete(v:true)<cr>
" omniComplete force trigger
imap <C-space> <C-x><C-o>
nmap <leader>rn :LspRename<cr>
" TODO: Except references, these all seem to have both a goto and a peek
" variant. There's cases where both are useful
" There's also Show variants that seem to add to quickfix instead, which
" also seems useful for refactoring.
" There's just so much cool stuff that I've been wanting, and I just need
" to start somewhere for now.
nmap <silent> <leader>rd :LspGotoDefinition<cr>
nmap <silent> <leader>rD :LspGotoDeclaration<cr>
nmap <silent> <leader>rr :LspPeekReferences<cr>
nmap <silent> <leader>ri :LspPeekImpl<cr>
nmap <silent> <leader>rt :LspPeekTypeDef<cr>
nmap <silent> <leader>rs :LspSymbolSearch<cr>
nmap <silent> <leader>rf :LspFormat<cr>
vmap <silent> <leader>rf :LspFormat<cr>
" Show docs
" TODO: K conflicts with built-in K, which runs :!man <word under cursor>,
" which would be so nice to have (maybe?)
nnoremap <silent> K :LspHover<cr>
inoremap <C-k> <C-\><C-o>:LspShowSignature<cr>
nnoremap <silent> <leader>rc :LspServer restart<cr>
nnoremap <silent> <leader>hp :echoerr "Not implemented for yegappan/lsp"<cr>
" Set to enable custom completion types, and completion outside LSP
" buffers.
" FCompletePath matches the CompletePath function in this file.
" o matches the default omnicomplete function, which yegappan/lsp always
" sets
" TODO: autocomplete means complete is auto-invoked, but doesn't seem to
" be compatible with autoComplete from yegappan/lsp. For that to work,
" omnicomplete needs to be used instead, which adds a lot more noise.
" I still really want this built-in, though ctrl-N is enough to show the
" complete dialog. Can't map it to <C-space>, because that's the LSP force
" button.
"
set autocomplete
" TODO: figure out if adding tags back makes sense
set complete=F,o,FCompletePath,t,.,w,b
" noinsert is required so it doesn't forcibly insert arbitrary shit
" fuzzy is set to CLI::App{}->callback yields all the _callbacks
set completeopt=popup,menuone,noinsert,fuzzy
endfun
fun! LoadJSTS(type)
if a:type == "deno"
call LspAddServer([modules#lsp#Location("deno")])
else
call LspAddServer([modules#lsp#Location("tsserver")])
endif
endfun
fun! LoadYegappanLsp()
" TODO: re-add kotlin-lsp
" TODO: ccls support is blocked until https://github.com/MaskRay/ccls/issues/530 is resolved
let lsps = [
\ modules#lsp#Location("clangd"),
\ modules#lsp#Location("ty"),
\ modules#lsp#Location("luals"),
\ ]
" Remove LSPs that don't exist. This lets kotlin-lsp be enabled even
" though I only (plan to) use it at work.
call filter(lsps, 'v:val.path !~ "^/" || filereadable(v:val.path)')
for lsp in lsps
call s:SilentPrint("Active: " .. lsp.name)
endfor
" diagVirtualTextAlign is required to deal with a bug in "before", which
" causes the virtual text to contribute to the textwidth, and forces wrap
" on every single word, which is fucking infuriating.
"
" Snippet support is disabled due to a new <C-l> map that opens fzf with
" snippets instead. In retrospect, it's a lot more searchable than using
" the popup, and bypasses the fact that the lsp omnicomplete func is only
" set if an LSP is loaded
" The alternative is adding a custom function for it, but fzf exists and
" is just better, so I feel like this makes more sense. <C-t> also exists,
" so <C-l> and interactive search is not required.
call LspOptionsSet(#{
\ autoComplete: v:false,
\ codeAction: v:true,
\ completionMatcher: 'fuzzy',
\ diagVirtualTextAlign: 'below',
\ diagVirtualTextWrap: 'truncate',
\ diagNoOverrideSyntaxHighlighting: v:true,
\ omniComplete: v:true,
\ omniCompleteAllowBare: v:true,
\ noNewlineInCompletion: v:true,
\ showDiagWithSign: v:true,
\ showDiagWithVirtualText: v:true,
\ showInlayHints: v:true,
\ snippetSupport: v:false,
\ showSignature: v:true,
\ ultisnipsSupport: v:false,
\ useBufferCompletion: v:false,
\ usePopupInCodeAction: v:true,
\ popupBorder: v:true,
\ popupBorderChars: ['─', '│', '─', '│', '┌', '┐', '┘', '└'],
\ popupBorderHighlight: 'Identifier',
\ popupHighlight: 'Normal',
\ popupBorderSignatureHelp: v:false,
\ popupHighlightSignatureHelp: 'Pmenu',
\ })
call LspAddServer(lsps)
endfun
" }}}
if (UseJSShit == 0)
call PreloadYegappanLsp()
augroup LiviLspConfig
au!
autocmd User LspSetup call LoadYegappanLsp()
augroup END
command! LiviLspLoadDeno call LoadJSTS("deno")
command! LiviLspLoadTsserver call LoadJSTS("tsserver")
else
call LoadCocNvim()
endif
" }}}
" }}}
" Vimspector {{{
if !has("win32") && !has("win32unix")
let g:vimspector_enable_mappings = ''
let g:vimspector_install_gadgets = [ "vscode-cpptools", "vscode-js-debug" ]
nmap <leader>dc <Plug>VimspectorContinue
nmap <leader>ds <Plug>VimspectorStop
nmap <leader>dR <Plug>VimspectorRestart
nmap <leader>dr :VimspectorReset<cr>
nmap <leader>dp <Plug>VimspectorPause
nmap <leader>db :call vimspector#Launch()<cr>
nmap <leader>bb <Plug>VimspectorToggleBreakpoint
nmap <leader>bc <Plug>VimspectorToggleConditionalBreakpoint
nmap <Leader>bl <Plug>VimspectorBreakpoints
nmap <leader>dl :execute 'VimspectorLoadSession /tmp/' .. fnamemodify(getcwd(), ':t') .. '.session'<CR>
nmap <leader>dm :execute 'VimspectorMkSession /tmp/' .. fnamemodify(getcwd(), ':t') .. '.session'<CR>
endif
" }}}
" Autopair config {{{
let g:AutoPairsShortcutFastWrap = "<C-f>"
let g:AutoPairsMapBS = 0
let g:AutoPairsMapCR = 1
let g:AutoPairsMultilineFastWrap = 1
let g:AutoPairsMultilineClose = 0
let g:AutoPairsCompatibleMaps = 0
let g:AutoPairsStringHandlingMode = 2
let g:AutoPairsPreferClose = 0
call autopairs#Variables#InitVariables()
let g:AutoPairs = autopairs#AutoPairsDefine([
\ {"open": '\w\zs<', "close": '>', "filetype": ["cpp", "java"]},
\ {"open": "$", "close": "$", "filetype": "tex"},
\ {"open": '\left(', 'close': '\right)', "filetype": "tex"},
\ {"open": '\vclass .{-} (: (.{-}[ ,])+)? ?\{', 'close': '};', 'mapopen': '{', 'filetype': 'cpp', 'regex': 1},
\ {"open": "*", "close": "*", "filetype": ["help"]},
\ {"open": "|", "close": "|", "filetype": "help"},
\ ])
"let g:AutoPairs = autopairs#AutoPairsDefine([{'open': '\\(', 'close': '\)', 'filetype': 'tex'}])
if has_key(g:AutoPairsLanguagePairs["html"], "<")
unlet g:AutoPairsLanguagePairs["html"]["<"]
endif
let g:AutoPairsExperimentalAutocmd = 1
" }}}
" Undotree {{{
nnoremap <leader>ou :UndotreeToggle<cr>
" }}}
" Local vimrc {{{
" set exrc
" }}}
" Airline {{{
let g:airline_theme = "light"
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#formatter = 'default'
let g:airline_theme_patch_func = 'AirlineThemePatch'
function! AirlineThemePatch(palette)
if g:airline_theme == 'light'
" TODO: This isn't great, would be better to match whatever the last
" state was rather than fully reverting to normal mode, but this will
" have to work for now. " It makes the light colours usable, and it's
" such an expressive theme. I love it
" Making it kinda retain state requires stuff that isn't documented.
" extremely little appears to be documented (in airline.txt at least)
" about the contents and extended scripting with the palette.
let a:palette.inactive = a:palette["normal"]
endif
endfunction
" }}}
" Ultisnips {{{
let g:UltiSnipsSnippetDirectories = ["UltiSnips", "CustomSnippets"]
let g:UltiSnipsExpandTrigger="<C-t>"
let g:UltiSnipsJumpForwardTrigger="<C-j>"
let g:UltiSnipsJumpBackwardTrigger="<C-k>"
let g:UltiSnipsListSnippets="<C-u>"
" }}}
" Vista {{{ "
let g:vista_fzf_preview = ['right:50%']
let g:vista#renderer#enable_icon = 1
let g:vista#renderer#icons = {
\ "function": "\uf794",
\ "variable": "\uf71b",
\ }
" }}} Vista "
" FZF {{{
let g:fzf_layout = {
\ 'window':
\ {
\ 'width': 0.7,
\ 'height': 0.7,
\ 'highlight': 'Type',
\ 'border': 'rounded'
\ }
\ }
let g:CopyPastaTemplate = g:fzf_layout["window"]
let $FZF_DEFAULT_OPTS="--bind ctrl-a:select-all"
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit',
\ 'ctrl-o': 'tabe',
\ }
command! -bang -nargs=? -complete=dir HFiles call fzf#run(fzf#wrap({
\ 'source': "rg --hidden --glob '!.git' --files",
\ 'options': ['--layout=reverse'],
\ 'window': g:CopyPastaTemplate
\ }))
command! -bang -nargs=? -complete=dir HNGFiles call fzf#run(fzf#wrap({
\ 'source': "rg --hidden --no-ignore-vcs --glob '!.git' --files",
\ 'options': ['--layout=reverse'],
\ 'window': g:CopyPastaTemplate
\ }))
command! -bang -nargs=? -complete=dir CMakeFiles call fzf#run(fzf#wrap({
\ 'source': 'rg --hidden --ignore .git -g "CMakeLists.txt"',
\ 'options': ['--layout=reverse'],
\ 'down': '30%'
\ }))
command! -nargs=0 TODO grep! '(TODO\|FIXME)(\(.*\))?:?'
" Note to self: the documentation lies
" sinklist here forces a fallback
" TODO: create an equivalent for \zx. Fuzzy searching at a filename level gets
" too aggressive at times
command! -bang -nargs=* Search call fzf#vim#grep2(
\ "rg --hidden --glob '!.git' --column --line-number --no-heading --color=always --smart-case -- ",
\ <q-args>,
\ {
\ 'options': [
\ '--layout=reverse',
\ '--bind=enter:select-all+accept',
\ '--multi',
\ ],
\ 'down': '30%',
\ },
\ <bang>0
\ )
fun! s:AddCoAuthors(lines)
call map(a:lines, '"Co-Authored-By: " .. v:val')
" Force insertion on the current line and out rather than inserting a
" potentially blank line
call append(line('.') - 1, a:lines)
endfun
command! -bang -nargs=* AddGitCoAuthors call fzf#run(fzf#wrap({
\ 'source': "git log --format='%aN <%aE>' | sort -u",
\ 'down': '30%',
\ 'sinklist': function('s:AddCoAuthors')
\ }), <bang>0)
augroup GitCoAuthorHelper
au!
autocmd FileType gitcommit nnoremap <buffer> <leader>co :AddGitCoAuthors<cr>
augroup END
" Modified version of fzf.vim's :Rg and :RG that includes hidden files, while
" omitting .git. Necessary for several very relevant files to be searchable
command! -bang -nargs=* HRg call fzf#vim#grep("rg --hidden --glob '!.git' --column --line-number --no-heading --color=always --smart-case -- ".fzf#shellescape(<q-args>), fzf#vim#with_preview(), <bang>0)
command! -bang -nargs=* HRG call fzf#vim#grep2("rg --hidden --glob '!.git' --column --line-number --no-heading --color=always --smart-case -- ", <q-args>, fzf#vim#with_preview(), <bang>0)
command! -bang -nargs=1 RGGlob call fzf#vim#grep2("rg --hidden --glob '!.git' --glob '" .. <q-args> .. "' --column --line-number --no-heading --color=always --smart-case ", '', fzf#vim#with_preview(), <bang>0)
nnoremap <leader>zx :HFiles<cr>
nnoremap <leader>zX :HNGFiles<cr>
nnoremap <leader>zc :HRg<cr>
nnoremap <leader>zC :HRG<cr>
nnoremap <leader>zb :TODO<cr>
nnoremap <leader>zs :Search<cr>
nnoremap <leader>zgc :RGGlob !{*.md,LICENSE,*.txt,*.json,*.xml}<cr>
nnoremap <leader>zgp :RGGlob *.{c,cpp,h,hpp,cc}<cr>
nnoremap <leader>zgt :RGGlob *.{js,ts,tsx,jsx}<cr>
nnoremap <leader>zgj :RGGlob *.{java,kt}<cr>
nnoremap <leader>ocm :CMakeFiles<cr>
" Remap some of the defaults {{{
nnoremap <leader>zh :Helptags<cr>
inoremap <C-l> <C-o>:Snippets<cr>
nnoremap <leader>s :Snippets<cr>
" }}}
" }}} FZF
" fern.vim {{{
" Global settings
let g:fern#disable_default_mappings = 1
let g:fern#default_hidden = 1
let g:fern#disable_drawer_smart_quit = 1
let g:fern#drawer_width = 32
let g:fern#default_hidden = 1
let g:fern#renderer = "nerdfont"
let g:fern#renderer#nerdfont#indent_markers = 1
let g:fern#comparator = 'numeric'
" let g:fern#loglevel = g:fern#logger#DEBUG
let g:nerdfont#autofix_cellwidths = 1
" Global control mappings
nnoremap <F2> :execute ':Fern ' .. getcwd() .. ' -drawer -stay -toggle'<cr>
nnoremap <leader>fs :exec ':FernDo FernReveal ' .. expand('%')<cr>
nnoremap <F5> :exec ":FernDo normal \<F5> -stay"<cr>
"let g:fern#loglevel = g:fern#DEBUG
fun FernMaps()
nmap <buffer><expr> <Plug>(fern-cr)
\ fern#smart#Leaf(
\ "<Plug>(fern-action-open)",
\ "<Plug>(fern-action-expand:stay)",
\ "<Plug>(fern-action-collapse)",
\ )
" This is common sense, why isn't this default?
nmap <buffer> <CR> <Plug>(fern-cr)
nmap <buffer> <2-LeftMouse> <Plug>(fern-cr)
" Nerd-tree compatible mappings
nmap <buffer> s <Plug>(fern-action-open:vsplit)
nmap <buffer> h <Plug>(fern-action-open:split)
nmap <buffer> t <Plug>(fern-action-open:tabedit)
nmap <buffer> o <Plug>(fern-cr)
nmap <buffer> O <Plug>(fern-action-expand-tree:stay)
nmap <buffer> L <Plug>(fern-action-expand-tree:in)
" Filesystem maps
nmap <buffer> M <Plug>(fern-action-move)
nmap <buffer> C <Plug>(fern-action-copy)
nmap <buffer> N <Plug>(fern-action-new-path)
nmap <buffer> T <Plug>(fern-action-new-file)
nmap <buffer> D <Plug>(fern-action-new-dir)
nmap <buffer> dd <Plug>(fern-action-remove)
nmap <buffer> cd <Plug>(fern-action-enter)
" Fern-specific maps
nmap <buffer> <leader> <Plug>(fern-action-mark)
" Meta maps
" TODO: this won't move the cwd if it has changed
nmap <buffer> <F5> <Plug>(fern-action-reload)
endfun
" }}}
" Wintabs {{{
nnoremap <M-1> :WintabsGo 1<cr>
nnoremap <M-2> :WintabsGo 2<cr>
nnoremap <M-3> :WintabsGo 3<cr>
nnoremap <M-4> :WintabsGo 4<cr>
nnoremap <M-5> :WintabsGo 5<cr>
nnoremap <M-6> :WintabsGo 6<cr>
nnoremap <M-7> :WintabsGo 7<cr>
nnoremap <M-8> :WintabsGo 8<cr>
nnoremap <M-9> :WintabsGo 9<cr>
nnoremap <M-0> :WintabsLast<cr>
nnoremap <C-PageUp> :WintabsPrevious<cr>
nnoremap <C-PageDown> :WintabsNext<cr>
" Remaps <leader>q to closing a single tab. Using :q closes the entire buffer,
" including all other tabs nested within it. :WintabsClose closes one. All the
" buffers live on if :q is used instead of <leader>q, but they're not nested
" in the same way.
nnoremap <leader>qt :WintabsClose<cr>
let g:wintabs_ui_vimtab_name_format = ' %n %t '
" }}}
" Vimtex {{{
let g:tex_flavor = "latex"
let g:vimtex_compiler_clean_paths = ['_minted*']
let g:vimtex_compiler_latexmk = {
\ 'options' : [
\ '-shell-escape',
\ '-verbose',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ],
\}
" }}}
" }}}
" Formatter config {{{
let g:html_indent_style1 = "inc"
" }}}
" Config {{{
" Basic enabling {{{
set nowrap " Soft wrapping is annoying
set smartcase " Search enhancements
filetype plugin indent on
filetype plugin on
syntax enable
set incsearch " Along withsearch highlighting, it shows search results while typing
set hlsearch " Search highlighting
set splitright
set wildmenu " GUI popup for command autocomplete options
if has("patch-8.2.4325")
set wildoptions=pum
end
set number " Line numbers
set laststatus=2
set cursorline " Active line highlighting - because it's nice
set hidden
set autoindent
set showcmd " Helps managing leader timeout
set scrolloff=5 " Lines over and under the cursor when scrolling
set list
set listchars=tab:→\ ,nbsp:•
" Deals with annoying editing conceal
set concealcursor=
set conceallevel=0
" Enable the mouse
set mouse=a
" Show a search count
set shortmess-=S
" Look at all the pretty colors
if has("termguicolors")
" I still find it funny that I haven't touched this part of my vimrc
" since I wrote it, and I have yet to use a single terminal where
" termguicolors has been unavailable.
set termguicolors " Required for true color terminals. If statement for compat
else
set t_Co=256
endif
" Fix backspace issues
set backspace=indent,eol,start " backspace over everything in insert mode"
" Fix that horrid arrow nav issue
set whichwrap+=<,>,h,l,[,]
" Welcome to 2024
set smoothscroll
" }}}
" Configure wrapping {{{
" Wrapping is disabled by default, but it's still used in a few places because
" it does have practical uses.
" Of course, though, there's config to make it less crap :D
augroup CustomWrap
au!
autocmd FileType text,markdown,tex setlocal wrap
augroup END
" I don't remember what this is for
set linebreak
" Indent broken lines
set breakindent
" Highlight broken lines
set showbreak=>>
" Remove @ on wrapped lines
set display=lastline
" Wrap maps
inoremap <C-up> <C-o>g<up>
inoremap <C-down> <C-o>g<down>
nnoremap <Up> gk
nnoremap <Down> gj
vnoremap <Up> gk
vnoremap <Down> gj
" }}}
" Configure indents {{{
set cindent
set cino=N-s
set cino+=g0,l1
set cino+=(0
set cino+=k4,m1,W4,j1
" }}}
" Add non-standard filetypes {{{
augroup OFiletypes
au!
autocmd BufRead,BufNewfile conanfile.txt set filetype=dosini.conanfile
autocmd Bufread,BufNewFile *.trconf set ft=json
autocmd BufRead,BufNewFile *.vert,*.frag set ft=glsl
" TODO: why isn't this default? The syntax is supported out of the box
" (polyglot?), but the .kdl extension is not
autocmd BufRead,BufNewFile *.kdl set ft=kdl
augroup END
" }}}
" Themes and visual configurations {{{
set background=light " Color scheme variant
let g:PaperColor_Theme_Options = {
\ 'language': {
\ 'cpp': { 'highlight_standard_library': 1 }
\ }
\ }
" Colorschemes + alternate variants
" =================================
colorscheme PaperColor " Color scheme
"colorscheme one
"colorscheme onedark
"colorscheme onehalfdark
"colorscheme onehalflight
"colorscheme seoul256-light
"colorscheme two-firewatch
"colorscheme Aurora
" =================================
" General light, not paper {{{
"let g:terminal_ansi_colors = ['#eeeeee', '#af0000', '#008700', '#5f8700',
"\ '#0087af', '#878787', '#005f87',
"\ '#444444', '#bcbcbc', '#d70000', '#d70087', '#8700af',
"\ '#d75f00', '#d75f00', '#005faf', '#005f87']
" }}}
"}}}
" Anti-tab squad {{{
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set smartindent
augroup TabConf
au!
" Make is specific about using tabs
autocmd FileType make setlocal noexpandtab
autocmd FileType yaml setlocal tabstop=2 shiftwidth=2 softtabstop=2
autocmd FileType typescript,typescriptreact,javascriptreact setlocal sw=2 tabstop=2 softtabstop=2
augroup END
" }}}
" Cursor config {{{
if has("gui_running")
hi iCursor guibg=#e00d93
hi Cursor guibg=purple
hi Visual guibg=#b19cd9
set guicursor=n-v-c:block-Cursor-blinkon530-blinkwait530-blinkoff530
set guicursor+=i:ver20-iCursor-blinkon530-blinkwait530-blinkoff530