-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvimrc
More file actions
2232 lines (1842 loc) · 77.8 KB
/
Copy pathvimrc
File metadata and controls
2232 lines (1842 loc) · 77.8 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
" ~/.vim/vimrc by Marius Gedminas <marius@gedmin.as>
"
" I've tried to make it work with vim.tiny without errors, by sprinkling
" conditionals all over the place.
"
"
" Options {{{1
"
set nocompatible " be modern (default if you have a .vimrc)
" Presentation {{{2
set laststatus=2 " always show a status line
set cmdheight=2 " avoid 'Press ENTER to continue'
set guioptions-=L " disable left scrollbar in GUI
set guioptions-=m " disable GUI menu
set guicursor+=a:blinkon0 " disable cursor blinking
set shortmess-=S " show N/M while searching
set showcmd " show partial commands in status line
set ruler " show cursor position in status line
set list " show tabs and spaces at end of line:
set listchars=tab:>-,trail:·,extends:>
if v:version >= 600
set listchars+=precedes:<
endif
if v:version >= 700
set listchars+=nbsp:_
endif
if has("linebreak")
set linebreak " wrap lines at word boundaries, not mid-word
let &sbr = nr2char(8618).' ' " show ↪ at the beginning of wrapped lines
endif
set display=lastline " when last line doesn't fit, show most of it
if has("extra_search")
set hlsearch " highlight search matches
nohlsearch " but not initially
endif
if exists("&colorcolumn")
let &colorcolumn=join(range(81,999),",") " highlight columns over 80
endif
set numberwidth=6 " I want it constant width everywhere
set title " set xterm title even in Wayland (where autodetect fails)
" I want gvim to look the same as vim in gnome-terminal
set guifont=Ubuntu\ Mono\ 13
" Silence {{{2
set noerrorbells " don't beep!
set visualbell " don't beep!
set t_vb= " don't beep! (but also see t_vb= below)
if exists("&belloff")
set belloff=all " don't beep!
endif
" Interpreting file contents {{{2
set modelines=5 " debian disables this by default
set nomodeline " on second thought, debian has it right
set fileencodings=ucs-bom,utf-8,windows-1257 " autodetect
" Backup files {{{2
set backup " make backups
set backupdir=~/tmp " but don't clutter $PWD with them
if $USER == "root"
" 'sudo vi' on certain machines cannot write to ~/tmp (NFS root-squash)
set backupdir=/root/tmp
endif
" create the backup directory if it doesn't already exist
call mg#mkdir#if_missing(&backupdir)
" Persistent undo (vim 7.3+) {{{2
if has("persistent_undo")
set undofile " enable persistent undo
let &undodir=&backupdir . "/.vimundo" " but don't clutter $PWD
call mg#mkdir#if_missing(&undodir)
endif
" No swap files for unmodified buffers {{{2
set noswapfile
augroup Swap
autocmd CursorHold,BufWritePost,BufReadPost,BufLeave *
\ if isdirectory(expand("<amatch>:h")) | let &swapfile = &modified | endif
augroup END
" Behaviour {{{2
set wildmenu " nice tab-completion on the command line
set wildmode=longest,full " nicer tab-completion on the command line
set hidden " side effect: undo list is not lost on C-^
if !has('nvim')
set browsedir=buffer " :browse e starts in %:h, not in $PWD
endif
set autoread " automatically reload files changed on disk
set history=1000 " remember more lines of cmdline history
set switchbuf=useopen " quickfix reuses open windows
set iskeyword-=/ " Ctrl-W in command-line stops at /
set splitright " put new splits on the right please
set nrformats-=octal " Ctrl-A/X on YYYY-0M-0D
if has('patch-8.2.0860')
set nrformats+=unsigned " Ctrl-A/X on YYYY-MM-DD
endif
if has('mouse_xterm')
set mouse=a " use mouse in xterms
endif
set clipboard&
set clipboard-=autoselect " unnamed + autoselect = can't use Vp to replace
set clipboard^=unnamed " interoperate with the X clipboard
if v:version >= 700
set diffopt+=vertical " split diffs vertically
set spelllang=en,lt " spell-check two languages at once
endif
if exists('&splitkeep')
set splitkeep=screen " avoid scrolling text when creating splits
endif
if exists('&smoothscroll')
set smoothscroll " allow scrolling by screen line (^Y/^E only for now)
endif
" Input {{{2
set ttimeout ttimeoutlen=20 " timeout keys after 20ms (mappings time out after 1 s)
" doesn't seem to work for <esc>Ok
set updatetime=250 " faster CursorHold events for vim-gitgutter
" Movement {{{2
set incsearch " incremental searching
set scrolloff=2 " always keep cursor 2 lines from screen edge
set nostartofline " don't jump to start of line
" Folding {{{2
if &foldmethod == 'manual'
" set foldmethod=marker " use folding by markers by default
set foldmethod=syntax " use syntax folding by default
endif
set foldlevelstart=9999 " initially open all folds
" Editing {{{2
set nowrap " do not wrap long lines
set backspace=indent,eol,start " sensible backspacing
set shiftwidth=4 " more-or-less reasonable indents
set softtabstop=-1 " make the <tab> key more useful
set tabstop=8 " anything else is heresy
set expandtab " tabs are evil
set noshiftround " do NOT enforce the indent
set autoindent " automatic indent
set nosmartindent " but no smart indent (ain't smart enough)
set copyindent " no tabs if previous line used spaces
set preserveindent " no tabs if line didn't use them before
set isfname-=\= " fix filename completion in VAR=/path
if v:version >= 704
set fo+=j " remove comment leader when joining lines
let &flp='^\s*\d\+[\]:.)}\t ]\s*' " default value
let &flp.='\|^\s*[-*]\s' " also recognize bulleted lists
endif
" Editing code {{{2
set path&
set path+=/usr/include/i386-linux-gnu " multiarch on ubuntu
set path+=/usr/include/x86_64-linux-gnu " multiarch on ubuntu
set path+=** " let :find do recursive searches
set tags&
set tags-=./TAGS " ignore emacs tags to prevent duplicates
set tags-=TAGS " ignore emacs tags to prevent duplicates
set tags-=./tags " bin/tags is not a tags file
set tags+=tags;$HOME " look for tags in parent dirs
set suffixes&
set suffixes+=.class " ignore Java class files
set suffixes+=.pyc,.pyo " ignore compiled Python files
set suffixes+=.egg-info " ignore compiled Python files
set suffixes+=.~1~,.~2~ " ignore Bazaar droppings
set suffixes+=.png " don't edit .png files please
set wildignore&
set wildignore+=*.pyc,*.pyo " same as 'suffixes', but for tab completion
set wildignore+=*.[oad],*.so " and, more importantly, Command-T
set wildignore+=*/__pycache__/* " compiled python files
set wildignore+=*.egg-info/ " setuptools droppings
set wildignore+=*/*.egg-info/* " setuptools droppings
set wildignore+=*~ " backup files
" most of these directory ignores are probably broken because they don't have
" the trailing /* which appears to be necessary, in addition to the leading */
set wildignore+=*/build " distutils, I hates them
set wildignore+=*/dist " distutils deliverables
set wildignore+=*/htmlcov " coverage.py html reports
set wildignore+=*/coverage " zope.testrunner --coverage
set wildignore+=*/parts " all buildout-generated junk even
set wildignore+=*/.venv " virtualenv
set wildignore+=*/python " virtualenv called 'python'
set wildignore+=*/eggs " buildout?
set wildignore+=*/.eggs " setuptools
"set wildignore+=.tox/* " tox -- I find it useful to :e files from .tox/
set wildignore+=*/_build " sphinx
set wildignore+=*/node_modules " thousands of files, omg
set wildignore+=*/obj-x86_64-pc-linux-gnu/* " firefox builds, 43018 files
set wildignore+=.ruff_cache " ruff, a Python linter
if v:version >= 700
set complete-=i " don't autocomplete from included files (slow)
set completeopt-=preview " don't show the preview window
endif
" Pytest syntax errors {{{2
" Reset error format so that sourcing .vimrc again and again doesn't grow it
" without bounds
set errorformat&
" For the record, the default errorformat is this:
"
" %*[^"]"%f"%*\D%l: %m
" "%f"%*\D%l: %m
" %-G%f:%l: (Each undeclared identifier is reported only once
" %-G%f:%l: for each function it appears in.)
" %-GIn file included from %f:%l:%c:
" %-GIn file included from %f:%l:%c\,
" %-GIn file included from %f:%l:%c
" %-GIn file included from %f:%l
" %-G%*[ ]from %f:%l:%c
" %-G%*[ ]from %f:%l:
" %-G%*[ ]from %f:%l\,
" %-G%*[ ]from %f:%l
" %f:%l:%c:%m
" %f(%l):%m
" %f:%l:%m
" "%f"\, line %l%*\D%c%*[^ ] %m
" %D%*\a[%*\d]: Entering directory %*[`']%f'
" %X%*\a[%*\d]: Leaving directory %*[`']%f'
" %D%*\a: Entering directory %*[`']%f'
" %X%*\a: Leaving directory %*[`']%f'
" %DMaking %*\a in %f
" %f|%l| %m
"
" and sometimes it misfires, so let's fix it up a bit
" (TBH I don't even know what compiler produces filename(lineno) so why even
" have it?)
set errorformat-=%f(%l):%m
" Sometimes Vim gets confused about ISO-8601 timestamps and thinks they're
" filenames; this is a big hammer that ignores anything filename-like on lines
" that start with at least two spaces, possibly preceded by a number and
" optional punctuation
set errorformat^=%+G%\\d%#%.%\\=\ \ %.%#
" Similar, but when the entire line starts with a date
set errorformat^=%+G\\d\\d\\d\\d-\\d\\d-\\d\\d\ \\d\\d:\\d\\d%.%#
" make: *** [Makefile:14: target] Error 1
set errorformat^=%+Gmake:\ ***\ %.%#
" FAILED tests.py::test_with_params[YYYY-MM-DD:HH:MM:SS] - Exception: bla bla
set errorformat^=%+GFAILED\ %.%#
" AssertionError: assert ...YYYY-MM-DD:HH:MM:SS...
set errorformat^=%+GAssertionError:\ %.%#
" --- /path/to/file:before YYYY-MM-DD HH:MM:SS.ssssss
set errorformat^=---%f:%m
" +++ /path/to/file:before YYYY-MM-DD HH:MM:SS.ssssss
set errorformat^=+++%f:%m
" Sometimes pytest prepends an 'E' marker at the beginning of a traceback line
set errorformat+=E\ %#File\ \"%f\"\\,\ line\ %l%.%#
" Python tracebacks (unittest + doctest output) {{{2
" This collapses the entire traceback into just the last file+lineno,
" which is convenient when you want to jump to the line that failed (and not
" the top-level entry point), but it makes it impossible to see the full
" traceback, which sucks.
""set errorformat+=
"" \File\ \"%f\"\\,\ line\ %l%.%#,
"" \%C\ %.%#,
"" \%-A\ \ File\ \"unittest%.py\"\\,\ line\ %.%#,
"" \%-A\ \ File\ \"%f\"\\,\ line\ 0%.%#,
"" \%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,
"" \%Z%[%^\ ]%\\@=%m
set errorformat+=
\File\ \"%f\"\\,\ line\ %l\\,%#%m
" Shell scripts {{{2
if has("eval")
let g:is_posix = 1 " /bin/sh is POSIX, not ancient Bourne shell
let g:sh_fold_enabled = 7 " fold functions, heredocs, ifs/loops
endif
" C headers {{{2
if has("eval")
let g:c_syntax_for_h = 1 " assume *.h are C, not C++
endif
" Markdown {{{2
let g:markdown_fenced_languages=['ini', 'console', 'python']
" Netrw explorer {{{2
if has("eval")
let g:netrw_list_hide = '.*\.swp\($\|\t\),.*\.py[co]\($\|\t\),__pycache__'
let g:netrw_sort_sequence = '[\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$,\.py[co]$'
let g:netrw_timefmt = '%Y-%m-%d %H:%M:%S'
endif
"
" Abbreviations {{{1
"
" I keep mistyping these
abbrev Pyhton Python
abbrev PYthon Python
abbrev improt import
abbrev retunr return
abbrev PAth Path
abbrev ehco echo
abbrev wiht with
abbrev reosurce resource
abbrev MAke Make
abbrev assing assign
abbrev jsut just
abbrev naything anything
abbrev kidn kind
abbrev everythign everything
abbrev chagne change
abbrev teh the
abbrev isntall install
"
" Plugins {{{1
"
" Builtin plugins {{{2
" :Cfilter /pat/ to filter quickfix list
packadd! cfilter
" vim-plug plus list of plugins to install {{{2
if has("eval")
call plug#begin('~/.vim/bundle')
" :help for vim-plug itself {{{3
Plug 'junegunn/vim-plug', {
\ 'do': 'cp plug.vim ~/.vim/autoload/plug.vim' }
" Programming {{{3
" Show syntax errors and style warning in files I edit. Updates
" asynchonously (requires Vim 8).
if has('nvim') || has('timers') && exists('*job_start') && exists('*ch_close_in')
let g:ale_set_balloons = 1 " must be set before loading ale
Plug 'dense-analysis/ale'
let g:ale_linters = {}
let g:ale_linters.python = ['flake8']
let g:ale_linters.rust = ['cargo']
" ansible-lint is cluttering empty .ansible/{collections,modules,roles}/
" subdirectories everywhere, shame on you
let g:ale_linters.ansible = []
let g:ale_linters.yaml = ['yamllint']
" eslint complains about not having a config file, the gall!
let g:ale_linters.html = []
" xmllint gets confused about tal: prefixes in Zope page templates
let g:ale_linters.xml = []
let g:ale_fixers = {}
let g:ale_fixers.javascript = ['prettier']
let g:ale_fixers.typescript = ['prettier']
let g:ale_fixers.python = ['isort']
let g:ale_fixers.rust = ['rustfmt']
let g:ale_fixers.yaml = ['prettier']
if filereadable(expand('~/.cargo/bin/rust-analyzer'))
let g:ale_linters.rust = ['analyzer', 'cargo']
endif
" see https://github.com/w0rp/ale/issues/1827#issuecomment-433920827
let g:ale_python_flake8_change_directory = 0
let g:ale_rust_cargo_use_clippy = 1
let g:ale_python_isort_options = "--lai=2 -m3 --tc"
else
" Show syntax errors and style warnings in files I edit. Updates on save.
Plug 'scrooloose/syntastic'
endif
" Update tags file automagically
Plug 'ludovicchabant/vim-gutentags'
" As suggested in https://github.com/ludovicchabant/vim-gutentags/issues/113,
" to only update existing tags files and never create new ones:
let g:gutentags_project_root = ['tags']
let g:gutentags_add_default_project_roots = 0
let g:gutentags_generate_on_missing = 0
let g:gutentags_generate_on_new = 0
" Base64 encode/decode on <leader>atob and <leader>btoa in visual mode
Plug 'christianrondeau/vim-base64'
" and since I can never remember the mappings
vmap <leader>a2b <leader>atob
vmap <leader>b2a <leader>btoa
" Show [current_function] in the status line for supported file types (C, Python, JS, diff)
Plug 'mgedmin/taghelper.vim'
" Comment out stuff with gc<motion> (gcc for the current line)
Plug 'tpope/vim-commentary'
" Programming: VimScript {{{3
Plug 'junegunn/vader.vim'
" Programming: Rust {{{3
Plug 'rust-lang/rust.vim'
" Programming: JavaScript {{{3
Plug 'yuezk/vim-js'
Plug 'MaxMEllon/vim-jsx-pretty'
" Programming: Python {{{3
" Random Python code refactorings like :SortList, :SwapAssignment etc.
Plug 'mgedmin/python-refactorings.vim'
" Insert Python import statements computed from tags, bound to <F5>
Plug 'mgedmin/python-imports.vim', {'on': ['ImportName', 'ImportNameHere']}
" A smarter :Tag [package.][module.][class.]name command for Python
" (my ftplugin/python.vim also remaps Ctrl-] to use it)
Plug 'mgedmin/pytag.vim', {'on': ['Tag'], 'for': 'python'}
" <Leader>oo to jump to Python standard library source code
" (my fork because bugfixes)
Plug 'mgedmin/python_open_module.vim'
" Python folding, to replace my hacky syntax/python.vim perhaps?
" (I'm not ready to switch yet)
""Plug 'tmhedberg/SimpylFold'
" Automate switching between code and unit test files, bound to <C-F6>
Plug 'mgedmin/test-switcher.vim', {'on': ['SwitchCodeAndTest', 'TestForTheOtherWindow', 'OpenTestInOtherWindow']}
" Run test under cursor
Plug 'mgedmin/py-test-runner.vim'
" Locate the source code line from clipboard contents, bound to <F7>
Plug 'mgedmin/source-locator.vim', {'on': ['ClipboardTest', 'LocateTest']}
" :EnableTestOnSave and have fun doing code katas
Plug 'mgedmin/test-on-save.vim', {'on': ['EnableTestOnSave', 'RunTests']}
" :HighlightCoverage for Python
Plug 'mgedmin/coverage-highlight.vim', {'on': ['HighlightCoverage', 'HighlightCoverageForAll', 'HighlightCoverageOff', 'ToggleCoverage', 'PrevUncovered', 'NextUncovered']}
let g:coverage_script = 'coverage'
noremap [C :<C-U>PrevUncovered<CR>
noremap ]C :<C-U>NextUncovered<CR>
noremap <M-Up> :<C-U>PrevUncovered<CR>
noremap <M-Down> :<C-U>NextUncovered<CR>
" Better Python autoindentation
Plug 'Vimjas/vim-python-pep8-indent'
" Misbehaves for long literals (over 50 lines), see
" https://github.com/Vimjas/vim-python-pep8-indent/pull/90
" More up-to-date Python syntax that supports f-strings and everything
" Well. It used to be up-to-date. Last commit 4 years ago, doesn't support
" match statements.
""Plug 'vim-python/python-syntax'
""let python_slow_sync = 1
let python_highlight_all = 1 " builtin python syntax also supports this
" :Pydoc
Plug 'fs111/pydoc.vim'
let g:pydoc_cmd = 'python3 -m pydoc'
" :BlackMachiatto to autoformat the selected range of lines; needs pipx
" install black-machiatto
Plug 'smbl64/vim-black-macchiato'
let g:black_macchiato_args = "-S -l79"
" Version control integration {{{3
" Git integration -- :Gdiff, :Ggrep etc.
Plug 'tpope/vim-fugitive'
let g:fugitive_legacy_commands = 1 " :Gbrowse, :Gblame are burned into my muscle memory
" GitHub support for vim-fugitive
Plug 'tpope/vim-rhubarb'
" Gitlab support for vim-fugitive
Plug 'shumphrey/fugitive-gitlab.vim'
let g:fugitive_gitlab_domains = {
\ 'https://gitlab.gnome.org': 'https://gitlab.gnome.org',
\ }
" Bitbucket support for vim-fugitive
Plug 'tommcdo/vim-fubitive'
let g:fubitive_domain_pattern = 'stash\.draeger\.com'
" Azure DevOps support for vim-fugitive
Plug 'cedarbaum/fugitive-azure-devops.vim'
" Git log browsing (unmaintained)
Plug 'gregsexton/gitv', {'on': ['Gitv']}
" Git log browsing (alternative)
Plug 'rbong/vim-flog', {'on': ['Flog', 'Flogsplit']}
" Show git change status for each line in the gutter
Plug 'airblade/vim-gitgutter'
" Higlight git conflict markers in files
Plug 'vim-scripts/ingo-library'
Plug 'vim-scripts/ConflictDetection'
" Use [x/]x to navigate to conflict markers
Plug 'vim-scripts/CountJump'
Plug 'vim-scripts/ConflictMotions'
" Version control integration for SVN and other legacy VCSes -- :VCSVimDiff
Plug 'vim-scripts/vcscommand.vim'
" Load previous svn-commit.tmp automatically when you repeat 'svn ci' after
" a failed commit.
Plug 'vim-scripts/svn_commit'
" Show the svn diff while I'm editing an svn commit message.
Plug 'vim-scripts/svn-diff.vim'
" Navigation {{{3
" Open files by typing a subsequence of the pathname, bound to <Leader>t
if has('nvim')
Plug 'wincent/command-t', {
\ 'branch': '7-x-release',
\ 'do': 'make' }
let g:CommandTPreferredImplementation = 'lua'
nmap <silent> <Leader>t <Plug>(CommandT)
elseif has('ruby')
Plug 'wincent/command-t', {
\ 'branch': '7-x-release',
\ 'do': 'cd ruby/command-t/ext/command-t && ruby extconf.rb && make' }
let g:CommandTPreferredImplementation = 'ruby'
endif
" Pure-python alternative to command-t, slightly different UI, not as nice
" to use as command-t but useful for some circumstances (Vim w/o Ruby).
" Bound to <C-P>
Plug 'vim-scripts/ctrlp.vim'
" Extend the builtin gx
Plug 'stsewd/gx-extended.vim'
nmap gx <Plug>(gxext-normal)
" List open buffers with various sorting modes on \be
Plug 'jlanzarotta/bufexplorer'
" File tree in a sidebar. Bound to <Leader>N, <Leader>f
Plug 'preservim/nerdtree', {
\ 'on': ['NERDTree', 'NERDTreeToggle', 'NERDTreeFocus', 'NERDTreeFind'] }
Plug 'Xuyuanp/nerdtree-git-plugin'
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ 'Modified' :'*',
\ 'Staged' :'+',
\ 'Untracked' :'?',
\ 'Renamed' :'>',
\ 'Unmerged' :'=',
\ 'Deleted' :'x',
\ 'Dirty' :'*',
\ 'Ignored' :'I',
\ 'Clean' :'v',
\ 'Unknown' :'?',
\ }
" Extending vim's features {{{3
" Show ASCII-art representation of Vim's undo tree, with bonus unified diffs
Plug 'sjl/gundo.vim'
let g:gundo_prefer_python3 = has('python3') " Unbreak broken default config
" :MacroEdit q
Plug 'dohsimpson/vim-macroeditor'
" Defines the very useful :Rename newfilename.txt
Plug 'vim-scripts/Rename'
" :%S/foo/bar/gc --> case-preserving :%s
Plug 'tpope/vim-abolish'
" Replace 'ga' to show Unicode names etc.
Plug 'tpope/vim-characterize'
" ^P/^N completion on the command line
Plug 'vim-scripts/CmdlineComplete'
" Emacs-like Alt-t transpose words
Plug 'vim-scripts/transpose-words'
if !has('nvim')
exec "set <M-t>=\<Esc>t"
endif
" Snippets! Type some text, press <tab> to expand, with get expansion with
" multiple placeholders you can keep or replace and tab over.
" Supposedly better than SnipMate which I used earlier.
if has('python') || has('python3')
Plug 'SirVer/UltiSnips'
endif
" Default snippet collection -- I don't use them!
""Plug 'honza/vim-snippets'
" Enable vim filename:lineno and :e filename:lineno
Plug 'kopischke/vim-fetch'
" Edit symlink targets instead of symlinks
" (mostly because I want fugitive to work on my dotfiles repo)
Plug 'aymericbeaumet/symlink.vim'
" symlink.vim: 'moll/vim-bbye' is required in order for this plugin to
" properly work in diff mode
Plug 'moll/vim-bbye'
" Async shell commands (see :Make)
Plug 'skywind3000/asyncrun.vim'
" :EasyAlign
Plug 'junegunn/vim-easy-align'
" :Tabularize
Plug 'godlygeek/tabular'
" Resize quickfix windows to fit content -- broooken currently
" see https://github.com/blueyed/vim-qf_resize/issues/5
"Plug 'blueyed/vim-qf_resize'
" Text objects for vim's folds (vaz etc.)
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-fold'
" The popular vim-surround that I hate every time I try
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
" Show vim command output in a buffer, e.g. :Bufferize scriptnames
Plug 'AndrewRadev/bufferize.vim'
let g:bufferize_keep_buffers = 1
" Tell me which vim version introduced a feature with :HelpfulVersion foo
Plug 'tweekmonster/helpful.vim'
" Sum numbers in visual selection
Plug 'emugel/vim-sum'
vmap <Esc>= <Plug>VimSumVisual
" :StartupTime
Plug 'dstein64/vim-startuptime'
" Highlight whatever was yanked, briefly
Plug 'machakann/vim-highlightedyank'
let g:highlightedyank_highlight_duration = 250
let g:highlightedyank_highlight_in_visual = 0
" Highlight whatever was pasted, briefly (too briefly)
Plug 'MaxMEllon/vim-shiny'
nmap p <Plug>(shiny-p)
nmap P <Plug>(shiny-P)
nmap gp <Plug>(shiny-gp)
nmap gP <Plug>(shiny-gP)
" Additional filetypes {{{3
" LESS (the CSS preprocessor) syntax
Plug 'groenewege/vim-less'
" Vala syntax
Plug 'tkztmk/vim-vala'
" Improved ReStructuredText syntax
Plug 'mrsipan/vim-rst'
" Folding for Markdown files
Plug 'masukomi/vim-markdown-folding'
" Improved YAML syntax for Ansible
Plug 'chase/vim-ansible-yaml'
" YAML folding
Plug 'pedrohdz/vim-yaml-folds'
" Jinja syntax
" (my fork because mitsuhiko is MIA and ignores GH issues)
Plug 'mgedmin/vim-jinja'
" Nginx syntax
Plug 'vim-scripts/nginx.vim'
" huh this has no ftdetect plugin?? and stock vim doesn't either?
" Caddyfile syntax
Plug 'isobit/vim-caddyfile'
" xchat log syntax highlighting (set ft=xchatlog)
Plug 'vim-scripts/xchat-log-syntax'
" there's also 'XChat-IRC-Log' (set ft=irclog), but it fails to highlight
" anything?
" Syntax for Robot Framework tests
Plug 'mfukar/robotframework-vim'
" Jenkinsfile
Plug 'martinda/Jenkinsfile-vim-syntax'
" PostgreSQL
Plug 'lifepillar/pgsql.vim'
let g:sql_type_default = 'pgsql'
" Puppet .epp templates
Plug 'farkasmate/epp-syntax-vim'
" }}}3
call plug#end()
endif
" Filetype plugins {{{2
if v:version >= 600
filetype plugin on " load filetype plugins
filetype indent on " load indent plugins
endif
" Syntastic (which I no longer use if ALE is available) {{{2
if has("eval")
let g:syntastic_check_on_open = 1 " default is 0
let g:syntastic_enable_signs = 1 " default is 1
let g:syntastic_enable_baloons = 1 " default is 1
let g:syntastic_enable_highlighting = 1 " default is 1
let g:syntastic_auto_jump = 0 " default is 0
let g:syntastic_auto_loc_list = 2 " default is 2
let g:syntastic_always_populate_loc_list = 1 " default is 0
" let g:syntastic_quiet_warnings = 1
" I don't know what syntastic uses to check Java, but it's unusably slow
let g:syntastic_mode_map = { "mode": "active",
\ "active_filetypes": [],
\ "passive_filetypes": ["java"] }
" statusline format (default: '[Syntax: line:%F (%t)]')
let g:syntastic_stl_format = '{%t}'
" fun with unicode
let g:syntastic_error_symbol = '⚡'
let g:syntastic_warning_symbol = '⚠'
" For forcing the use of flake8, pyflakes, or pylint set
" let g:syntastic_python_checkers = ['pyflakes']
let g:syntastic_python_checkers = ['flake8']
let $PYFLAKES_DOCTEST = ''
let g:syntastic_javascript_checkers = ['jshint']
" don't check json files; I rarely edit these and sometimes they're huge
" which makes jshint slow
" the same applies to configure scripts
let g:syntastic_ignore_files = ['\.json$', '^configure$']
endif
" A.L.E.
if has("eval")
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '>>'
if exists('*sign_getdefined') && sign_getdefined('ALEErrorSign') != []
" If you want to change the sign text after they've been defined (e.g.
" if you edit the .vimrc and source it), you have to re-define the sign.
runtime! autoload/ale/sign.vim
endif
let g:ale_statusline_format = ['{%d}', '{%d}', '']
" if I become annoyed about ALE showing errors for half-typed text, perhaps
" I'll want to uncomment these:
""let g:ale_lint_on_save = 1
""let g:ale_lint_delay = 1000
""let g:ale_lint_on_text_changed = 0
nmap <Leader>af <Plug>(ale_fix)
endif
" Command-t {{{2
if has("eval")
let g:CommandTCursorEndMap = ['<C-e>', '<End>'] " add End
let g:CommandTCursorStartMap = ['<C-a>', '<Home>'] " add Home
let g:CommandTCursorLeftMap = ['<Left>'] " remove ^H
let g:CommandTCursorRightMap = ['<Right>'] " remove ^L
let g:CommandTClearPrevWordMap = ['<C-w>', '<C-h>'] " add ^H aka Ctrl-BS
let g:CommandTCancelMap = ['<C-c>', '<Esc>', '<C-g>'] " add ^G
let g:CommandTMaxHeight = 20
let g:CommandTTraverseSCM = "pwd"
""let g:CommandTFileScanner = "find" " should be faster than the default 'ruby'
" I may want to experiment with these:
let g:CommandTFileScanner = "git"
let g:CommandTGitIncludeUntracked = 1
if exists(":CommandTFlush")
" In case we changed &wildignore and want to test it
CommandTFlush
endif
" Allow Command-T to replace bufexplorer windows
let g:CommandTWindowFilter = '!&buflisted && &buftype == "nofile" && &filetype != "bufexplorer"'
"let g:CommandTMaxFiles=800000 " firefox source tree is _big_
" OTOH my home directory is also big and it sucks that I cannot interrupt
" command-t with a ctrl-c when I accidentally trigger it there
let g:CommandTMaxFiles=10000 " it's unbearably slow after 10000 files
nmap <silent> <Leader>T <Plug>(CommandTTag)
nmap <silent> <Leader>B <Plug>(CommandTBuffer)
nmap <silent> <Leader>H <Plug>(CommandTHelp)
endif
" ctrlp.vim {{{2
if has("eval")
let g:ctrlp_match_window_reversed = 1
let g:ctrlp_reuse_window = 'netrw\|BufExplorer'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]build$',
\ }
" make ctrl-f refresh the file cache like command-t
" nb: changes the default meaning of ctrl-f which is "switch to next mode",
" but I don't use modes
let g:ctrlp_prompt_mappings = {
\ 'PrtClearCache()': ['<F5>', '<c-f>'],
\ }
" faster scanning maybe
let g:ctrlp_user_command =
\ ['.git', 'cd %s && git ls-files . -co --exclude-standard']
endif
" bufexplorer.vim {{{2
if has("eval")
let g:bufExplorerShowRelativePath = 1
let g:bufExplorerSplitOutPathName = 0
let g:bufExplorerShowNoName = 1
let g:bufExplorerSortBy = 'fullpath'
endif
" YouCompleteMe (which I no longer use) {{{2
if has("eval")
" auto-triggering breaks typing-then-<Up>/<Down> navigation in insert mode
" auto-triggering also breaks foo<C-p> completion
let g:ycm_auto_trigger = 0
" so I'm confused: I'd think I'd want this, but it appears to already
" detect my tags, despite the docs saying this is off by default?
" eh, maybe I had the right buffers open at that time.
" BTW apparently I need ctags --fields=+l for YCM to work
""let g:ycm_collect_identifiers_from_tags_files = 1
" I hate when the preview window stays on screen
let g:ycm_autoclose_preview_window_after_completion = 1
" don't stomp on the <Tab> key dammit
let g:ycm_key_list_select_completion = ['<Down>']
let g:ycm_key_list_previous_completion = ['<Up>']
endif
" UltiSnips {{{2
if has("eval")
" don't override ^J/^K -- I don't mind ^J, but ^K is digraphs
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" <c-tab> doesn't work in gnome-terminal
let g:UltiSnipsListSnippets="<C-R><tab>"
endif
" Manual pages (:Man foo) {{{2
if v:version >= 600
runtime ftplugin/man.vim
endif
" Toggle between .c (.cc, .cpp) and .h {{{2
" ToggleHeader defined in $HOME/.vim/plugin/cpph.vim
" Maybe these mappings should be moved into FT_C() ?
map ,h :call ToggleHeader()<CR>
map <C-F6> ,h
imap <C-F6> <C-O><C-F6>
" List all functions in a file {{{2
" functions defined in $HOME/.vim/plugin/funcs.vim
" Maybe these mappings should be moved into FT_C() ?
map ,l :call ListAllFunctions(1)<CR>
map ,j :<C-U>call JumpToFunction(0)<CR>
" py-test-runner.vim {{{2
map ,t :CopyTestUnderCursor<cr>
if has("user_commands")
" :Co now expands to :CommandT, but I'm used to type it as a shortcut for
" :CopyTestUnderCursor
command! Co CopyTestUnderCursor
endif
" XML syntax folding {{{2
if has("eval")
let xml_syntax_folding = 1
endif
" XML tag complyetion {{{2
if has("eval")
" because autocompleting when I type > is irritating half of the time
let xml_tag_completion_map = "<C-l>"
endif
" VCSCommand configuration {{{2
if has("eval")
" I want 'edit' for VCSAnnotate, but 'split' for all others :(
let VCSCommandEdit = 'split'
let VCSCommandDeleteOnHide = 1
let VCSCommandCommitOnWrite = 0
endif
" vim-scripts/git-commit (which I no longer use) {{{2
if has("eval")
let git_diff_spawn_mode = 1 " auto-split by default
endif
" bzr syntax plugin {{{2
if has("eval")
" NB: it uses an exists() check, so don't set it to 0 if you want it off
let bzr_highlight_diff = 1
endif
" NERD_tree.vim {{{2
if v:version >= 700 && has("eval")
let g:NERDTreeIgnore = [
\ '\.py[co]$', '\~$', '^tags$', '^__pycache__$', '\.sw[a-z]$',
\ '^\.cache$', '^\.git$', '^\.tox$', '\.egg-info$',
\ '^\.mypy_cache$', '^\.pytest_cache$', '^\.eggs$', '^\.ruff_cache$',
\ ]
let g:NERDTreeHijackNetrw = 0
let g:NERDTreeShowHidden = 1
" let g:NERDRespectWildIgnore = 1 <-- hmm, why didn't I have this one
" instead of overriding g:NERDTreeToggle? Either it's new, or it ignores
" something that I ordinarily want to see, like node-modules.
endif
map <Leader>n :NERDTreeToggle<CR>
map <Leader>N :NERDTreeFocus<CR>
map <expr> <Leader>f
\ expand("%") == "" ? ":NERDTreeFocus\<CR>" :
\ filereadable(expand("%")) ? ":NERDTreeFind\<CR>" : ":NERDTreeFind %:h\<CR>O"
" jedi.vim (which I no longer use) {{{2
if has("eval")
" show_function_definition is a hack that modified your source buffer
" and interacts badly with syntax highlighting
let g:jedi#show_function_definition = "0"
" I type 'import zope.component', I see 'import zope.interfacecomponent'
" because jedi autocompletes the only zope subpackage it finds in
" site-packages, unmindful about my virtualenvs/buildouts.
let g:jedi#popup_select_first = 0
endif
" netrw.vim open plugin repo with gx in .vimrc {{{2
fun! Netrw_get_URL_vim()
let plugin_url = ''
try
let save_view = winsaveview()
if getline('.') =~ "^\\s*Plug\\s\\+'.*'"
let plugin_url = matchstr(getline('.'), "^\\s*Plug\\s\\+'\\zs.*\\ze'")
if plugin_url !~ '://'
let plugin_url = 'https://github.com/' .. plugin_url
endif
return plugin_url
endif
finally
call winrestview(save_view)
return plugin_url
endtry
endf
" asyncrun.vim + fugitive.vim = <3 {{{2
if has("user_commands")
" :Make as described in
" https://github.com/skywind3000/asyncrun.vim/wiki/Cooperate-with-famous-plugins
" now :Gpush and :Gfetch are async!
command! -bang -bar -nargs=* Gpush execute 'AsyncRun<bang> -cwd=' .
\ fnameescape(FugitiveGitDir()) 'git push' <q-args>
command! -bang -bar -nargs=* Gfetch execute 'AsyncRun<bang> -cwd=' .
\ fnameescape(FugitiveGitDir()) 'git fetch' <q-args>