-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
1356 lines (1081 loc) · 47.6 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" vim: foldlevel=0
" _
" __ _(_)_ __ ___ _ __ ___
" \ \ / / | '_ ` _ \| '__/ __|
" \ V /| | | | | | | | | (__
" \_/ |_|_| |_| |_|_| \___|
"
" Jeremy Brubaker's .vimrc. Some stuff in here was shame-
" lessly ripped from places I completely forget about.
"
" https://github.com/jbrubake/dotfiles/blob/master/vimrc
" Folding cheet sheet (because I always forget)
" zR open all folds
" zM close all folds
" za toggle fold at cursor position
" zj move down to start of next fold
" zk move up to end of previous fold
" Initialization {{{1
" ==============
" Remove all autocommands if sourcing .vimrc again
autocmd!
" Source .vimrc when saving changes
autocmd BufWritePost ~/.vimrc nested source ~/.vimrc
set nocompatible " Don't be vi compatible
if has ('clientserver') && empty(v:servername) && exists('*remote_startserver')
call remote_startserver('VIM')
endif
" Remap Leader here because it may be used *before* the mapping section
" Better than ',' which is used for backwards character searching
let mapleader = ' '
let maplocalleader = ' '
" Plugins {{{1
"============
" Optional packages {{{2
packadd! matchit " Enhanced % matching
packadd! cfilter " Filter quickfix or location lists
" minpac setup {{{2
"
" call minpac#update() to update all packages
" call minpac#clean() to remove unused plugins
" call minpac#status() to get plugin status
packadd minpac
if !exists('g:loaded_minpac')
" No plugins loaded
else
call minpac#init()
call minpac#add('k-takata/minpac', {'type': 'opt'})
" augroup for loading optional plugins
augroup load_plugins
autocmd!
augroup END
" EVALUATING {{{2
" Lisp stuff {{{3
call minpac#add('https://github.com/vlime/vlime') " vlime: A Common Lisp dev environment for Vim
call minpac#add('https://github.com/kovisoft/paredit') " paredit: Structured Editing of Lisp S-expressions
let g:vlime_cl_impl = "clisp"
function! VlimeBuildServerCommandFor_clisp(vlime_loader, vlime_eval)
return ["clisp", "-i", "~/quicklisp/setup.lisp",
\ "-i", a:vlime_loader,
\ "-x", a:vlime_eval,
\ "-repl"]
endfunction
call minpac#add('https://github.com/junegunn/vim-easy-align') " vim-easy-align: A Vim alignment plugin {{{3
""call minpac#add('luochen1990/rainbow') " Rainbow Parentheses Improved {{{3
""call minpac#add('jpalardy/vim-slime') " A vim plugin to give you some slime {{{3
""call minpac#add('sjl/gundo.vim') " Graph your Vim undo tree in style {{{3
""call minpac#add('mtth/scratch.vim') " Unobtrusive scratch window {{{3
""call minpac#add('dbeniamine/cheat.sh-vim') " cheat.sh-vim: A vim plugin to access cheat.sh sheets {{{3
""call minpac#add('neoclide/coc-snippets') " coc-snippets: snippets for coc {{{3
""call minpac#add('vim-scripts/Conque-GDB') " conque-gdb: integrate gdb with vim {{{3
""call minpac#add('Shougo/deoplete.nvim') " deoplete: vim completion framework {{{3
""call minpac#add('roryokane/detectindent') " detectindent: detect indent settings in vim {{{3
""call minpac#add('vim-scripts/DrawIt') " DrawIt: ASCII drawing plugin {{{3
""call minpac#add('Shougo/echodoc.vim') " echodoc.vim: Print documents in echo area {{{3
""call minpac#add('editorconfig/editorconfig-vim') " editorconfig-vim: EditorConfig plugin for Vim {{{3
""call minpac#add('ii14/exrc.vim') " exrc.vim: project vimrc {{{3
""call minpac#add('skywind3000/gutentags_plus') " gutentags_plus: vim_tags {{{3
""call minpac#add('junegunn/gv.vim') " gv.vim: Git commit browser {{{3
""call minpac#add('lervag/lists.vim') " lists.vim: A Vim plugin to handle lists {{{3
""call minpac#add('SidOfc/mkdx') " mkdx: A vim plugin that adds some nice extras for working with markdown documents {{{3
""call minpac#add('bennyyip/plugpac.vim') " plugpac.vim: Thin wrapper of minpac, provides vim-plug-like experience {{{3
""call minpac#add('sotte/presenting.vim') " presenting.vim: A simple tool for presenting slides in vim based on text files {{{3
""call minpac#add('unblevable/quick-scope') " quick-scope: Lightning fast left-right movement in Vim {{{3
""call minpac#add('Ron89/thesaurus_query.vim') " thesaurus-query: Multi-language Thesaurus Query and Replacement plugin {{{3
""call minpac#add('sirver/UltiSnips') " UltiSnips: vim snippets {{{3
""call minpac#add('mbbill/undotree') " undotree: The undo history visualizer for VIM {{{3
""call minpac#add('vifm/vifm.vim') " vifm.vifm: use vim as a file picker {{{3
""call minpac#add('pseewald/vim-anyfold') " vim-anyfold: Langague agnostic vim plugin for folding and motion based on indentation {{{3
""call minpac#add('tpope/vim-apathy') " vim-apathy: Set the 'path' option for miscellaneous file types {{{3
""call minpac#add('jenterkin/vim-autosource') " vim-autosource: project vimrc {{{3
""call minpac#add('bagrat/vim-buffet') " vim-buffet: IDE-like Vim tabline {{{3
""call minpac#add('altercation/vim-colors-solarized') " vim-colors-solarized: Solarized colorscheme {{{3
""call minpac#add('romainl/vim-cool') " vim-cool: A very simple plugin that makes hlsearch more useful {{{3
""call minpac#add('ryanoasis/vim-devicons') " vim-devicons: NERDTree icons {{{3
""call minpac#add('rhysd/vim-grammarous') " vim-grammarous: vim grammar checker {{{3
""call minpac#add(ludovicchabant/vim-gutentags') " vim-gutentags: vim tags {{{3
""call minpac#add('RRethy/vim-hexokinase') " vim-hexokinase: Display colors in the file {{{3
""call minpac#add('euclio/vim-markdown-composer') " vim-markdown-composer: Asynchronous markdown preview {{{3
""call minpac#add('lifepillar/vim-mucomplete') " vim-mucomplete: Chained completion that works the way you want! {{{3
""call minpac#add('simnalamburt/vim-mundo') " vim-mundo: Vim undo tree visualizer {{{3
""call minpac#add('tpope/vim-obsession') " vim-obsession: Continuously updated session files {{{3
""call minpac#add('sickill/vim-pasta') " vim-pasta: Pasting in Vim with indentation adjusted to destination context {{{3
""call minpac#add('preservim/vim-pencil') " vim-pencil: Rethinking Vim as a tool for writing {{{3
""call minpac#add('tpope/vim-projectionist') " vim-projectionist: Granular project configuration {{{3
""call minpac#add('romainl/vim-qf') " vim-qf: Tame the quickfix window {{{3
""call minpac#add('airblade/vim-rooter') " vim-rooter: Change working directory to project root {{{3
""call minpac#add('tpope/vim-speeddating') " vim-speeddating: use CTRL-A/CTRL-X to increment dates, times and more {{{3
""call minpac#add('christoomey/vim-system-copy') " vim-system-copy: Vim plugin for copying to the system clipboard with text-objects and motions {{{3
""call minpac#add('kana/vim-textobj-entire') " vim-textobj-entire: Text objects for entire buffer {{{3
""call minpac#add('kana/vim-textobj-line') " vim-textobj-line: Text objects for the current line {{{3
""call minpac#add('tpope/vim-unimpaired') " vim-unimpaired: Pairs of handy bracket mappings {{{3
""call minpac#add('tpope/vim-vinegar') " vim-vinegar: Combine with netrw to create a delicious salad dressing {{{3
""call minpac#add('fcpg/vim-waikiki') " vim-waikiki: Vim minimal wiki {{{3
""call minpac#add('chaoren/vim-wordmotion') " vim-wordmotion: More useful word motions for vim {{{3
""call minpac#add('jreybert/vimagit') " vimagit: Ease your git workflow within Vim {{{3
""call minpac#add('LucHermitte/VimFold4C') " VimFold4C: Vim folding ftplugin for C & C++ (and similar languages) {{{3
""call minpac#add('vimoutliner/vimoutline') " vimoutline: Work fast, think well {{{3
""call minpac#add('vimwiki/vimwiki') " vimwiki: Personal Wiki for Vim {{{3
""call minpac#add('sysid/vimwiki-nirvana') " vimwiki-nirvana: vimwiki custom link handler {{{3
""call minpac#add('preservim/vim-lexical') " vim-lexical: Build on Vim's spell/thes/dict completion {{{3
" auto_mkdir2: Automatically create directory tree for new files {{{3
""call minpac#add('arp242/auto_mkdir2.vim')
" Only make tree in wiki
let g:auto_mkdir2_autocmd = '$WIKI_DIR/content/**'
" nerdtree: A tree explorer plugin for vim {{{3
""call minpac#add('preservim/nerdtree')
" <F10> : Toggle file tree browser
noremap <silent> <F8> :NERDTreeToggle<cr>
" Close Vim if last window open is NERDTree
autocmd bufenter * if (winnr("$") == 1 &&
\ exists("b:NERDTree") &&
\ b:NERDTree.isTabTree()) | q |
\ endif
" nerdtree-git-plugin: A plugin of NERDTree showing git status {{{3
""call minpac#add('Xuyuanp/nerdtree-git-plugin')
" Custom indicators
"let g:NERDTreeIndicatorMapCustom = {
" \ "Modified" : "✹",
" \ "Staged" : "✚",
" \ "Untracked" : "✭",
" \ "Renamed" : "➜",
" \ "Unmerged" : "═",
" \ "Deleted" : "✖",
" \ "Dirty" : "✗",
" \ "Clean" : "✔︎",
" \ "Ignored" : "☒",
" \ "Unknown" : "?"
" \ }
" NOTE: See 'Colors and Syntax Settings' for more
" fzf: Fuzzy finder {{{3
""call minpac#add('junegunn/fzf')
" fzf plugin is located here
""set rtp+=/usr/local/share/fzf
" fzf-checkout.vim: Manage branches and tags with fzf {{{3
""call minpac#add('stsewd/fzf-checkout.vim')
" fzf.vim: fzf vim plugin {{{3
""call minpac#add('junegunn/fzf.vim')
" :Files [PATH] " Files ($FZF_DEFAULT_COMMAND)
" :GFiles [OPTS] " Git files (git ls-files)
" :GFiles? " Git files (git status)
" :Buffers
" :Rg [PATTERN] " Search using ripgrep
" :Lines [QUERY] " Lines in all buffers
" :BLines [QUERY] " Lines in current buffer
" :Tags [QUERY] " Tags in current project (ctags -R)
" :BTags [QUERY] " Tags in current buffer
" :Marks " Marks
" :Snippets " Snippets (UltiSnips)
" :Commits " Git commits (vim-fugitive)
" noremap <C-p> :Files<CR>
" noremap <Leader>b :Buffers<CR>
" SimplyFold: No-BS Python code folding{{{3
""call minpac#add('tmhedberg/SimpylFold')
" vim-autoformat: Provide easy code formatting in Vim by integrating existing code formatters {{{3
""call minpac#add('vim-autoformat/vim-autoformat')
" vim-IndentCommentPrefix: Indents comments sensibly {{{3
""call minpac#add('inkarkat/vim-IndentCommentPrefix')
" >> : Indent, keeping comment prefix where it is
" << : Deindent, keeping comment prefix where it is
" g>> : Indent, including comment prefix
" Use single > or < in Visual mode
" Comment chars in this list will *not* be left in column 1
"let g:IndentCommentPrefix_Blacklist = ['#', '>']
" Any string in this list *will* remain in column 1
"let g:IndentCommentPrefix_Whitelist = ['REMARK:']
" vim-ingo-library: library functions required by IndentCommentPrefix {{{3
""call minpac#add('inkarkat/vim-ingo-library')
" vim-markdown-folding: Fold Markdown files on headers {{{3
""call minpac#add('masukomi/vim-markdown-folding', {'type': 'opt'})
""autocmd load_plugins FileType markdown packadd vim-markdown-folding
" OPTIONAL {{{2
" a.vim: Swap header and source files {{{3
call minpac#add('vim-scripts/a.vim', {'type': 'opt'})
" :A : Switch between header and source files
" :AS: Split and switch
" :AV: Vertical split and switch
autocmd load_plugins FileType c packadd a.vim
" ansible-vim: Syntax highlighting Ansible's common filetypes {{{3
call minpac#add('pearofducks/ansible-vim')
let g:ansible_attribute_highlight = 'ab' " highlight all key=value pairs
let g:ansible_name_highlight = 'b' " highlight 'name:'
let g:ansible_extra_keywords_highlight = 1 " highlight extra keywords
" Highlight groups using specified group (:help E669)
let g:ansible_normal_keywords_highlight = 'Statement'
let g:ansible_loop_keywords_highlight = 'Statement'
let g:ansible_extra_keywords_highlight_group = 'Delimiter'
" See custom color settings below to customize 'name_highlight'
" Properly highlight HCL Jinja templates
let g:ansible_template_syntaxes = {'*.hcl.j2': 'hcl', '*.tf.j2': 'hcl', '*.sh.j2': 'sh'}
" When to use filetype=yaml.ansible
let g:ansible_ftdetect_filename_regex = '\v(playbook|site|main|local|requirements)\.ya?ml$'
let g:ansible_goto_role_paths = './roles,../_common/roles'
" CCTree: Vim CCTree plugin {{{3
if has("cscope")
call minpac#add('hari-rangarajan/CCTree', {'type': 'opt'})
" See Mappings & Commands -> Cscope for mappings
set cscopetag " use cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetagorder=0 " search cscope then ctags
set cscopequickfix=s-,c-,d-,i-,t-,e-,a- " Open all results in quickfix
" Automatically load database if it exists in current directory
" or if defined in $CSCOPE_DB
function! s:load_cscope_db()
if filereadable("cscope.out")
packadd CCTree
CCTreeLoadDB cscope.out
elseif $CSCOPE_DB != ""
packadd CCTree
CCTreeLoadDB $CSCOPE_DB
endif
endfunction
autocmd VimEnter * call s:load_cscope_db()
endif
" cisco.vim: Vim syntax for cisco configuration files {{{3
call minpac#add('momota/cisco.vim', {'type': 'opt'})
autocmd load_plugins FileType cisco packadd cisco.vim
" Colorizer: Color hex codes and color names{{{3
call minpac#add('chrisbra/Colorizer', {'type': 'opt'})
" Turn off color:
" :ColorClear
" Toggle color:
" :ColorToggle
" Automatically colorize these filetypes
let g:colorizer_auto_filetype = 'css,html,markdown,xdefaults'
let g:colorizer_disable_bufleave = 0 " Only highlight above files
" Highlight X11 colornames in Xresources and such
let g:colorizer_x11_names = 1
execute 'au Filetype ' . g:colorizer_auto_filetype . ' packadd Colorizer | ColorToggle'
" fugitive-gitea: Plugin for :Gbrowse to work with GITea server {{{3
call minpac#add('borissov/fugitive-gitea', {'type': 'opt'})
" fugitive-gitlab: A vim extension to fugitive.vim for GitLab support {{{3
call minpac#add('shumphrey/fugitive-gitlab.vim', {'type': 'opt'})
" gemini-vim-syntax: Syntax highlighting for text/gemini files {{{3
call minpac#add('https://tildegit.org/sloum/gemini-vim-syntax', {'type': 'opt'})
autocmd load_plugins FileType gmi packadd gemini-vim-syntax
" scss-syntax: Sassy CSS for vim {{{3
call minpac#add('cakebaker/scss-syntax.vim', {'type': 'opt'})
autocmd load_plugins FileType scss packadd scss-syntax-vim
" tagalong: Change an HTML(ish) tag and update the matching one {{{3
call minpac#add('AndrewRadev/tagalong.vim')
let g:tagalong_additional_filetypes = ['xml', 'html', 'php']
execute 'au Filetype ' . join(g:tagalong_additional_filetypes, ',') . ' packadd tagalong.vim'
" todo-txt.vim: Vim plugin for Todo.txt {{{3
call minpac#add('freitass/todo.txt-vim', {'type': 'opt'})
" <LocalLeader>s : Sort by priority
" <LocalLeader>s+ : Sort on +Projects
" <LocalLeader>s@ : Sort on @Contexts
" <LocalLeader>sd : Sort on due dates
" <LocalLeader>sc : Sort by context, then priority
" <LocalLeader>scp : Sort by context, project, then priority
" <LocalLeader>sp : Sort by project, then priority
" <LocalLeader>spc : Sort by project, context, then priority
" <LocalLeader>-sd : Sort by due date. Entries with due date are at the beginning
" <LocalLeader>j : Lower priority
" <LocalLeader>k : Increase priority
" <LocalLeader>a : Add priority (A)
" <LocalLeader>b : Add priority (B)
" <LocalLeader>c : Add priority (C)
" <LocalLeader>d : Insert current date
" date<tab> : (Insert mode) insert current date
" due: : (Insert mode) insert due: <date>
" DUE: : (Insert mode) insert DUE: <date>
" <LocalLeader>x : Toggle done
" <LocalLeader>C : Toggle cancelled
" <LocalLeader>X : Mark all completed
" <LocalLeader>D : Move completed tasks to done file
autocmd load_plugins FileType todo packadd todo.txt-vim
" vim-closetag: Easily close HTML/XML tags {{{3
call minpac#add('alvan/vim-closetag', {'type': 'opt'})
" Current content:
" <table|
" Press >:
" <table>|</table>
" Press > again:
" <table>
" |
" </table>
" Use closetag in these files
let g:closetag_filenames = "*.sgml,*.xml,*.html,*.xhtml,*.phtml,*.php"
autocmd load_plugins FileType sgml packadd vim-closetag
autocmd load_plugins FileType xml packadd vim-closetag
autocmd load_plugins FileType html packadd vim-closetag
autocmd load_plugins FileType xhtml packadd vim-closetag
autocmd load_plugins FileType phtml packadd vim-closetag
autocmd load_plugins FileType php packadd vim-closetag
" vim-fugitive: Git in Vim {{{3
call minpac#add('tpope/vim-fugitive', {'type': 'opt'})
"set completopt-=preview " disable issue body preview
" Load plugin on-demand
" TODO: Add these and the gitlab/gitea plugins to a list/augroup which is all
" loaded at once
command -nargs=? Git packadd vim-fugitive | packadd vim-fugitive-blame-ext | packadd vim-rhubarb | :Git <args>
" vim-fugitive-blame-ext: extend vim-fugitive to show commit message on statusline in :Gblame {{{3
call minpac#add('tommcdo/vim-fugitive-blame-ext', {'type': 'opt'})
" vim-gist: Edit github.com gists with vim {{{3
call minpac#add('mattn/vim-gist', {'type': 'opt'})
" Load plugin on-demand
command -nargs=? Gist packadd webapi-vim | packadd vim-gist | :Gist <args>
let g:gist_post_private = 1 " Private gists by default
" :Gist -P to create public Gist
" vim-gitgutter: Use the sign column to show git chanages {{{3
call minpac#add('airblade/vim-gitgutter', {'type': 'opt'})
" The default updatetime of 4000ms is not good for async update
set updatetime=100
" Use fontawesome icons as signs
" NOTE: requires a 'nerd font'
let g:gitgutter_sign_added = ''
let g:gitgutter_sign_modified = ''
let g:gitgutter_sign_removed = ''
let g:gitgutter_sign_removed_first_line = ''
let g:gitgutter_sign_modified_removed = ''
" vim-ini-fold: folding for ini-like files {{{3
call minpac#add('matze/vim-ini-fold')
autocmd load_plugins FileType dosini packadd vim-ini-fold
" vim-markdown: Markdown vim mode {{{3
call minpac#add('preservim/vim-markdown', {'type': 'opt'})
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_folding_style_pythonic = 1
let g:vim_markdown_folding_level = 1
let g:vim_markdown_override_foldtext = 0
let g:vim_markdown_follow_anchor = 1
let g:vim_markdown_conceal_code_blocks = 0
autocmd load_plugins FileType markdown packadd vim-markdown
" vim-redact-pass: Do not write passwords into vim files when using pass(1) {{{3
call minpac#add('https://dev.sanctum.geek.nz/code/vim-redact-pass.git', {'type': 'opt', 'rev': 'master'})
au BufRead **/pass*/*.txt packadd vim-redact-pass
" vim-rhubarb: GitHub extension for fugitive.vim {{{3
call minpac#add('tpope/vim-rhubarb', {'type': 'opt'})
" vim-sxhkdrc: Vim syntax for sxhkd's configuration files {{{3
call minpac#add('baskerville/vim-sxhkdrc')
autocmd load_plugins FileType sxhkdrc packadd vim-sxhkdrc
" vim-terraform: basic vim/terraform integration {{{3
call minpac#add('hashivim/vim-terraform')
autocmd load_plugins FileType hcl packadd vim-terraform
autocmd load_plugins FileType json packadd vim-terraform
autocmd load_plugins FileType terraform packadd vim-terraform
" vim-textobj-sentence: Improving native sentence text object and motion {{{3
call minpac#add('preservim/vim-textobj-sentence', {'type': 'opt'})
augroup textobj_sentence
autocmd!
autocmd FileType markdown packadd vim-textobj-user | packadd vim-textobj-sentence | call textobj#sentence#init()
autocmd FileType text packadd vim-textobj-user | packadd vim-textobj-sentence | call textobj#sentence#init()
augroup END
" vim-textobj-user: Create your own text objects {{{3
" (required by vim-textobj-sentence)
call minpac#add('kana/vim-textobj-user', {'type': 'opt'})
" vim-tmux: Vim plugin for .tmux.conf {{{3
call minpac#add('tmux-plugins/vim-tmux', {'type': 'opt'})
autocmd load_plugins FileType tmux packadd vim-tmux
" vim-tridactyl: Syntax plugin for Tridactyl configuration files {{{3
call minpac#add('tridactyl/vim-tridactyl')
autocmd load_plugins FileType tridactyl packadd vim-tridactyl
" vim-tmux-pilot: Unified navigation of splits and tabs in nvim and tmux {{{3
call minpac#add('urbainvaes/vim-tmux-pilot')
" Use Alt+[hjkl] to navigate windows
if has ('unix') " set convert-meta off in .inputrc makes Alt not the Meta key
let g:pilot_key_h='h'
let g:pilot_key_j='j'
let g:pilot_key_k='k'
let g:pilot_key_l='l'
let g:pilot_key_p='\'
else
let g:pilot_key_h='<a-h>'
let g:pilot_key_j='<a-j>'
let g:pilot_key_k='<a-k>'
let g:pilot_key_l='<a-l>'
let g:pilot_key_p='<a-\>'
endif
" vimtex: vim LaTeX plugin {{{3
call minpac#add('lervag/vimtex', {'type': 'opt'})
let g:vimtex_view_method = 'zathura'
autocmd load_plugins FileType tex packadd vimtex
" webapi-vim: Needed for vim-gist {{{3
call minpac#add('mattn/webapi-vim', {'type': 'opt'})
endif " minpac loaded
" Conditionally load git related plugins {{{3
silent! !git rev-parse --is-inside-work-tree >/dev/null 2>&1
if v:shell_error == 0
packadd vim-gitgutter
endif
" AUTOMATIC {{{2
" indentLine: Display the indentation levels with thin vertical lines {{{3
call minpac#add('wickles/indentLine')
let g:indentLine_char = '│'
let g:indentLine_bufTypeExclude = ['help', 'terminal', 'markdown']
"let g:indentLine_bufNameExclude = ['tagbar?']
" Hide indents on cursor line
let g:indentLine_concealcursor = ''
" Use this if JSON quotes are hidden
" let g:vim_json_syntax_conceal = 0
" tabular: Smart alignment of tables {{{3
call minpac#add('godlygeek/tabular')
" :Tabularize /<delimiter>/<format>
"
" <format> : (l)eft, (r)ight, (center)
" Each can be followed by a number indicating padding
"
" Example:
" x = 12;
" num = 13;
" var2 = 1;
"
" :Tabularize /=/l0r1
"
" x = 12;
" num = 13;
" var2= 1;
"
" Example:
" osh/Sh6: V6 sh ports (http://v6shell.org)
" sent: Console "powerpoint" (http://tools.suckless.org/sent)
" pixie: Color picker (http://nattyware.com/pixie.php)
"
" Align on *first* character only:
" :Tabularize /^[^:]*\zs:
"
" osh/Sh6 : V6 sh ports (http://v6shell.org)
" sent : Console "powerpoint" (http://tools.suckless.org/sent)
" pixie : Color picker (http://nattyware.com/pixie.php)
"
" :AddTabularPattern <name> <pattern> allows you to save patterns
"
" Custom mappings:
" ----------------
" <Leader>t= : = (with space)
" <Leader>t: : : (with space)
" <Leader>t:: : : (no space before)
" <Leader>t, : , (with space)
" <Leader>t| : | (with space)
"
nmap <Leader>t= :Tabularize /=<cr>
vmap <Leader>t= :Tabularize /=<cr>
nmap <Leader>t: :Tabularize /:<cr>
vmap <Leader>t: :Tabularize /:<cr>
nmap <Leader>t:: :Tabularize /:\zs<cr>
vmap <Leader>t:: :Tabularize /:\zs<cr>
nmap <Leader>t, :Tabularize /,<cr>
vmap <Leader>t, :Tabularize /,<cr>
nmap <Leader>t<Bar> :Tabularize /<Bar><cr>
vmap <Leader>t<Bar> :Tabularize /<Bar><cr>
" tagbar: Source code browser using ctags {{{3
call minpac#add('preservim/tagbar')
" ctags commands
" --------------
" CTRL-] : Jump to tag underneath cursor
" CTRL-o : Jump back in the tag stack
" :ts <tag> : Search for <tag>
" :tn : Go to next definition of last tag
" :tp : Go to previous definition of last tag
" :ts : List all definitions of last tag
"
" Default settings
" ----------------
" let g:tagbar_left = 1
" let g:tagbar_width = 40
" let g:tagbar_autoclose = 0
" <F9> : toggle TagBar
noremap <silent> <F9> :TagbarToggle<cr>
" Add support for Makefiles (requires adding
" --regex-make=/^([^# \t:]*):/\1/t,target/
" to ~/.ctags)
let g:tagbar_type_make = {'kinds':
\ ['m:macros',
\ 't:targets']}
" Add support for Markdown
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'markdown',
\ 'ctagsbin' : 'markdown2ctags',
\ 'ctagsargs' : '-f - --sort=yes --sro=»',
\ 'kinds' : ['s:sections', 'i:images'],
\ 'sro' : '»',
\ 'kind2scope' : {'s' : 'section',},
\ 'sort' : 0}
" vim-commentary: Commenting keymaps {{{3
call minpac#add('tpope/vim-commentary')
" gc{motion} : Toggle commenting over {motion}
" gcc : Toggle commenting of [count] lines
" {Visual}gc : Toggle commenting of highlighted lines
" gcu : Uncomment current and adjacent lines
" vim-repeat: Enable repeating supported plugin maps with "."{{{3
call minpac#add('tpope/vim-repeat')
" vim-surround: Modify surrounding characters {{{3
call minpac#add('tpope/vim-surround')
" ds<t> : delete <t>
" cs<t><r> : change <t> to <r>
" csw<t> : surround current word with <t>
" ysiw<t> : surround current word with <t>
" yss<t> : surround current line with <t>
" ys<motion><t> : surround <motion> with <t>
" VS<t> : surround selection with <t> on separate lines
" Special characters for <t> and <r>
" ( { [ < : trim/insert spaces
" ) } ] > : DO NOT trim/insert spaces
" " ' ` : quote pairs (current line only)
" t : HTML tag
" w, W : word, WORD (<t> only)
" s : sentence (<t> only)
" p : paragraph (<t> only)
" Using 't' for <r>
" Vim will prompt for the tag to insert. Any attributes given
" will be stripped from the closing tag.
" No configuration needed
"
" YankRing.vim: Maintains a history of previous yanks, changes and deletes {{{3
call minpac#add('vim-scripts/YankRing.vim')
let g:yankring_history_dir = '$HOME/var/cache'
" Basics {{{1
" ======
filetype plugin indent on " Load filetype plugins and indent settings
set omnifunc=syntaxcomplete#Complete " Complete on syntax (CTL-X CTL-O to complete)
set encoding=utf8 " Use Unicode
set noexrc " Do not source .exrc
set autowrite " Write file when changing to a new file
set wildmenu " Show wildmenu
set wildmode=longest:full,full " Tab complete longest part, then show wildmenu
set backspace=indent,eol,start " What BS can delete
set backupdir=~/.vim/backup " Where to put backup files
set directory=~/.vim/tmp " Where to put swap files
set mouse=a " Use mouse everywhere
set mousehide " Hide mouse while typing
set incsearch " Incremental search
set nolist " Do not show listchars
set listchars=
set listchars+=extends:>,precedes:< " Show long line continuation chars
set listchars+=tab:»\ " Show real tabs
set listchars+=trail:. " Show trailing spaces and higlight them
set listchars+=eol:¬ " Show end of line
set listchars+=nbsp:+ " Show non-breaking space
set cursorline " Highlight current line
set visualbell " Blink instead of beep
set relativenumber " Show relative line number
set number " Show line number of current line
set numberwidth=4 " Allows line numbers up to 999
set report=0 " Always report when a : command changes something
set shortmess=aOstT " Keep messages short
set scrolloff=99 " Basically keep cursor centered on the screen vertically
set sidescrolloff=10 " Keep 10 lines at right/left
set sidescroll=1 " Horizontal scroll one column at a time
set showtabline=0 " Never show tabline
set hidden " Allow hidden buffers
set tags-=./tags " Remove ./tags and ./tags; from 'tags'
set tags-=./tags; " and prepend ./tags; in order to search
set tags^=./tags; " up the tree for the tags file
set complete-=i " *Do not* search included files when completing
set history=1000 " Save more command history
set fillchars=vert:\|,fold:―
set undofile " Persistent undo tree
set undodir=~/.vim/undo " Put undo files here
call mkdir(&undodir, "p", 0o700)
set path^=$DOTFILES " Search for files in $DOTFILES
set path+=~/work/fen-x/fenx-infra
set path+=~/work/fen-x/fenx-infra/fenx_infra
" ttymouse is not properly set if TERM=tmux*
" and then I can't use the mouse to resize splits
if &term =~ "tmux"
set ttymouse=sgr
endif
" Absolute & Hybrid line numbers by buffer status {{{2
"
" https://jeffkreeftmeijer.com/vim-number/
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &number && mode() != 'i' | set relativenumber | endif
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &number | set norelativenumber | endif
augroup END
" Automatically open quickfix window {{{2
augroup quickfix
autocmd!
autocmd QuickFixCmdPost [^l]* cwindow
autocmd QuickFixCmdPost l* lwindow
augroup END
" Searching {{{2
if executable('rg')
set grepprg=rg\ --vimgrep
endif
" grep/lgrep without polluting the terminal or opening the first match
"
" Respects &grepprg
"
" https://gist.github.com/romainl/56f0c28ef953ffc157f36cc495947ab3
function! Grep(...)
return system(join([&grepprg] + [expandcmd(join(a:000, ' '))], ' '))
endfunction
command! -nargs=+ -complete=file_in_path -bar Grep cgetexpr Grep(<f-args>)
command! -nargs=+ -complete=file_in_path -bar LGrep lgetexpr Grep(<f-args>)
cnoreabbrev <expr> grep (getcmdtype() ==# ':' && getcmdline() ==# 'grep') ? 'Grep' : 'grep'
cnoreabbrev <expr> lgrep (getcmdtype() ==# ':' && getcmdline() ==# 'lgrep') ? 'LGrep' : 'lgrep'
" Text Formatting/Layout {{{1
"===========================
set formatoptions+=rqlnj " j: delete comment leader when joining lines
" l: do not break long lines in insert mode
" n: support numbered lists (:help formatlistpat)
" q: reformat comments with 'gq'
" r: insert comment leader on <Enter>
set ignorecase " Case insensitive by default
set smartcase " but case sensitive if search string is multi-case
set nowrap " Long lines do not wrap
set shiftround " Indent at multiples of shiftwidth
set expandtab " Expand tabs to spaces
set tabstop=4 " Real tabs are 4 spaces
set softtabstop=4 " A tab is 4 spaces for a tab or backspace
set shiftwidth=4 " Indent and <</>> is 4 spaces
set textwidth=80 " Lines wrap at column 80
set autoindent " Automatically indent based on previous line
set smartindent " Automatic indenting is intelligent
" Statusline {{{1
" ==========
function! SL_GitHunks()
if system('git rev-parse --is-inside-work-tree 2>/dev/null') !~ 'true'
return ''
endif
let [a,m,r] = GitGutterGetHunkSummary()
let s = printf('[+%d %~%d -%d] ', a, m, r)
return s
endfunction
function! SL_GitBranch()
let b = substitute(system('git rev-parse --abbrev-ref HEAD 2>/dev/null'), '\n\+$', '', '')
let s = strlen(b) ? ' ' . b . ' ' : ''
return s
endfunction
function! SL_isactive()
return g:statusline_winid == win_getid(winnr())
endfunction
function! Statusline() abort
let s = ' '
"let s .= '%{SL_GitBranch()} '
let s .= '%F'
let s .= '%m'
let s .= '%r'
let s .= ' '
let s .= '[%Y]'
let s .= '%='
"let s .= '%{SL_GitHunks()}'
let s .= '%l(%L):%c'
let s .= ' '
let s .= '[UNICODE 0x%B]'
return s
endfunction
set laststatus=2 " Always show status line
set statusline=%!Statusline()
" Terminal window status line
augroup termwindow | autocmd!
autocmd TerminalWinOpen * setlocal statusline=%t
augroup end
" Folding {{{1
"============
set foldenable " Turn on folding
set foldmethod=marker " Fold on the marker
set foldopen=block,hor,mark,percent,quickfix,tag " What movements open folds
" Right justify folded line count
"
" dhruvasagar (dhruvasagar.com/2013/03/28/vim-better-foldtext)
function! NeatFoldText()
let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' '
let lines_count = v:foldend - v:foldstart + 1
let lines_count_text = '| ' . printf("%10s", lines_count . ' lines') . ' |'
let foldchar = matchstr(&fillchars, 'fold:\zs.')
let foldtextstart = strpart('+' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
let foldtextend = lines_count_text . repeat(foldchar, 8)
let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
endfunction
set foldtext=NeatFoldText()
" Mappings & Commands {{{1
"========================
" Help {{{2
" map: normal, visual, select, operator-pending
" nmap: normal
" vmap: visual and select
" omap: operator-pending
" xmap: visual
" smap: select
" map!: insert and command-line
" imap: insert
" cmap: command line
" lmap: insert, command line, language-arg
"
" *nore*: non-recursive mapping
"
" <silent> : don't echo mapping on command line
" <expr> : mapping inserts result of {rhs}
" <buffer> : buffer local mapping
" Window Management: {{{2
" ==================
" See vim-tmux-pilot configuration
" Resize windows with C-[hjkl] {{{3
nnoremap <C-j> <C-w>-
nnoremap <C-k> <C-w>+
nnoremap <C-h> <C-w><
nnoremap <C-l> <C-w>>
" Maximize/Minimize window with CTRL-W m {{{3
"
" pmalek (github.com/pmalek/toggle-maximize.vim)
let t:maximizeCurrentWindow = 0
function! ToggleMaximizeCurrentWindow()
if t:maximizeCurrentWindow == 0
:vertical resize
:resize
let t:maximizeCurrentWindow = 1
else
:exe "normal \<C-W>="
let t:maximizeCurrentWindow = 0
endif
endfunction
nnoremap <silent> <C-W>m :call ToggleMaximizeCurrentWindow() <cr>
" Terminal Mode {{{2
"
" <leader><Esc>: Enter normal mode
tnoremap <leader><Esc> <C-\><C-n>
" Searching {{{2
"
" Metacharacters do not need escaped (very magic, :help \v)
nnoremap / /\v
vnoremap / /\v
" <leader>c: toggle colorcolumn {{{2
"
" Kevin Kuchta (www.vimbits.com/bits/317)
function! g:ToggleColorColumn()
if &colorcolumn == ''
setlocal colorcolumn=80
else
setlocal colorcolumn&
endif
endfunction
nnoremap <silent> <leader>c :call g:ToggleColorColumn()<cr>
" <leader>l: toggle listchars {{{2
nnoremap <silent> <leader>l :set list!<cr>
" <leader>s: split line {{{2
"
" https://gist.github.com/romainl/3b8cdc6c3748a363da07b1a625cfc666
function! BreakHere()
s/^\(\s*\)\(.\{-}\)\(\s*\)\(\%#\)\(\s*\)\(.*\)/\1\2\r\1\4\6
call histdel("/", -1)
endfunction
nnoremap <leader>s :<C-u>call BreakHere()<CR>
" <leader><leader>: clear search highlighting {{{2
noremap <silent> <leader><leader> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
" fN: set foldlevel=N {{{2
noremap <leader>f0 :set foldlevel=0<cr>
noremap <leader>f1 :set foldlevel=1<cr>
noremap <leader>f2 :set foldlevel=2<cr>
noremap <leader>f3 :set foldlevel=3<cr>
noremap <leader>f4 :set foldlevel=4<cr>
noremap <leader>f5 :set foldlevel=5<cr>
noremap <leader>f6 :set foldlevel=6<cr>
noremap <leader>f7 :set foldlevel=7<cr>
noremap <leader>f8 :set foldlevel=8<cr>
noremap <leader>f9 :set foldlevel=9<cr>
" [<Space> / ]<Space>: add [n] blank lines before/after line {{{2
"
" https://superuser.com/a/607168
nnoremap <silent> [<Space> :<C-u>put!=repeat(nr2char(10),v:count)<Bar>execute "']+1"<CR>
nnoremap <silent> ]<Space> :<C-u>put =repeat(nr2char(10),v:count)<Bar>execute "'[-1"<CR>
" [e / ]e: exchange current line with previous/next {{{2
nnoremap [e kddp
nnoremap ]e jddkP
" <Tab>: % {{{2
nmap <tab> %
vmap <tab> %
" Y: yank to end (consistent with C and D) {{{2
nnoremap Y y$