-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvimrc
2817 lines (2200 loc) · 95.3 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
" ============================================================================
" _
" __ _(_)_ __ ___ _ __ ___
" \ \ / / | '_ ` _ \| '__/ __|
" \ V /| | | | | | | | | (__
" \_/ |_|_| |_| |_|_| \___|
"
" ----------------------------------------------------------------------------
"
" vimrc
"
" Startup commands for Vim.
"
" http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc
" https://github.com/amix/vimrc
"
" Load order:
" vimrc (This file)
" after/plugin/*
" gvimrc
"
" ---------
" About Vim
"
" Vim is a highly configurable text editor for efficiently creating and
" changing any kind of text. It is included as `vi` with most UNIX systems and
" with Apple OS X.
"
" https://www.vim.org/
"
" ----------
" Perfomance
"
" To log startup timing:
"
" vim --startuptime vim-startup.log test.md
"
" Identified slow-loading files:
"
" - `vim-bufkill/plugin/bufkill.vim`
" - `vim-airline/autoload/airline/extensions/default.vim`
" - `/usr/local/Cellar/neovim/0.1.7/share/nvim/runtime/syntax/markdown.vim`
" - `neomake/autoload/neomake.vim`
"
" ---------
" Resources
"
" - https://github.com/mhinz/vim-galore
" All things Vim!
" - https://github.com/amix/vimrc
" The ultimate Vim configuration: vimrc
" - https://github.com/carlhuda/janus
" - https://spacevim.org/
" https://github.com/SpaceVim/SpaceVim
" A community-driven vim distribution
" - https://github.com/LER0ever/EverVim
" A Modern, Powerful & Modular Vim Distribution
" - https://vim.spf13.com/
" https://github.com/spf13/spf13-vim
" spf13-vim is a distribution of vim plugins and resources for Vim, GVim and
" MacVim.
" - https://github.com/liangxianzhe/oh-my-vim
"
" ============================================================================
" ============================================================================
" vimrc • begin begin • vimrc
" ------------- -------------
" ############################################################################
" ____
" / ___|___ _ __ ___
"| | / _ \| '__/ _ \
"| |__| (_) | | | __/
" \____\___/|_| \___|
"
" ############################################################################
" ============================================================================
" Leader
" ============================================================================
" change the leader from backslash (\) to comma (,)
let mapleader=","
" ============================================================================
" Base Vim Settings
"
" Migrated from:
" janus/vim/core/before/plugin/settings.vim
" ============================================================================
" set nocompatible and hidden
"
" Required by plugins like vim-ctrlspace
"
" http://vimdoc.sourceforge.net/htmldoc/options.html#'compatible'
if has('vim_starting') && !has('nvim') && &compatible
set nocompatible " Be iMproved
endif
" http://vimdoc.sourceforge.net/htmldoc/options.html#'hidden'
set hidden
" encoding
"
" string (default: 'latin1' or value from $LANG)
"
" http://vimdoc.sourceforge.net/htmldoc/options.html#'encoding'
" NOTE: Neovim disallow changing 'enconding' option after initialization
" see https://github.com/neovim/neovim/pull/2929 for more details
if !has('nvim')
set encoding=UTF-8 " Set default encoding to UTF-8
endif
" Show line numbers
set number
" Show line and column number
set ruler
" Turn on syntax highlighting allowing local overrides
syntax enable
" updatetime
"
" Set to 100ms (default 4000) to reduce the update delay experienced with
" plugins like vim-gitgutter.
"
" http://vimdoc.sourceforge.net/htmldoc/options.html#'updatetime'
" https://www.reddit.com/r/vim/comments/3ql651/
" https://github.com/airblade/vim-gitgutter#getting-started
set updatetime=100
" formatoptions
"
" r Automatically insert the current comment leader after hitting <Enter> in
" Insert mode
set formatoptions+=r
" clipboard
"
" Cross-platform clipboard configuration.
"
" More information: https://stackoverflow.com/a/30691754
set clipboard^=unnamed,unnamedplus
" ============================================================================
" Whitespace
"
" Copied (and edited) from: janus/vim/core/before/plugin/settings.vim
" ============================================================================
set tabstop=2 " a tab is two spaces
set shiftwidth=2 " an autoindent (with <<) is two spaces
set expandtab " use spaces, not tabs
set list " Show invisible characters
set backspace=indent,eol,start " backspace through everything in insert mode
if exists("g:enable_mvim_shift_arrow")
let macvim_hig_shift_movement = 1 " mvim shift-arrow-keys
endif
" List chars
set listchars="" " Reset the listchars
set listchars=tab:\ \ " a tab should display as " ", trailing whitespace as "."
set listchars+=trail:. " show trailing spaces as dots
set listchars+=extends:> " The character to show in the last column when wrap is
" off and the line continues beyond the right of the screen
set listchars+=precedes:< " The character to show in the last column when wrap is
" off and the line continues beyond the left of the screen
" ============================================================================
" Searching
"
" Copied from: janus/vim/core/before/plugin/settings.vim
" ============================================================================
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
" ============================================================================
" Wild settings
"
" Copied from: janus/vim/core/before/plugin/settings.vim
" ============================================================================
" TODO: Investigate the precise meaning of these settings
" set wildmode=list:longest,list:full
" Disable output and VCS files
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.rbo,*.class,.svn,*.gem
" Disable archive files
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
" Ignore bundler and sass cache
set wildignore+=*/vendor/gems/*,*/vendor/cache/*,*/.bundle/*,*/.sass-cache/*
" Ignore librarian-chef, vagrant, test-kitchen and Berkshelf cache
set wildignore+=*/tmp/librarian/*,*/.vagrant/*,*/.kitchen/*,*/vendor/cookbooks/*
" Ignore rails temporary asset caches
set wildignore+=*/tmp/cache/assets/*/sprockets/*,*/tmp/cache/assets/*/sass/*
" Disable temp and backup files
set wildignore+=*.swp,*~,._*
" ============================================================================
" Temporary Directories
"
" NOTE: This overrides settings from Janus:
" janus/vim/core/before/plugin/settings.vim#L79
" ============================================================================
" http://vimdoc.sourceforge.net/htmldoc/options.html#'backupdir'
set backupdir^=~/.vim/cache/backup//
" http://vimdoc.sourceforge.net/htmldoc/options.html#'directory'
set directory^=~/.vim/cache/temp//
" =============================================================================
" netrw
"
" Network oriented reading, writing, and browsing.
"
" Commands:
" https://gist.github.com/danidiaz/37a69305e2ed3319bfff9631175c5d0f
"
" More info:
" https://github.com/vim/vim/blob/master/runtime/doc/pi_netrw.txt
" =============================================================================
" Display preview in vertical split.
let g:netrw_preview = 1
" =============================================================================
" filetypes.vim
"
" Adapted from:
" https://github.com/carlhuda/janus/blob/master/janus/vim/core/before/plugin/filetypes.vim
" =============================================================================
filetype plugin indent on " Turn on filetype plugins (:help filetype-plugin)
if has("autocmd")
" In Makefiles, use real tabs, not tabs expanded to spaces
au FileType make setlocal noexpandtab
" Make sure all mardown files have the correct filetype set and setup wrapping
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,txt} setf markdown
if !exists("g:disable_markdown_autostyle")
au FileType markdown setlocal wrap linebreak textwidth=72 nolist
endif
" make Python follow PEP8 for whitespace ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python setlocal tabstop=4 shiftwidth=4
" Remember last location in file, but not for commit messages.
" see :help last-position-jump
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g`\"" | endif
endif
" =============================================================================
" Optional auto-save on focus lost
"
" Adapted from:
" https://github.com/carlhuda/janus/blob/master/janus/vim/core/before/plugin/autocmds.vim
"
" See also:
" https://stackoverflow.com/a/15252783
" =============================================================================
if has("autocmd")
if exists("g:autosave_on_blur")
au FocusLost * silent! wall
endif
endif
" ############################################################################
" _ _
" _ __ ___ _____ _(_) __| | ___
" | '_ \ / _ \/ _ \ \ / / |/ _` |/ _ \
" | | | | __/ (_) \ V /| | (_| | __/
" |_| |_|\___|\___/ \_/ |_|\__,_|\___|
"
" https://neovide.dev/configuration.html
" https://neovide.dev/
" https://github.com/neovide/neovide
" ############################################################################
if exists("g:neovide")
let g:neovide_cursor_animation_length = 0
let g:neovide_cursor_trail_size = 0
endif
" ############################################################################
" ____ _ _
" | _ \| |_ _ __ _(_)_ __ ___
" | |_) | | | | |/ _` | | '_ \/ __|
" | __/| | |_| | (_| | | | | \__ \
" |_| |_|\__,_|\__, |_|_| |_|___/
" |___/
"
" Resources:
" - https://gist.github.com/manasthakur/ab4cf8d32a28ea38271ac0d07373bb53
" - https://shapeshed.com/vim-packages/#vim-8-brings-native-third-party-package-loading
"
" NOTE: Slow plugins:
" - TagBar
" - Calling ctags is slow, particularly the initial calls for a buffer.
" - Syntastic
" - Does not have an async option at this time. Consider Neomake instead.
" - NERDTree
"" ############################################################################
" s:PluginEnabled()
"
" A utility function to test whether a plugin is installed and enabled.
"
" Returns:
" true If matching the given name is enabled.
" false If not.
"
" More Information:
" https://vi.stackexchange.com/a/10947
function! PluginEnabled(name)
return len(
\ filter(split(execute(':scriptname'), "\n"), 'v:val =~? "' . a:name . '"')
\ ) != 0
endfunction
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
" Pathogen
"
" Manage your 'runtimepath' with ease. In practical terms, pathogen.vim makes
" it super easy to install plugins and runtime files in their own private
" directories.
"
" https://github.com/tpope/vim-pathogen
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
" ============================================================================
" Disable Pathogen plugins
"
" NOTE: This section must come before `janus#disable_plugin` is called since
" it apparently uses the `g:pathogen_disabled` variable..
" ============================================================================
" To disable a plugin, add its bundle name to the following list
let g:pathogen_disabled = []
" Example disable call:
"
" call add(g:pathogen_disabled, '<plugin_name>')
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
" vim-plug (begin)
"
" A minimalist Vim plugin manager.
"
" https://github.com/junegunn/vim-plug
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
" Plugins will be downloaded under the specified directory.
call plug#begin('~/.vim/vim-plug')
" ============================================================================
" vim-devicons
"
" Adds file type glyphs/icons to popular Vim plugins: NERDTree, vim-airline,
" Powerline, Unite, vim-startify and more.
"
" https://github.com/ryanoasis/vim-devicons
" https://github.com/ryanoasis/vim-devicons/wiki/Extra-Configuration
"
" NOTE: Load vim-devicons first so it's available when NERDTree and other
" plugins load.
" ============================================================================
function! SetupPluginVimDevicons()
" Init: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Plug init:
" Plug 'ryanoasis/vim-devicons'
" Native Vim init:
packadd vim-devicons
" After: •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Disable g:NERDTreeUpdateOnCursorHold
"
" This setting appears to cause ALE warnings in the statusline /
" command-line / cmdline to show and immediately disappear in some cases.
" This is confirmed to happen when NERDTree is open and the focus goes from
" an embedded terminal window to the window with the file that has errors.
" This does not happen when when focus comes from a normal buffer window.
"
" Search for this variable in the devicons project on GitHub:
" https://git.io/JUlFr
let g:NERDTreeUpdateOnCursorHold = 0
" enable folder/directory glyph flag (disabled by default with 0)
let g:WebDevIconsUnicodeDecorateFolderNodes = 1
" enable open and close folder/directory glyph flags (disabled by default
" with 0)
let g:DevIconsEnableFoldersOpenClose = 1
" adding to vim-airline's tabline
let g:webdevicons_enable_airline_tabline = 1
" ctrlp glyphs
let g:webdevicons_enable_ctrlp = 1
if has("gui_macvim") && has("gui_running")
" specify OS to decide an icon for unix fileformat (not defined by default)
let g:WebDevIconsOS = 'Darwin'
" Reduce the amount of space after the glyph character (default ' ').
let g:WebDevIconsNerdTreeAfterGlyphPadding = ''
endif
endfunction
" ============================================================================
" Tab Completion Plugins
"
" Conquer of Completion (CoC)
" ---------------------------
"
" Nodejs extension host for vim & neovim, load extensions like VSCode and host
" language servers.
"
" https://github.com/neoclide/coc.nvim
"
" deoplete.nvim
" -------------
"
" Dark powered asynchronous completion framework for neovim/Vim8
" https://github.com/Shougo/deoplete.nvim
"
" Supertab
" --------
"
" Perform all your vim insert mode completions with Tab.
"
" https://github.com/ervandew/supertab
"
" VimCompletesMe
" --------------
"
" A super simple, super minimal, super light-weight tab-completion plugin for
" Vim.
"
" NOTE: original repository missing
" TODO: review
"
" https://github.com/ajh17/VimCompletesMe
"
" YouCompleteMe
" -------------
"
" A code-completion engine for Vim
"
" https://valloric.github.io/YouCompleteMe/
" https://github.com/Valloric/YouCompleteMe
"
" See Also
" --------
"
" https://github.com/Shougo/neocomplete.vim
" https://github.com/lifepillar/vim-mucomplete
" ============================================================================
function! SetupTabCompletionPlugins()
" Init: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Native Vim init:
if has("gui_macvim") && has("gui_running")
let use_conquer_of_completon = 0
if use_conquer_of_completon
" ===========================
" Conquer of Completion (CoC)
" ===========================
let coc_init = '
\ _coc_path="${HOME}/.vim/pack/plugins/opt/coc.nvim" &&
\ [ -e "${_coc_path}/package.json" ] &&
\ [ ! -e "${_coc_path}/package-lock.json" ] &&
\ [ ! -e "${_coc_path}/yarn.lock" ] &&
\ (cd "${_coc_path}" && yarn install)'
call system(coc_init)
let g:coc_global_extensions = [
\ 'coc-css',
\ 'coc-html',
\ 'coc-json',
\ 'coc-pairs',
\ 'coc-highlight',
\ 'coc-rust-analyzer',
\ 'coc-solargraph',
\ 'coc-tsserver'
\ ]
packadd coc.nvim
else
" =============
" YouCompleteMe
" =============
let you_complete_me_init = '
\ _ycm_path="${HOME}/.vim/pack/plugins/opt/YouCompleteMe" &&
\ [ -e "${_ycm_path}" ] &&
\ [ ! -e "${_ycm_path}/third_party/ycmd/build.py" ] &&
\ (cd "${_ycm_path}" && git submodule update --init --recursive)'
call system(you_complete_me_init)
" NOTE: To install YouCompleteMe, run the following command. This must be
" done during at least some upgrades of YouCompleteMe.
"
" More Information:
" https://valloric.github.io/YouCompleteMe/#mac-os-x
let you_complete_me_install = '
\ _ycm_path="${HOME}/.vim/pack/plugins/opt/YouCompleteMe" &&
\ [ -e "${_ycm_path}/third_party/ycmd/build.py" ] &&
\ [ ! -e "${_ycm_path}/third_party/ycmd/ycm_core.so" ] &&
\ (
\ cd "${_ycm_path}" &&
\ ./install.py \
\ --clangd-completer \
\ --go-completer \
\ --rust-completer \
\ --ts-completer \
\ --java-completer
\ )'
call system(you_complete_me_install)
packadd YouCompleteMe
endif
else
packadd supertab
" packadd VimCompletesMe
endif
" VimCompletesMe
" --------------
" packadd VimCompletesMe
" deoplete.nvim
" --------------
" let g:deoplete#enable_at_startup = 1
" packadd deoplete.nvim
" After: •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Turn off YCM auto hover documentation popup.
"
" https://www.reddit.com/r/vim/comments/gibavq
" https://www.reddit.com/r/vim/comments/g9v832
" https://vimawesome.com/plugin/youcompleteme#the-gycm_auto_hover-option
let g:ycm_auto_hover = ''
endfunction
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
" ============================================================================
" ack.vim
"
" Vim plugin for the Perl module / CLI script 'ack', along with The Silver
" Searcher, `ag`, and RipGrep, `rg`.
"
" https://github.com/mileszs/ack.vim
" ============================================================================
function! SetupPluginAck()
" Init: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Plug init:
" Plug 'https://github.com/mileszs/ack.vim'
" Native Vim init:
packadd ack.vim
" After: •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Use `Ack!` to avoid opening first result (see ack.vim README).
cnoreabbrev Ack Ack!
if has("gui_macvim") && has("gui_running")
" Command-Shift-F on OSX
map <D-F> :Ack<space>
else
" Define <C-F> to a dummy value to see if it would set <C-f> as well.
map <C-F> :dummy
if maparg("<C-f>") == ":dummy"
" <leader>f on systems where <C-f> == <C-F>
map <leader>f :Ack<space>
else
" <C-F> if we can still map <C-f> to <S-Down>
map <C-F> :Ack<space>
endif
map <C-f> <S-Down>
endif
" Use ripgrep `rg` if available.
" http://www.wezm.net/technical/2016/09/ripgrep-with-vim/
if executable('rg')
let g:ackprg = 'rg --vimgrep --no-heading --hidden --glob "!.git/*"'
" Use The Silver Searcher `ag` if available.
" https://github.com/mileszs/ack.vim#can-i-use-ag-the-silver-searcher-with-this
elseif executable('ag')
let g:ackprg = 'ag --vimgrep --hidden'
endif
endfunction
" ============================================================================
" ALE (Asynchronous Lint Engine)
"
" Asynchronous linting/fixing for Vim and Language Server Protocol (LSP)
" integration.
"
" ALE (Asynchronous Lint Engine) is a plugin for providing linting in NeoVim
" 0.2.0+ and Vim 8 while you edit your text files, and acts as a Vim Language
" Server Protocol client.
"
" https://github.com/w0rp/ale
" ============================================================================
function! SetupPluginAle()
" Before: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Only lint on save. More info:
" https://github.com/dense-analysis/ale/issues/38#issuecomment-251504769
let g:ale_lint_on_text_changed = 0
let g:ale_lint_on_enter = 0
let g:ale_lint_on_save = 1
" Turn off virtual text.
" https://github.com/dense-analysis/ale/blob/master/doc/ale.txt#L2291
let g:ale_virtualtext_cursor = 0
" Init: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Native Vim init:
packadd ale
" After: •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
let g:airline#extensions#ale#enabled = 1
" Do not lint or fix minified files.
let g:ale_pattern_options = {
\ '\.min\.js$': {'ale_linters': [], 'ale_fixers': []},
\ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []},
\}
" Use more subtle symbols.
"
" NOTE: Color overrides can be found in the 'colorschemes' section of
" after/plugin/dotvim.vim
let g:ale_sign_warning = '›'
let g:ale_sign_error = '›'
" Only use highlights in MacVim.
if ! has("gui_macvim")
let g:ale_set_highlights = 0
endif
" Configure Linters
"
" golang: revive
"
" https://revive.run/docs
" https://github.com/mgechev/revive
"
" More information:
" https://github.com/golang/go/issues/38968
" https://github.com/golang/lint/issues/263
" https://github.com/golangci/golangci-lint/issues/238
"
" javascript: ESLint
"
" https://eslint.org/
" https://github.com/eslint/eslint/
let g:ale_linters = {
\ 'go': ['revive'],
\ 'javascript': ['eslint']
\}
" Display additional linter information.
"
" https://github.com/w0rp/ale/blob/master/doc/ale.txt#L1085
let g:ale_echo_msg_format = '[%linter%] %s (%severity%)%(code)%'
endfunction
" ============================================================================
" AsyncRun
"
" Run Async Shell Commands in Vim 8.0 / NeoVim and Output to Quickfix Window
"
" https://github.com/skywind3000/asyncrun.vim
" ============================================================================
function! SetupPluginAsyncRun()
" Init: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Native Vim init:
packadd asyncrun.vim
endfunction
" ============================================================================
" aliou/bats.vim
"
" Syntax files for Bats (Bash Automated Testing System).
"
" https://github.com/aliou/bats.vim
" ============================================================================
function! SetupPluginBatsVim()
" Init: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Native Vim init:
packadd bats.vim
endfunction
" ============================================================================
" Black
"
" The uncompromising Python code formatter
"
" https://github.com/psf/black
" https://black.readthedocs.io/en/stable/
" https://black.readthedocs.io/en/stable/editor_integration.html
" ============================================================================
function! SetupPluginBlack()
" Init: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Native Vim init:
packadd black
endfunction
" ============================================================================
" buffergator
"
" Vim plugin to list, select and switch between buffers.
"
" https://github.com/jeetsukumaran/vim-buffergator
" ============================================================================
function! SetupPluginBuffergator()
" Init: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Native Vim init:
packadd vim-buffergator
endfunction
" ============================================================================
" csv
"
" A Filetype plugin for csv files
"
" https://github.com/chrisbra/csv.vim
" ============================================================================
function! SetupPluginCsvVim()
" Init: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Native Vim init:
packadd csv.vim
endfunction
" ============================================================================
" ctrlp.vim
"
" Fuzzy file, buffer, mru, tag, etc finder.
"
" NOTE: Active fork is https://github.com/ctrlpvim/ctrlp.vim
" ============================================================================
function! SetupPluginCtrlp()
" Init: ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
" Plug init:
" Plug 'https://github.com/ctrlpvim/ctrlp.vim'
" Native Vim init:
packadd ctrlp
" After: •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
let g:ctrlp_map = ''
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$|bower_components|node_modules',
\ 'file': '\.pyc$\|\.pyo$\|\.rbc$|\.rbo$\|\.class$\|\.o$\|\~$\',
\ }
if has("gui_macvim") && has("gui_running")
map <D-t> :CtrlP<CR>
imap <D-t> <ESC>:CtrlP<CR>
endif
" Use abbreviation for CtrlP/Command-T cache refresh
:ca rc ClearCtrlPCache
" Include hidden files
let g:ctrlp_show_hidden = 1
" Include the current file in the file list.
let g:ctrlp_match_current_file = 1
" Don't switch to the existing window when the file is already open.
let g:ctrlp_switch_buffer = 0
" Default searching order.
"
" Ctrl+D:
" Toggle between full-path search and filename only search.
" Note: in filename mode, the prompt's base is >d> instead of >>>
"
" Ctrl+R:
" Toggle between the string mode and full regexp mode.
" Note: in full regexp mode, the prompt's base is r>> instead of >>>
"
" https://unix.stackexchange.com/a/144571
" let g:ctrlp_by_filename = 1
" let g:ctrlp_regexp = 1
" Use `rg` or `ag` if available. More information:
" https://elliotekj.com/2016/11/22/setup-ctrlp-to-use-ripgrep-in-vim/
if executable('rg')
set grepprg=rg\ --color=never\ --hidden
let g:ctrlp_user_command =
\ 'rg %s --files --color=never --hidden --glob "!.git/*"'
let g:ctrlp_use_caching = 1
elseif executable('ag')
set grepprg=ag\ --nogroup\ --nocolor\ --hidden
let g:ctrlp_user_command =
\ 'ag %s -l --nocolor --hidden -g ""'
let g:ctrlp_use_caching = 1
endif
" Ignore local glyph directory in project since it slows down cache building.
"
" TODO: remove when this directory no longer exists locally.
set wildignore+=*system/development/glyphs*
" CtrlPCacheRefresh
"
" Rebuild the CtrlP cache after a delay when the window is unfocused.
" CtrlP briefly pops open during indexing. The status bar colors are set
" to the Normal highlight group background colors in order to minimize
" flashing when this happens.
"
" Configure delay:
"
" let g:ctrlp_cache_refresh_timer = 10000
"
" TODO: Find or implement a way to refresh the cache without opening CtrlP.
" The CtrlP ctrlp#files() function is where the indexing appears to occur:
"
" https://github.com/ctrlpvim/ctrlp.vim/blob/master/autoload/ctrlp.vim#L381
"
" ctrlp#files() appears to rely on initialization that happens during
" s:Open():
"
" https://github.com/ctrlpvim/ctrlp.vim/blob/master/autoload/ctrlp.vim#L309
"
" Resources:
" https://github.com/kien/ctrlp.vim/issues/305#issuecomment-9802791
" https://vimhelp.org/eval.txt.html#timer_start%28%29
" NOTE: Only automatically refresh CtrlP in MacVim.
" TODO: Fix errors when running refresh command in non-GUI vim.
if ! has("gui_macvim") || ! has("gui_running")
return
endif
let g:ctrlp_cache_refresh_is_focused = 1
if ! exists('g:ctrlp_cache_refresh_timer')
let g:ctrlp_cache_refresh_timer = 30000
endif
function! CtrlPCacheRefreshFocus(...)
let g:ctrlp_cache_refresh_is_focused = 1
call timer_stopall()
endfunction
function! CtrlPCacheRefreshUnfocus(...)
let g:ctrlp_cache_refresh_is_focused = 0
call timer_stopall()
call timer_start(g:ctrlp_cache_refresh_timer, function('CtrlPCacheRefreshOnBlur'))
endfunction
function! CtrlPCacheRefreshGetHighlightGroup(group)
return matchstr(execute('hi ' . a:group), '\vxxx\zs(.*)')
endfunction
function! CtrlPCacheRefreshGetHighlightTerm(group, term)
return matchstr(execute('hi ' . a:group), a:term.'=\zs\S*')
endfunction
function! CtrlPCacheRefreshOnBlur(...)
if ! g:ctrlp_cache_refresh_is_focused
let CtrlPlight_original = CtrlPCacheRefreshGetHighlightGroup('CtrlPlight')
let CtrlPdark_original = CtrlPCacheRefreshGetHighlightGroup('CtrlPdark')
let CtrlParrow1_original = CtrlPCacheRefreshGetHighlightGroup('CtrlParrow1')
let CtrlParrow2_original = CtrlPCacheRefreshGetHighlightGroup('CtrlParrow2')
let CtrlParrow3_original = CtrlPCacheRefreshGetHighlightGroup('CtrlParrow3')
let normal_ctermbg = CtrlPCacheRefreshGetHighlightTerm('Normal', 'ctermbg')
let normal_guibg = CtrlPCacheRefreshGetHighlightTerm('Normal', 'guibg')
if empty(normal_ctermbg) | let normal_ctermbg = 0 | endif
execute printf(
\ 'highlight CtrlPlight ctermfg=%s ctermbg=%s guifg=%s guibg=%s',
\ normal_ctermbg, normal_ctermbg, normal_guibg, normal_guibg
\ )
execute printf(
\ 'highlight CtrlPdark ctermfg=%s ctermbg=%s guifg=%s guibg=%s',
\ normal_ctermbg, normal_ctermbg, normal_guibg, normal_guibg
\ )
execute printf(
\ 'highlight CtrlParrow1 ctermfg=%s ctermbg=%s guifg=%s guibg=%s',
\ normal_ctermbg, normal_ctermbg, normal_guibg, normal_guibg
\ )
execute printf(
\ 'highlight CtrlParrow2 ctermfg=%s ctermbg=%s guifg=%s guibg=%s',
\ normal_ctermbg, normal_ctermbg, normal_guibg, normal_guibg
\ )
execute printf(
\ 'highlight CtrlParrow3 ctermfg=%s ctermbg=%s guifg=%s guibg=%s',
\ normal_ctermbg, normal_ctermbg, normal_guibg, normal_guibg
\ )
let g:ctrlp_match_window = 'max:0,results:1'
CtrlPClearCache
CtrlP
exec "normal \<ESC>"
let g:ctrlp_match_window = 'max:10,results:10'
execute printf('highlight CtrlPlight %s', CtrlPlight_original)
execute printf('highlight CtrlPdark %s', CtrlPdark_original)
execute printf('highlight CtrlParrow1 %s', CtrlParrow1_original)
execute printf('highlight CtrlParrow2 %s', CtrlParrow2_original)
execute printf('highlight CtrlParrow3 %s', CtrlParrow3_original)
endif
endfunction
function! CtrlPCacheRefreshAutocommands()
if exists("g:loaded_ctrlp") && g:loaded_ctrlp
augroup CtrlPExtension
autocmd!
autocmd FocusGained * call CtrlPCacheRefreshFocus()
autocmd FocusLost * call CtrlPCacheRefreshUnfocus()
augroup END
endif
endfunction
if has("autocmd")