-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc.vim
More file actions
2039 lines (1693 loc) · 61.6 KB
/
vimrc.vim
File metadata and controls
2039 lines (1693 loc) · 61.6 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
if filereadable(expand('~/.vim/settings.vim'))
source ~/.vim/settings.vim
endif
if ! exists('g:vim_peter')
let g:vim_peter = 1
endif
if ! exists('g:want_fast')
let g:want_fast = 0
endif
if ! exists('g:hackymappings')
let g:hackymappings = 0
endif
" sensible defaults to start with
if &compatible
setglobal nocompatible
endif
let s:dotfiles_root = expand('<sfile>:p:h')
" NOTE: this is needed in one of the Lua LSP initialisers
let g:pete_dotfiles_root = s:dotfiles_root
set confirm
" 256-color mode for vim8/neovim
if exists('&termguicolors')
" NOTE: this needs to be set at startup
set termguicolors
" NOTE: I had to manually set these options to get truecolor to work in vim8
" in iTerm2/tmux, but I think I actually prefer sticking with 256-color mode
" in regular vim because it helps me figure out which one I'm using ...
if ! has('nvim')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
" vim8 needs explicit terminal codes if we want cursor shape changing to
" work
if ! has('nvim')
let &t_SI = "\<Esc>[6 q"
let &t_SR = "\<Esc>[4 q"
let &t_EI = "\<Esc>[2 q"
endif
elseif has('nvim') && &term == 'screen'
" TODO: what was this for?
"set term=screen-256color
endif
" we need to work out what tmux session we're running under
let g:tmux_session = ''
if executable('tmux') && exists('*systemlist')
" NOTE: I experienced a bug where vim 8.0.007's systemlist() would return an
" empty list, but only during startup
let s:result = systemlist('tmux display-message -p "#S"')
if type(s:result) == type([]) && len(s:result)
let g:tmux_session = s:result[0]
endif
endif
" runtimepath modifications {{{
if g:allow_rtp_modify
" if we are using neovim, we have to manually add ~/.vim to rtp
if has('nvim')
let &runtimepath = '~/.vim,' . &runtimepath . ',~/.vim/after'
endif
" for backwards compatibility
if get(g:, 'use_edit_real_path', 0)
" TODO: convert this to its own project
let g:editrealpath#strategy = 'enew'
augroup EditRealPath
augroup end
" Note: this can't be BufReadPre because otherwise E201 is raised for
" changing the current buffer
autocmd! EditRealPath BufReadPost * nested call editrealpath#EditRealPath()
endif
" add our own vim/ and vim-multi-python/ folders to runtimepath
let s:specials = ['vim', 'vim-multi-python', 'vim-git-magic']
for s:name in s:specials
let s:local = expand('<sfile>:h').'/'.s:name
let &runtimepath = printf('%s,%s,%s/after', s:local, &runtimepath, s:local)
endfor
unlet s:specials
unlet s:name
unlet s:local
" add the <vim-est> thing if it is present
if isdirectory(expand('~/src/vim-est.git'))
let &runtimepath = &runtimepath . ','.expand('~/src/vim-est.git')
endif
" vimstatic area for things we may download manually
let &runtimepath = '~/.vimstatic,' . &runtimepath
endif
" }}}
fun! <SID>VendoredPlug(path)
let l:parts = split(a:path, '/')
let l:name = l:parts[1]
let l:newpath = s:dotfiles_root . '/vim-packages/' . l:name . '.git'
if g:allow_rtp_modify
let &runtimepath = l:newpath . ',' . &runtimepath . ',' . l:newpath . '/after'
endif
endfun
" per-project config
call <SID>VendoredPlug('phodge/vim-project-config')
let s:config_dirs = get(g:, 'mydots_additional_project_config_paths', {})
let s:config_dirs.Personal = s:dotfiles_root . '/vimproject'
call vimprojectconfig#initialise({
\ 'project_config_dirs': s:config_dirs,
\ })
unlet s:config_dirs
let s:use_copilot_chat = 0
if $GIT_REBASING == "1"
let g:git_rebasing = 1
else
let g:git_rebasing = 0
endif
if has('nvim') && g:want_copilot
if ! g:git_rebasing
call <SID>VendoredPlug('github/copilot.vim')
endif
" the default mapping for Copilot is <tab>, to change it see
" :help copilot-maps
imap <silent><script><expr> <S-TAB> copilot#Accept("\<CR>")
let g:copilot_no_tab_map = v:true
" disable copilot for certain filetypes
aug PeterCopilot
au! BufReadPost,BufNewFile *.txt,*.md,*.csv let b:copilot_enabled = 0
aug end
" NOTE: you may need to set g:copilot_node_command if you have an old
" version of node set as default
if $EXP_NVIM_COPILOT_CHAT == "1"
let s:use_copilot_chat = 1
endif
endif
if has('nvim') && g:want_neovim_treesitter " {{{ tree-sitter
if ! g:git_rebasing
call <SID>VendoredPlug('nvim-treesitter/nvim-treesitter')
call <SID>VendoredPlug('nvim-treesitter/nvim-treesitter-playground')
endif
let g:peter_ts_disable = []
if ! g:want_neovim_treesitter_python
call add(g:peter_ts_disable, 'python')
endif
lua <<EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
custom_captures = {
},
disable = vim.g.peter_ts_disable,
additional_vim_regex_highlighting = false,
},
playground = {
enable = true,
updatetime = 25,
persist_queries = false,
keybindings = {
},
},
ensure_installed={
"typescript",
"tsx",
"javascript",
"python",
"vim",
"vimdoc",
"lua",
},
}
EOF
" NOTE: so if you want treesitter to work you also need to run ...
" :TSInstall typescript
" :TSInstall tsx
" :TSInstall javascript
" :TSInstall python
" use e.g. "TSInstall typescript" to install a specific parser
" also set up ts-node-action while we're here
if ! g:git_rebasing
call <SID>VendoredPlug('CKolkey/ts-node-action')
endif
lua vim.keymap.set({"n"}, "\\x", require("ts-node-action").node_action, { desc = "Trigger Node Action" })
lua <<EOF
local actions = require 'ts-node-action.actions'
require'ts-node-action'.setup {
}
EOF
endif " }}}
" set up Vundle if it's present and not in &rtp yet
let s:plugpath = $HOME.'/.vim/autoload/plug.vim'
if filereadable(s:plugpath)
" use different path depending on vim/nvim
let s:plugins = has('nvim') ? '~/.nvim/plugged' : '~/.vim/plugged'
call plugmaster#begin('~/src/plugedit', '~/src', s:plugins) " {{{
if g:tmux_session == 'SPACETEA-DEV'
call <SID>VendoredPlug('phodge/spacetea.vim')
endif
" copilot chat
if s:use_copilot_chat && !g:git_rebasing
" NOTE: this also requires plenary.nvim but I don't have a way to
" specificy dependencies yet
call <SID>VendoredPlug('CopilotC-Nvim/CopilotChat.nvim')
call <SID>VendoredPlug('nvim-lua/plenary.nvim')
endif
" firenvim
if get(g:, 'peter_want_firenvim', 0) && !g:git_rebasing
" see https://github.com/glacambre/firenvim for instructions on how to
" configure
call <SID>VendoredPlug('glacambre/firenvim')
endif
if has('nvim') && ! g:git_rebasing
if has('nvim-0.10.0')
call <SID>VendoredPlug('neovim/nvim-lspconfig')
else
call <SID>VendoredPlug('neovim/nvim-lspconfig-old')
endif
call <SID>VendoredPlug('jose-elias-alvarez/null-ls.nvim')
" provides :TSLspImportCurrent, TSLspRenameFile, TSLspOrganize
call <SID>VendoredPlug('jose-elias-alvarez/nvim-lsp-ts-utils')
" plenary.nvim is required for the nvim-lsp-ts-utils plugin
call <SID>VendoredPlug('nvim-lua/plenary.nvim')
endif
if ! has('nvim-0.9.0') && !g:git_rebasing
" this is built into neovim from v0.9 onwards
call <SID>VendoredPlug('editorconfig/editorconfig-vim')
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
endif
" the awesome Jedi library for python
" XXX: we manage this with vim-plug because vim-plug takes care of
" initialising jedi's own submodules
Plug 'davidhalter/jedi-vim'
" Note: we leave the plugin un-initialised by default and disable most of
" the keymaps so that it is easier to ensure all keymaps are superseded by
" LSP keymaps when those are activated in a particular buffer.
" BUT this means we do need to manually ...
" - set 'omnifunc' for python buffers
" - create our own mappings to jedi commands
" - call jedi#configure_call_signatures() if we want that feature?
" - We possibly need to define :Pyimport ourselves if we want that command
" available
let g:jedi#auto_initialization = 0
" sets 'completeopt' for us, I don't *think* we want this?
let g:jedI#auto_vim_configuration = 0
" we probably want to have this ON but we need to document how to turn it
" off for larger projects
" ALTHOUGH: it is probably not effective because I have set #auto_initialization = 0 above
let g:jedi#popup_on_dot = 0
" other jedi configuration
let g:jedi#use_splits_not_buffers = "winwidth"
" NOTE: I'm disabling call signatures because A) it doesn't seem to work and
" B() vim isfreezing and I don't know why
let g:jedi#show_call_signatures = 0
let g:jedi#smart_auto_mappings = 0
" ALE setup {{{
if ! g:git_rebasing
call <SID>VendoredPlug('w0rp/ale')
endif
" default behaviour is to use flake8/mypy from our virtualenv
" TODO(DOTFILES049) redo this - not sure this is what we want
let g:ale_python_flake8_executable = expand('~/.venv/vim-python-tools/bin/flake8')
let g:ale_python_mypy_executable = expand('~/.venv/vim-python-tools/bin/mypy')
" tell ALE it can invoke commands using poetry
let g:ale_python_auto_poetry = 1
if get(g:, 'use_ale_dmypy')
" tell ale to use dmypy instead of mypy
" WARNING: see notes in mydots-configure
let g:ale_python_mypy_use_global = 1
let g:ale_python_mypy_executable = 'dmypy'
let g:ale_python_mypy_options = 'run -- '
endif
let g:ale_linters = get(g:, 'ale_linters', {})
if ! exists('g:ale_linters.python')
" XXX: disable ruff linting by default because it's experimental and
" frequently raises error due to being invoked the wrong way
let g:ale_linters.python = ['flake8', 'mypy']
endif
" turn off ALE in fugitive:// buffers
aug NoALEInFugitiveBuffers | aug end
au! NoALEInFugitiveBuffers BufRead fugitive://* let b:ale_enabled = 0
" Disable markdownlint by default; To bring it back for a project, add
"
" this to your project config:
" if &l:filetype == 'markdown'
" let b:ale_markdown_markdownlint_executable = 'markdownlint'
" ALELint
" endif
let g:ale_markdown_markdownlint_executable = 'markdownlint_disabled_vimrc'
" }}}
" ArgWrap {{{
" TODO: would be good if we could outsource this to the LS
call <SID>VendoredPlug('FooSoft/vim-argwrap')
let g:argwrap_tail_comma = 1
nnoremap <space>a :ArgWrap<CR>
" }}}
if has('macunix') " Kapeli Dash docs viewer for Mac {{{
Plug 'rizzatti/dash.vim'
nnoremap <S-F5> :Dash <cword><CR>
endif " }}}
" nginx syntax
if ! g:git_rebasing
call <SID>VendoredPlug('chr4/nginx.vim')
endif
" graphql stuff
Plug 'jparise/vim-graphql'
if ! g:want_fast && !g:git_rebasing
call <SID>VendoredPlug('EinfachToll/DidYouMean')
call <SID>VendoredPlug('hynek/vim-python-pep8-indent')
if ! g:want_neovim_treesitter_python
" XXX: Note: this can be slow for large files, so you may want to
" disable it (set foldmethod=indent) if there are >2000LOC
call <SID>VendoredPlug('tmhedberg/SimpylFold')
endif
endif
call <SID>VendoredPlug('christoomey/vim-tmux-navigator')
" python imports {{{
" adds :ImportName and :ImportNameHere commands
" XXX: I haven't been using this and it has a big startup cost (250ms?) so
" am disabling for now
"Plug 'mgedmin/python-imports.vim'
" }}}
" python requirements.txt syntax highlighting
call <SID>VendoredPlug('raimon49/requirements.txt.vim')
" python code formatting via Black
" XXX: I've had to uninstall this because it doesn't set up the virtualenv
" correctly for nvim
"Plug 'psf/black'
aug FakeBlack
au!
au! BufRead *.py command! -buffer Black !black %:p
aug end
" make inactive windows dim slightly
let g:vimade = get(g:, 'vimade', {})
let g:vimade.fadelevel = 0.5
let g:vimade.basebg = '#000000'
if $FEAT_VIM_VIMADE == '1' && ! g:git_rebasing
call <SID>VendoredPlug('TaDaa/vimade')
endif
if has('nvim') && get(g:, 'want_neovim_snippy', 0)
" NOTE: you can find links to more snippets plugins here:
" https://github.com/honza/vim-snippets
call <SID>VendoredPlug('dcampos/nvim-snippy')
" NOTE: we can't use SHIFT+TAB for snippy any more because we need it for
" Copilot
imap <expr> <Tab> snippy#can_expand_or_advance() ? '<Plug>(snippy-expand-or-advance)' : '<Tab>'
" imap <expr> <S-Tab> snippy#can_jump(-1) ? '<Plug>(snippy-previous)' : '<S-Tab>'
smap <expr> <Tab> snippy#can_jump(1) ? '<Plug>(snippy-next)' : '<Tab>'
" smap <expr> <S-Tab> snippy#can_jump(-1) ? '<Plug>(snippy-previous)' : '<S-Tab>'
xmap <Tab> <Plug>(snippy-cut-text)
elseif has('nvim') && v:version >= 704
Plug 'SirVer/ultisnips', v:version >= 704 ? {} : {'on': []}
" this is CTRL+J by default, which we don't want
let g:UltiSnipsJumpForwardTrigger = '<space><C-J>'
else
" NOTE: we need to use the older SnipMate on vim because UltiSnips keeps
" producing errors in vim 8.1
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
" required to get rid of the SnipMate-deprecate warning on startup
" (See :help SnipMate-deprecate)
let g:snipMate = { 'snippet_version': 1 }
endif
Plug 'sjl/Clam.vim'
Plug 'tmux-plugins/vim-tmux'
Plug 'easymotion/vim-easymotion'
" TODO: revisit this and see if we can get some nice mappings up
Plug 'brooth/far.vim'
let s:has_fzf = 0
if 1
" TODO(DOTFILES050) this should supersede all the other fancy stuff below
" for figuring out fzf path
if exists('g:peter_fzf_install_path') && g:peter_fzf_install_path != ''
let &rtp .= ',' . g:peter_fzf_install_path
let s:has_fzf = 1
endif
elseif has('nvim') && get(g:, 'use_vendored_fzf', 0)
" use vendored version of FZF since the brew version (0.44.1) is having
" issues
let s:has_fzf = 1
let &rtp .= ',' . s:dotfiles_root . '/vim-packages/fzf.git'
elseif has('nvim') && isdirectory('/usr/local/opt/fzf')
" homebrew will install fzf in /opt/homebrew/bin/fzf
" (or in older versions of homebrew /usr/local/opt/fzf)
let s:has_fzf = 1
" use vim plugin provided by fzf homebrew package
set rtp+=/usr/local/opt/fzf
elseif has('nvim') && isdirectory($HOME . '/src/fzf.git')
" on Ubuntu fzf should be installed into ~/src/fzf.git
let s:has_fzf = 1
let g:fzf_dir = $HOME . '/src/fzf.git'
let &rtp .= ',' . g:fzf_dir
elseif has('nvim') && executable('fzf')
let s:has_fzf = 1
let &rtp .= ',' . expand('/opt/homebrew/Cellar/fzf/*')
endif
if s:has_fzf
nnoremap <C-P> :FZF<CR>
let g:fzf_layout = {'window': {'width': 0.8, 'height': 0.8}}
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit',
\ }
" I just want to be able to hit enter to open a file in a new split
let g:fzf_action['enter'] = 'split'
else
Plug 'ctrlpvim/ctrlp.vim'
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
endif
" Use `:DiffviewFileHistory %` to get a history of the current buffer
" See `:h diffview` for other git history commands
Plug 'sindrets/diffview.nvim'
" git-gutter
if has('signs') && v:version >= 704
Plug 'airblade/vim-gitgutter'
" make it disabled by default, by toggle-able by space-g
let g:gitgutter_enabled = 0
nnoremap <space>g :GitGutterToggle<CR>:echomsg 'Use ]c and [c to move between hunks'<CR>
" NOTE: you can also use ]c and [c to move to next/previous hunks
" reduce CursorHold time from 4s to .25s for faster gutter response
set updatetime=250
else
nnoremap <space>g :echoerr 'vim-gitgutter is not installed'<CR>
endif
" Cython
Plug 'lambdalisue/vim-cython-syntax'
Plug 'vim-scripts/sudo.vim'
"Plug 'justinmk/vim-sneak'
" for ansible
Plug 'pearofducks/ansible-vim'
" additional motions/targets:
" "quote": '"`
" "separator": , . ; : + - = ~ _ * # / | \ & $
" "pair": one of the following: b() B{} [] <> t <quote> <separator>
" If you use n<pair>, cursor will seek forward to the next pair,
" l<pair> seeks to the last pair. Otherwise, cursor searches for a
" pair on the current line.
" The quote pairs try to be smarter than vim's.
" "in pair": i<pair>
" select everything inside the pair:
" "Inside pair": I<pair>
" like "in pair" but excludes whitespace
" "a pair": a<pair>
" Select everything including the pair. Noteably, the quote pairs
" don't include surrounding whitespace by default any more.
" "Around pair": A<pair>
" like "a pair" but also selects either trailing/leading
" whitespace.
" "arguments":
" ia select a func argument without the comma
" Ia select a func argument without the comma or whitespace
" aa select a func argument and its comma
" Aa select a func argument and delimiters on both ends?
Plug 'wellle/targets.vim', g:want_fast ? {'on': []} : {}
" skip gutentags when there is no ctags executable installed
let g:gutentags_ctags_tagfile = '.tags'
let g:gutentags_ctags_exclude = [
\ '.mypy_cache',
\ '*.min.js',
\ '*-min.js',
\ '*.map.js',
\ '*-map.js',
\ ]
let g:gutentags_generate_on_empty_buffer = 1
" disable file types that add noise to the tag file
let g:gutentags_ctags_extra_args = [
\ '--languages=-html,svg,markdown,json,sql,css',
\ ]
Plug 'ludovicchabant/vim-gutentags', executable('ctags') && v:version >= 704 ? {} : {'on': []}
" configure gutenttags to use git ls-files to find files ... I don't know why this isn't the
" default
let g:gutentags_file_list_command = {
\ 'markers': {
\ '.git': 'git ls-files --cached --others --exclude-standard',
\ },
\ }
" use vim-projectroot to figure out the project root
let g:gutentags_project_root_finder = 'projectroot#get'
Plug 'majutsushi/tagbar', g:want_fast ? {'on': []} : {}
nnoremap <space>n :TagbarToggle<CR>
let g:tagbar_width = 60
" go to next ALE error. We use :ALENextWrap instead of :ALEFirst because often I can fix a bug and
" hit '\a' again before ale has re-linted and removed the current error.
" TODO: DOTFILES013: would be good to have this call :ALENextWrap and then
" use vim.diagnostic.goto_next() if the cursor doesn't move - in case we are
" using multiple linting engines
nnoremap \a :exe (get(b:, 'ale_enabled', 1) ? 'ALENextWrap' : 'lua vim.diagnostic.goto_next()')<CR>
if get(g:, 'clipchamp_js', 0)
" just use my own javascript syntax
call <SID>VendoredPlug('phodge/vim-javascript-syntax')
" TODO: this doesn't always take precedence - the builtin filetype
" detection takes precedence for Skylight windows and the buffer ends up
" with builtin ft=typescript syntax
aug TypeScriptTSX
aug end
autocmd! TypeScriptTSX BufNewFile,BufRead *.{ts,tsx} set filetype=javascript
" TODO(DOTFILES068): decide whether there's any value keeping this stuff
if 0
Plug 'https://github.com/HerringtonDarkholme/yats.vim'
hi! link typescriptAssign Operator
hi! link typescriptTypeAnnotation Function
hi! link typescriptUnaryOp Operator
hi! link typescriptBinaryOp Number
hi! link typescriptDotNotation Operator
endif
elseif has('nvim') && g:want_neovim_treesitter
" don't do anything if we are using treesitter syntax
elseif 1
" XXX: this is my new config for FudgeMoney
call <SID>VendoredPlug('phodge/vim-javascript-syntax')
" typescript support
" XXX: this seems like it would be important but I'm not really sure what
" it was giving me
if 0
Plug 'leafgarland/typescript-vim', {'on': []}
endif
elseif 1
" TODO: delete this section when we're more confident we don't need it
call <SID>VendoredPlug('phodge/vim-javascript-syntax')
" TODO: this doesn't always take precedence - the builtin filetype
" detection takes precedence for Skylight windows and the buffer ends up
" with builtin ft=typescript syntax
aug TypeScriptTSX
aug end
" XXX: this messes with the language server stuff so we need to scrap it
if has('nvim')
autocmd! TypeScriptTSX BufNewFile,BufRead *.{ts,tsx} set syntax=javascript
else
autocmd! TypeScriptTSX BufNewFile,BufRead *.{ts,tsx} set filetype=javascript
endif
" typescript support
Plug 'leafgarland/typescript-vim', {'on': []}
" tsx syntax as well
Plug 'peitalin/vim-jsx-typescript', {'on': []}
else
Plug 'pangloss/vim-javascript'
Plug 'othree/javascript-libraries-syntax.vim'
let g:used_javascript_libs = 'jquery,angularjs'
" typescript support
Plug 'leafgarland/typescript-vim'
endif
" javascript/typescript imports {{{
" TODO finish this
" adds :SortImport command for .js files
" TODO: should we use https://github.com/Galooshi/import-js project
" instead?
"Plug 'ruanyl/vim-sort-imports'
" }}}
call <SID>VendoredPlug('phodge/vim-python-syntax')
" don't escape '$' because it will break grep '...$' end-of-line matching
let g:shell_command_escape_chars = '%#!'
call <SID>VendoredPlug('phodge/vim-shell-command')
" MySchema
nnoremap gss :call MySchema#GetSchema(expand('<cword>'))<CR>
command! -nargs=0 SQLWindow call MySchema#SQLWindow()
call <SID>VendoredPlug('phodge/vim-myschema')
call <SID>VendoredPlug('phodge/MicroRefactor')
call <SID>VendoredPlug('phodge/vim-syn-info')
PlugMaster 'phodge/vim-split-search'
" XXX: disabling this for now because it jumps us off the first tab page on
" startup
" PlugMaster 'phodge/vim-auto-spell'
PlugMaster 'phodge/vim-vimui'
PlugMaster 'phodge/vim-vcs'
Plug 'lumiliet/vim-twig'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-obsession'
Plug 'tpope/vim-repeat'
Plug 'AndrewRadev/linediff.vim'
" Debugger
if g:peter_give_me_a_debugger
Plug 'sakhnik/nvim-gdb', {'do': '!./install.sh'}
"Plug 'puremourning/vimspector'
endif
" Google Terraform syntax
if g:peter_want_terraform_plugins
Plug 'hashivim/vim-terraform'
endif
" Skylight
if has('nvim')
Plug 'https://github.com/voldikss/vim-skylight'
"nnoremap <silent> go :SkylightJumpTo<CR>
nnoremap <silent> gp :SkylightPreview<CR>
nmap <silent><expr> <C-n> skylight#float#has_scroll() ? skylight#float#scroll(1) : "\<C-n>"
exe 'nmap <silent><expr> <C-p> '
\ 'skylight#float#has_scroll() ? skylight#float#scroll(0) : '
\ '"' . (s:has_fzf ? ":FZF\<CR>" : ":CtrlP\<CR>") . '"'
else
nnoremap gp :echoerr 'Skylight requires neovim'
endif
" CSV plugin
" :WhatColumn
" what column number is the cursor in, or the heading if "!" is included
" :SearchInColumn <nr> /pat/
" Search for a value in a particular column
" :HiColumn[!] [<nr>]
" Highlight column <nr> or the current column. "!" removes highlighting
" :DeleteColumn [<nr>]
" Remove column <nr> or the current column.
" :Header <count>
" Add a split window that shows the first <count> lines of the file.
" :ArrangeColumn
" Rewrite the entire file to be vertically aligned
" :NewDelimiter <char>
" Set the delimiter to <char>
" HLKJ
" Move left/right between cells or up/down staying within the same column
" See also https://github.com/chrisbra/csv.vim#commands
Plug 'chrisbra/csv.vim'
" Minimap!
" TODO: make a faster version of this?
"Plug 'severin-lemaignan/vim-minimap'
" we don't necessarily want automatic stripping, but the highlighting will
" be helpful
Plug 'tweekmonster/wstrip.vim'
" :HelpfulVersion PATTERN for version info about features matching PATTERN
Plug 'tweekmonster/helpful.vim'
if has('conceal') && !g:want_fast
" show vertical lines to indicate indent level
call <SID>VendoredPlug('Yggdroot/indentLine')
" stop making JSON quotes disappear
let g:indentLine_fileTypeExclude = ['help', 'json', 'markdown']
endif
" TODO: also try 'nathanaelkane/vim-indent-guides'
" cool rust stuff
if g:peter_want_rust_plugins
Plug 'rust-lang/rust.vim'
" let rust automatically reformat my code on save
let g:rustfmt_autosave = 1
endif
" we also need this for the Cargo.toml files
call <SID>VendoredPlug('cespare/vim-toml')
let g:dispatch_quickfix_height = 10
Plug 'tpope/vim-dispatch'
" FIXME: I should make my own github repos from these
Plug 'vim-scripts/StringComplete'
Plug 'vim-scripts/InsertChar'
Plug 'vim-scripts/AfterColors.vim'
" php - insert/sort Use statements automatically {{{
if g:peter_want_php_plugins
Plug 'arnaud-lb/vim-php-namespace'
aug PHPStuff
au!
au FileType php nnoremap <buffer> <space>i :call PhpInsertUse()<CR>
au FileType php nnoremap <buffer> <space>e :call PhpExpandClass()<CR>
au FileType php com! -buffer SortUseStatements call PhpSortUse()<CR>
aug end
endif
" }}}
" custom PHP syntax - causes problems when g:php_show_semicolon_error is
" turned on though
if g:peter_want_php_plugins && ! g:peter_use_builtin_php_syntax
PlugMaster 'phodge/php-syntax.vim'
let g:php_show_semicolon_error = 0
let g:php_alt_construct_parents = 1
let g:php_alt_arrays = 2
let g:php_highlight_quotes = 1
let g:php_alt_properties = 1
let g:php_smart_members = 1
endif
" helps with working on neovim itself
if g:peter_want_nvimdev_plugin
call <SID>VendoredPlug('neovim/nvimdev.nvim')
endif
" I don't need the auto-ctags feature because gutentags does this for me
let g:nvimdev_auto_ctags = 0
" to all the time
Plug 'vim-scripts/Align', {'frozen': 0}
if g:tmux_session == 'NEOSITTER'
PlugMaster 'phodge/neovim-tree-sitter'
endif
" fast/live grep {{{
Plug 'dyng/ctrlsf.vim'
" Press ENTER to open a fiel in results window, CTRL+C to cancel
com! -nargs=+ S CtrlSF <args>
" }}}
" use <C-X><C-U> to complete things from other tmux panes/windows
call <SID>VendoredPlug('wellle/tmux-complete.vim')
" vim-projectroot is used for Gutentags config below
call <SID>VendoredPlug('phodge/vim-projectroot')
" tell vim-projectroot that when a file is part of a git repo that is a
" submodule of another git repo, the parent git repo should be considerd the
" project root
let g:projectroot_nested_git_submodule = 1
" NOTE: This isn't wasn't as useful as I'd hoped - it only looks at file
" extensions so is less useful for things like the MySU ORM/YAML files where
" more powerful manipulation is required
" Plug 'https://github.com/vim-scripts/a.vim'
" nvim-colorizer: highlights #RRGGBB hex codes for these file types:
if has('nvim-0.3.0') && !g:want_fast
Plug 'https://github.com/norcalli/nvim-colorizer.lua.git', {'for': ['css', 'scss', 'vim', 'html']}
autocmd! User nvim-colorizer.lua lua require'colorizer'.setup {css = {css = true}; scss = {css = true}, 'vim', 'html'}
endif
" vim-gh-line - open the current file/line on github/gitlab etc
" See also: https://github.com/tyru/open-browser-github.vim
" Use :GHInteractive to open the current line in github or :GBInteractive to
" open Blame view
let g:gh_line_map_default = 0
let g:gh_line_blame_map_default = 0
let g:gh_line_repo_map_default = 0
Plug 'https://github.com/ruanyl/vim-gh-line'
if has('nvim')
" other init stuff that only works for nvim+lua
exe printf('source %s/vimlua/startup.lua', s:dotfiles_root)
call v:lua.mydots_init_plugins(s:)
endif
" TODO: have a crack at some of these plugins
" Plug 'chrisbra/NrrwRgn'
" https://github.com/prettier/prettier
" https://github.com/tpope/vim-projectionist
" https://github.com/danro/rename.vim
" https://github.com/shougo/deoplete.nvim
" https://github.com/xolox/vim-session
" https://github.com/vim-scripts/grep.vim
" https://github.com/michaeljsmith/vim-indent-object
" https://github.com/andrewradev/splitjoin.vim
" https://github.com/vim-airline/vim-airline
" https://vimawesome.com/plugin/ack-vim
" https://vimawesome.com/plugin/commentary-vim
" https://vimawesome.com/plugin/jedi-vim
" https://vimawesome.com/plugin/vim-easy-align
" https://github.com/numirias/semshi
" https://github.com/erikfercak/php-search-doc
" https://github.com/beanworks/vim-phpfmt
" https://github.com/galooshi/vim-import-js
" https://github.com/ruanyl/vim-sort-imports
" https://github.com/skywind3000/vim-quickui
" https://github.com/mg979/vim-visual-multi
" https://github.com/nvim-treesitter/completion-treesitter
" https://github.com/wellle/context.vim
" https://github.com/romgrk/nvim-treesitter-context
" https://github.com/romgrk/searchReplace.vim
" https://github.com/romgrk/barbar.nvim
" https://github.com/barrett-ruth/import-cost.nvim
call plug#end() " }}}
endif
" configure diagnostics globally
if has('nvim')
lua vim.diagnostic.config({
\ virtual_text=false,
\ })
endif
fun! <SID>InitLSPBuffer()
" TODO: this util is DEPRECATED in favour of the using vim-project-config to
" activate language servers as needed.
" TODO: move all this stuff into peter#LSPKeymapsFallback() or some other function
" callable from per-project config because InitLSPBuffer() is no longer a
" thing
nnoremap <buffer> <space>f :lua vim.lsp.buf.incoming_calls()<CR>
nnoremap <buffer> \A :call <SID>ToggleDiagnostic()<CR>
" XXX: if formatting doesn't seem to do anything it probably means you need
" to install 'prettier' into your project. The guide I based this on
" recommended using 'npm install -g prettier' however I'm keen to avoid
" having a global version that gets stale / differs between machines
" TODO(DOTFILES051) move these into peter#LSPKeymaps*()
nnoremap <buffer> \f :lua vim.lsp.buf.format()<CR>
nnoremap <buffer> \F :call <SID>ToggleAutoFormatting()<CR>
command! -nargs=0 -buffer Format lua vim.lsp.buf.format()
" TODO: tidy this up so we're *not* using ALE namespace vars
" TODO: move this into vim/autoload/peter.vim
" TODO(DOTFILES051) untangle this
" TODO: since ALE also defines its own autocmd that check b:ale_fix_on_save,
" this means that our hijacking of this variable here will cause ALE to
" *also* format the buffer unless we have completely disabled ALE in the
" current buffer while we turned on LSP.
let b:ale_fix_on_save = 0
aug PeterLSPAutoFormat
au! BufWritePre <buffer> exe b:ale_fix_on_save ? 'lua vim.lsp.buf.format()' : ''
aug end
endfun
fun! <SID>ToggleAutoFormatting()
if get(b:, 'ale_fix_on_save', 0)
let b:ale_fix_on_save = 0
else
let b:ale_fix_on_save = 1
endif
echohl WarningMsg
echo printf('b:ale_fix_on_save = %s', b:ale_fix_on_save)
echohl None
endfun
fun! <SID>ToggleDiagnostic()
if get(b:, 'peter_show_diagnostic', 0)
lua vim.diagnostic.show()
let b:peter_show_diagnostic = 0
else
lua vim.diagnostic.hide()
let b:peter_show_diagnostic = 1
endif
endfun
if has('nvim')
lua require('Universal')
endif
" vim/tmux navigator keybindings {{{
let g:tmux_navigator_no_mappings = 1
if g:vim_peter
if has('nvim')
tnoremap <silent> <M-h> <C-\><C-n>:TmuxNavigateLeft<cr>
tnoremap <silent> <M-j> <C-\><C-n>:TmuxNavigateDown<cr>
tnoremap <silent> <M-k> <C-\><C-n>:TmuxNavigateUp<cr>
tnoremap <silent> <M-l> <C-\><C-n>:TmuxNavigateRight<cr>
nnoremap <silent> <M-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <M-j> :TmuxNavigateDown<cr>
nnoremap <silent> <M-k> :TmuxNavigateUp<cr>
nnoremap <silent> <M-l> :TmuxNavigateRight<cr>
"nnoremap <silent> <M-w> :TmuxNavigatePrevious<cr>
else
nnoremap <silent> <ESC>h :TmuxNavigateLeft<cr>
nnoremap <silent> <ESC>j :TmuxNavigateDown<cr>
nnoremap <silent> <ESC>k :TmuxNavigateUp<cr>
nnoremap <silent> <ESC>l :TmuxNavigateRight<cr>
" these don't seem to work :-(
"nnoremap <silent> <ESC>w :TmuxNavigatePrevious<cr>
endif
else
if has('nvim')
tunmap <M-h>
tunmap <M-h>
tunmap <M-h>
tunmap <M-h>
tunmap <M-h>
endif
silent! nunmap <ESC>h
silent! nunmap <ESC>j
silent! nunmap <ESC>k
silent! nunmap <ESC>l
silent! nunmap <ESC>w
silent! nunmap <M-h>
silent! nunmap <M-j>
silent! nunmap <M-k>
silent! nunmap <M-l>
silent! nunmap <M-w>
endif
" }}}
" the most important change to my vimrc in a long long time
if has('mouse')
set mouse=a
" the netrw mouse mappings are annoying and not something I want
let g:netrw_mousemaps = 0
" mouse support in massive windows
if has('mouse_sgr')
set ttymouse=sgr
endif
endif
colors elflord