-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.vimrc
More file actions
1036 lines (874 loc) · 29.6 KB
/
.vimrc
File metadata and controls
1036 lines (874 loc) · 29.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
set encoding=utf-8
scriptencoding utf-8
" Brian Ustas's .vimrc
"
" Tested with Neovim on OS X.
"
" Expected Installs:
" - Git
" - Ruby and RSpec
" - tmux (http://tmux.sourceforge.net)
" - rg (https://github.com/BurntSushi/ripgrep)
" - ctags (https://github.com/universal-ctags/ctags)
" - fzf (https://github.com/junegunn/fzf)
" === vim-plug === {{{
call plug#begin('~/.vim/plugged')
Plug 'itchyny/lightline.vim'
" editing
Plug 'tpope/vim-commentary', { 'on': 'Commentary' }
Plug 'tpope/vim-surround'
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
Plug 'dense-analysis/ale'
" completion
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
Plug 'sirver/UltiSnips'
" colors
Plug 'ustasb/gruvbox'
" git
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " GitHub support
" prose
Plug 'plasticboy/vim-markdown'
Plug 'reedes/vim-litecorrect', { 'for': ['text', 'markdown', 'pandoc'] }
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' }
" search
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" Don't use vim-plug's lazy loading here! :Ack on text below the cursor
" won't work the first time.
Plug 'mileszs/ack.vim'
" tmux
Plug 'benmills/vimux'
Plug 'christoomey/vim-tmux-navigator'
" web
Plug 'othree/html5-syntax.vim', { 'for': 'html' }
Plug 'JulesWang/css.vim', { 'for': 'css' }
Plug 'kchmck/vim-coffee-script', { 'for': 'coffee' }
Plug 'yuezk/vim-js', { 'for': ['javascript', 'javascriptreact'] }
Plug 'MaxMEllon/vim-jsx-pretty', { 'for': ['javascriptreact', 'typescriptreact'] }
Plug 'leafgarland/typescript-vim', { 'for': ['typescript', 'typescriptreact'] }
Plug 'peitalin/vim-jsx-typescript', { 'for': ['typescript', 'typescriptreact'] }
Plug 'chr4/nginx.vim', { 'for' : 'nginx' }
" elixir
Plug 'elixir-editors/vim-elixir', { 'for': 'elixir' }
" ruby
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }
Plug 'thoughtbot/vim-rspec', { 'for': 'ruby' }
" python
Plug 'vim-python/python-syntax', { 'for': 'python' }
Plug 'tmhedberg/SimpylFold', { 'for': 'python' }
" misc
Plug 'szw/vim-maximizer', { 'on': 'MaximizerToggle' }
Plug 'majutsushi/tagbar', { 'on': 'TagbarToggle' }
Plug 'lvht/tagbar-markdown', { 'for': 'markdown' }
Plug 'preservim/nerdtree', { 'on': ['NERDTree', 'NERDTreeToggle', 'NERDTreeFind'] }
Plug 'jamessan/vim-gnupg'
Plug 'tpope/vim-repeat'
Plug 'mhinz/vim-startify'
call plug#end()
" }}}
" === Basic === {{{
let g:bu_spell_file = expand('$USTASB_CLOUD_DIR_PATH/ustasb_not_encrypted/settings/vim/vim-spell-en.utf-8.add')
filetype plugin indent on
syntax enable
" file format (relevant to line ending type)
" Unix based systems and Mac OS X+.
set fileformats=unix,dos
" English spelling
set spelllang=en
" Custom spellfile for `zg` and `zw`.
execute('set spellfile="' . g:bu_spell_file . '"')
" Default spellfile is located at: ~/.vim/spell/en.utf-8.spl
" Enable mouse support for all modes.
set mouse=a
" Make backspace work like most other apps.
set backspace=indent,eol,start
" Merge Vim and OS clipboard.
" https://stackoverflow.com/a/30691754/1575238
set clipboard=unnamed,unnamedplus
" Keep 100 lines of command-line history.
set history=100
" Keep 100 lines of undo history.
set undolevels=100
" Set the tag file search order: current directory then root (used by Ctags).
set tags=./tags;/
" Allow unsaved background buffers.
set hidden
" I don't use modelines and it's apparently a potential security hazard.
set modelines=0
" Prevent Shift-O delay in terminal.
set ttimeoutlen=100
if has('nvim')
" Required to save files on mounted volumes.
set nofsync
else
" Vim's default (zip) is poor. Prefer AES256 via GnuPG.
set cryptmethod=blowfish2
endif
" }}}
" === Backups === {{{
" I never use these.
set noswapfile
if isdirectory($HOME . '/.vim/.backup') == 0
:silent !mkdir -m 700 -p ~/.vim/.backup > /dev/null 2>&1
endif
set backup
set backupdir=~/.vim/.backup
set backupcopy=auto
" Make a backup before overwriting the current buffer.
set writebackup
" Don't back up OS X's tmp/.
set backupskip+=/private/tmp/*
augroup AG_VimBackup
autocmd!
" Ensure unique backup names.
" solves: https://stackoverflow.com/a/26779916/1575238
autocmd BufWritePre * let &backupext = '~' . substitute(expand('%:p:h'), '/', '%', 'g')
augroup END
" }}}
" === Colors === {{{
" truecolor
set t_Co=256
set termguicolors
if $ITERM_PROFILE ==# 'GruvboxLight' || has('gui_running')
set background=light
else
set background=dark
endif
let g:gruvbox_bold = 1
let g:gruvbox_italic = 1
let g:gruvbox_invert_tabline = 0
let g:gruvbox_invert_selection = 0
let g:gruvbox_sign_column = 'bg1'
let g:gruvbox_color_column = 'bg1'
let g:gruvbox_number_column = 'bg1'
let g:gruvbox_guisp_fallback = 'fg' " Make misspellings clearer.
let g:gruvbox_contrast_dark = 'medium'
let g:gruvbox_contrast_light = 'hard'
let g:bu_ignore_capitalization = 1
silent! colorscheme gruvbox
" }}}
" === UI === {{{
" Change the title of the terminal/tab with the file name.
set title
set titlestring=%t
" Disable text concealing.
set conceallevel=0
" The default is 4000 which is rather slow. coc.nvim recommends 300.
set updatetime=300
" Don't show Vim's welcome message.
set shortmess=I
" Make the save message shorter. Helps avoid the 'Hit ENTER to continue' message.
set shortmess+=at
" Don't show completion messages. coc.nvim recommends this.
set shortmess+=c
" Always show the status line.
set laststatus=2
" better splits
set splitbelow
set splitright
" vertical split character
set fillchars+=vert:│
" Don't show pressed keys in the statusline.
set noshowcmd
" text folding
set foldenable
" Open all folds by default.
set foldlevel=20
set foldmethod=marker
set foldmarker={{{,}}}
" Only allow two levels of nesting.
set foldnestmax=2
" toggle folds
nnoremap <silent> <Space> @=(foldlevel('.') ? 'za' : "\<Space>")<CR>
nnoremap <silent> <C-Space> :call ToggleAllFolds()<CR>
" GUI
if has('gui_running')
set antialias
set linespace=1 " line height
set guifont=iA\ Writer\ Mono\ S:h15
" remove toolbar, menubar and scrollbar
set guioptions=
" disable cursor blinking
set guicursor+=a:blinkon0
" disable all error whistles
set noerrorbells visualbell t_vb=
" MacVim padding tweaks:
" defaults write org.vim.MacVim MMTextInsetTop '5'
" defaults write org.vim.MacVim MMTextInsetLeft '5'
" defaults write org.vim.MacVim MMTextInsetBottom '5'
" defaults write org.vim.MacVim MMTextInsetRight '5'
else
" Performance tweaks for terminal Vim...
" Don't match parentheses or brackets.
" let loaded_matchparen=1
" set noshowmatch
" not needed / expensive to render
set nocursorline
set nocursorcolumn
set norelativenumber
" Scroll 10 lines at bottom/ top.
" set scrolljump=10
endif
" Resize splits when Vim is resized.
augroup AG_VimResize
autocmd!
autocmd VimResized * execute("normal \<C-w>=")
" NOTE: Why not just `autocmd VimResized * wincmd =`?
" It doesn't resize the Vim buffer when GoyoEnter+Tmux is enabled.
augroup END
" }}}
" === Search === {{{
" Turn off highlight matching.
set nohlsearch
" incremental searching
set incsearch
" Searches are case insensitive...
set ignorecase
" ...unless they contain at least one capital letter.
set smartcase
" }}}
" === Whitespace === {{{
" enable auto-indenting
set autoindent
" Don't wrap lines.
set nowrap
" Insert spaces instead of tabs when <Tab> is pressed.
set expandtab
" Set the indentation width for < and >.
set shiftwidth=2
" Make 2 spaces behave like a tab.
set tabstop=2
set softtabstop=2
" }}}
" === Key Mappings === {{{
" Change the leader key from \ to ,
let mapleader=','
let maplocalleader = "\\"
" Use jk instead of <Esc> to enter Normal mode.
inoremap jk <Esc>
inoremap JK <Esc>
" typos
cnoreabbrev aw wa
" Disable `man` documentation for a word.
nnoremap <S-k> <Nop>
vnoremap <S-k> <Nop>
" Disable command and search history. Replaced with fzf.
nnoremap Q <Nop>
" Reselect visual block after indent/outdent.
vnoremap < <gv
vnoremap > >gv
" Swap two words.
nnoremap <silent> gw :s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR>`'
" Quickly reload .vimrc.
nnoremap <Leader>R :source $MYVIMRC<CR>:echo "~/.vimrc reloaded"<CR>
" beginning of line / end of line
inoremap <C-a> <Esc>I
inoremap <C-e> <Esc>A
" Allows pasting over content without changing the copy buffer.
" http://vim.wikia.com/wiki/Replace_a_word_with_yanked_text
xnoremap p "_dP
if has('nvim')
" Exit the Neovim terminal via jk.
tnoremap jk <C-\><C-n>
endif
" }}}
" === Wild Mode (command-line completion) === {{{
set wildmenu
set wildmode=list:longest,list:full
set wildignore+=*.csv,*.tsv,*.json,*.h4,*.h5,*.db
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.rbo,*.class,.svn,*.gem
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
" }}}
" === File Types === {{{
augroup AG_FileTypeOptions
autocmd!
" Python
autocmd FileType python setlocal
\ softtabstop=4
\ tabstop=4
\ shiftwidth=4
augroup END
" }}}
" === Misc Functions === {{{
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler.
" (happens when dropping a file on gvim).
function! ResetCursorPosition()
if line("'\"") > 0 && line("'\"") <= line('$')
exe "normal g`\""
endif
endfunction
" Remove whitespace at the end of lines while maintaining cursor position.
function! StripTrailingWhitespaces()
let l = line('.')
let c = col('.')
%s/\s\+$//e
call cursor(l, c)
endfunction
" Open a file in Google Chrome.
command! Chrome !open -a "Google Chrome" %:p
" Open the file's folder in Finder.
command! Finder !open -a "Finder" %:p:h
" Create a tags file.
function! CreateCtagsFile()
let cwd = getcwd()
silent execute('silent !ctags ' . cwd)
echom 'Created tags file at: ' . cwd . '/tags'
endfunction
command! Ctags call CreateCtagsFile()
" Allow saving with sudo permission.
function! SudoSaveFile()
execute 'silent :w !sudo tee > /dev/null %'
endfunction
command! SudoSave call SudoSaveFile()
function! RefreshAllBuffers()
" Temporarily disable syntax highlighting to speed things up.
syntax off
let currBuff = bufnr('%')
" refresh buffers
execute 'silent! bufdo e!'
" Go back to the original buffer.
execute 'buffer ' . currBuff
" bufdo e! turns syntax highlighting off for efficiency.
syntax enable
endfunction
command! BufRefresh call RefreshAllBuffers()
" Execute the current file with the correct interpreter.
function! ExecuteFile()
let interpreter = &filetype ==# 'ruby' ? 'ruby' :
\ &filetype ==# 'python' ? 'python' :
\ &filetype ==# 'javascript' ? 'node' :
\ &filetype ==# 'javascriptreact' ? 'node' :
\ &filetype ==# 'sh' ? 'bash' : ''
if interpreter ==# ''
echom "No interpreter found for filetype '" . &filetype . "'!"
else
execute '!' . interpreter . ' "%"'
endif
endfunction
nnoremap <Leader>e :call ExecuteFile()<CR>
" credit: https://github.com/arithran/vim-delete-hidden-buffers
function! CloseHiddenBuffers()
let tpbl=[]
call map(range(1, tabpagenr('$')), 'extend(tpbl, tabpagebuflist(v:val))')
for buf in filter(range(1, bufnr('$')), 'bufexists(v:val) && index(tpbl, v:val)==-1')
silent execute 'bwipeout!' buf
endfor
endfunction
command! CloseHiddenBuffers call CloseHiddenBuffers()
" Open / close all folds.
function! ToggleAllFolds()
if get(g:, 'folds_open', 1) == 1
let g:folds_open = 0
normal! zM
else
let g:folds_open = 1
normal! zR
endif
" center the cursor
normal! zz
endfunction
" Open the cursor's word in Dash using Search Profiles.
" https://kapeli.com/dash_guide#searchProfiles
function! OpenInDash()
let g:ft_dash_profile_map = get(g:, 'ft_dash_profile_map', {
\ 'vim' : 'vim',
\ 'python' : 'py',
\ 'ruby' : 'rb',
\ 'javascript' : 'js',
\ 'javascriptreact' : 'js',
\ })
let dash_profile = get(g:ft_dash_profile_map, &filetype, 'default')
let dash_uri = 'dash://' . dash_profile . ':' . expand('<cword>')
silent execute('!open ' . dash_uri)
endfunction
nnoremap <Leader>d :call OpenInDash()<CR>
" Use linters to 'fix' files when possible.
function! AutoFix()
if &filetype ==# 'javascriptreact'
" For JS files, coc-eslint's executeAutofix is faster than ALE's.
:CocCommand eslint.executeAutofix
else
:ALEFix
endif
endfunction
command! Fix call AutoFix()
function! PrintSyntaxGroupAtCursor()
echo synIDattr(synID(line('.'), col('.'), 1), 'name')
endfunction
command! PrintSyntaxGroupAtCursor call PrintSyntaxGroupAtCursor()
function! HighlightGroupsTest()
so $VIMRUNTIME/syntax/hitest.vim
endfunction
command! HighlightGroupsTest call HighlightGroupsTest()
command! EditSpellFile execute('e ' . g:bu_spell_file)
" .vimrc
command! Vimrc e ~/dotfiles/home/.vimrc
command! V Vimrc
command! VL e ~/.vimrc.local
" .zshrc
command! Zshrc e ~/dotfiles/home/.zshrc
command! Z Zshrc
command! ZL e ~/.zshrc.local
" quickly quit
command! Q qa
nnoremap Q qa<CR>
augroup AG_Misc
autocmd!
autocmd BufReadPost * call ResetCursorPosition()
autocmd FileType * autocmd BufWritePre <buffer> call StripTrailingWhitespaces()
" Don't auto-comment the next line on Enter.
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
augroup END
" }}}
" === Plugin Settings === {{{
" vim-ruby {{{
let g:ruby_spellcheck_strings = 0
let g:ruby_indent_block_style = 'do'
" Uncomment the below line if Ruby files become sluggish. Folding won't work.
let g:ruby_no_expensive = 1
let g:ruby_fold = 1
let g:ruby_foldable_groups = 'def'
" }}}
" RSpec.vim {{{
augroup AG_Rspec
autocmd!
autocmd FileType ruby nnoremap <buffer> <Leader>s :call RunNearestSpec()<CR>
autocmd FileType ruby nnoremap <buffer> <Leader>S :call RunCurrentSpecFile()<CR>
augroup END
" }}}
" Vimux {{{
let g:rspec_command = 'call VimuxRunCommand("bundle exec rspec {spec}")'
" }}}
" NERD Tree {{{
let g:NERDTreeIgnore = ['\.git$', '.DS_Store', 'Icon', '__pycache__', '\.o$']
let g:NERDTreeMinimalUI = 1
let g:NERDTreeShowHidden = 1
let g:NERDTreeAutoDeleteBuffer = 1
let g:NERDTreeWinSize = 30
let g:NERDTreeStatusline = -1
let g:NERDTreeMapActivateNode = '<Space>'
let g:NERDTreeMinimalMenu = 1 " fixes https://github.com/preservim/nerdtree/issues/1321
nnoremap <C-n> :NERDTreeToggle<CR>
nnoremap <Leader>g :NERDTreeFind<CR>
" }}}
" Vim Fugitive {{{
" Slows down my C-r command mode mapping.
let g:fugitive_no_maps = 1
" }}}
" Vim Maximizer {{{
nnoremap <C-W>o :MaximizerToggle<CR>
" }}}
" Ack.vim {{{
let $RIPGREP_VIM_ARGS = ' --hidden --smart-case --ignore-file $HOME/.rgignore-vim --max-count 3'
let g:ackprg = 'rg --vimgrep ' . $RIPGREP_VIM_ARGS
let g:ack_lhandler = 'topleft lopen'
let g:ack_qhandler = 'topleft copen'
cnoreabbrev Ag Ack!
cnoreabbrev AG Ack!
cnoreabbrev ag Ack!
" }}}
" Goyo.vim {{{
nnoremap <Leader>z :Goyo<CR>
let g:goyo_width = 80
let g:goyo_height = '90%'
function! s:GoyoEnter()
if executable('tmux') && strlen($TMUX)
" NOTE: I don't disable the tmux status line because I like having it around.
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
endif
endfunction
function! s:GoyoLeave()
if executable('tmux') && strlen($TMUX)
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
endif
endfunction
augroup AG_Goyo
autocmd!
autocmd User GoyoEnter nested call <SID>GoyoEnter()
autocmd User GoyoLeave nested call <SID>GoyoLeave()
augroup END
" }}}
" Vim-Commentary {{{
vnoremap <Leader>c :Commentary<CR>
nnoremap <Leader>c :Commentary<CR>
" }}}
" Tagbar {{{
let g:tagbar_width = 30
let g:tagbar_silent = 1
let g:tagbar_compact = 1
let g:tagbar_autofocus = 1
let g:tagbar_autoclose = 1
let g:tagbar_iconchars = ['▸', '▾']
let g:tagbar_sort = 0 " Don't sort alphabetically.
let g:tagbar_map_togglefold = '<Space>'
nnoremap <Leader>o :TagbarToggle<CR>
let g:tagbar_status_func = 'TagbarStatusFunc'
function! TagbarStatusFunc(current, sort, fname, ...) abort
let g:lightline.fname = a:fname
return lightline#statusline(0)
endfunction
" }}}
" Vim GnuPG {{{
let g:GPGExecutable = 'gpg --trust-model always'
let g:GPGPreferArmor = 0
let g:GPGUseAgent = 1
" Only signs upon creation, not after editing.
" Turning it off - too inconsistent. Even after forking and fixing, it's too slow.
let g:GPGPreferSign = 0
let g:GPGUsePipes = 1
let g:GPGFilePattern = '*.\(gpg\|asc\)'
let g:GPGDefaultRecipients = ['Brian Ustas <brianustas@gmail.com>']
" }}}
" vim-startify {{{
let g:startify_padding_left = 2
let g:startify_update_oldfiles = 1
let g:startify_fortune_use_unicode = 1
let g:startify_custom_header = 'startify#pad(startify#fortune#boxed())'
let g:startify_change_to_dir = 0
let g:startify_files_number = 10
let g:startify_enable_special = 0
let g:startify_skiplist = [
\ 'spec/fixtures/.*.yml',
\ ]
function! s:StartifyMruNotes()
let l:mru_notes = MruNotes(g:startify_files_number)
return map(l:mru_notes, { i, path -> { 'line': fnamemodify(path, ':t'), 'path': path } })
endfunction
let g:startify_lists = [
\ { 'type': 'files', 'header': [' MRU'] },
\ { 'type': function('s:StartifyMruNotes'), 'header': [' MRU Notes'] },
\ { 'type': 'dir', 'header': [' MRU ' . getcwd()] },
\ ]
augroup AG_Startify
autocmd!
" Highlight the cursor's line.
autocmd User Startified setlocal cursorline
augroup END
command! Welcome Startify
command! W Welcome
" }}}
" fzf.vim {{{
let $FZF_DEFAULT_COMMAND = $FZF_DEFAULT_COMMAND . $RIPGREP_VIM_ARGS
let g:fzf_command_prefix = 'Fzf'
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.7 } }
let g:fzf_preview_window = 'down:50%'
let g:fzf_colors = {
\ 'prompt': ['fg', 'GruvboxAquaBold'],
\ 'spinner': ['fg', 'Comment'],
\ 'info': ['fg', 'Comment'],
\ 'pointer': ['fg', 'Statement'],
\ 'fg': ['fg', 'Normal'],
\ 'fg+': ['fg', 'Normal'],
\ 'bg+': ['bg', 'CursorLine'],
\ 'hl+': ['fg', 'Statement'],
\ 'hl': ['fg', 'Statement']
\ }
" https://github.com/junegunn/fzf.vim#status-line-neovim
" empty status line
augroup AG_MyFZF
autocmd!
autocmd User FzfStatusLine setlocal statusline=%#CursorLine#
augroup END
" pwd files
nnoremap <silent> <Leader>f :FzfFiles<CR>
" MRU
nnoremap <silent> <Leader>F :FzfHistory<CR>
" ripgrep
nnoremap <silent> <Leader>r :FzfRg<CR>
" Vim help
nnoremap <silent> <Leader>h :FzfHelptags<CR>
" buffers
nnoremap <silent> <Leader>b :FzfBuffers<CR>
" ctags
nnoremap <silent> <Leader>t :FzfTags<CR>
" search history
nnoremap <silent> q/ :FzfHistory/<CR>
" command history
nnoremap <silent> q: :FzfHistory:<CR>
" }}}
" ALE (Used for the :Fix command and linting what coc.nvim can't.) {{{
let g:ale_enabled = 1
let g:ale_history_enabled = 0
let g:ale_history_log_output = 0
let g:ale_completion_enabled = 0
let g:ale_sign_error = 'E'
let g:ale_sign_warning = 'W'
let g:ale_sign_info = 'I'
let g:ale_linters_explicit = 1
let g:ale_linters = {
\ 'css': ['stylelint'],
\ 'scss': ['stylelint'],
\ 'vim': ['vint'],
\ }
let g:ale_fix_on_save = 0
let g:ale_fixers = {
\ 'ruby': ['rubocop'],
\ 'javascript': ['eslint'],
\ 'javascriptreact': ['eslint'],
\ 'css': ['stylelint'],
\ 'scss': ['stylelint'],
\ }
" }}}
" coc.nvim (Conquer of Completion) {{{
" . : current buffer
" w : buffers from other windows
" b : buffers from buffer list
set complete=.,w,b
set completeopt=menu,menuone,noselect
let g:coc_status_error_sign = 'E:'
let g:coc_status_warning_sign = 'W:'
let g:coc_status_info_sign = 'I:'
let g:coc_start_at_startup = 1
let g:coc_enable_locationlist = 1 " needed for <Plug>(coc-references)
let g:coc_global_extensions = [
\ 'coc-git',
\ 'coc-css',
\ 'coc-json',
\ 'coc-yaml',
\ 'coc-html',
\ 'coc-dictionary',
\ 'coc-tag',
\ 'coc-ultisnips',
\ 'coc-python',
\ 'coc-solargraph',
\ 'coc-tsserver',
\ 'coc-eslint',
\ 'coc-tailwindcss',
\ 'coc-pairs',
\ 'coc-highlight',
\ 'coc-vimlsp',
\ 'coc-elixir',
\ ]
" Use <Tab> and <S-Tab> for triggering and navigating the completion list.
function! s:CocTab()
if coc#pum#visible()
return coc#pum#next(1)
elseif <SID>check_back_space()
return "\<TAB>"
elseif get(b:, 'coc_suggest_disable', 0)
if get(b:, 'coc_suggest_disable_use_dict', 0)
" dictionary completion
return "\<C-x>\<C-k>\<C-n>"
else
return "\<TAB>"
endif
else
return coc#refresh()
endif
endfunction
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <TAB> <SID>CocTab()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Jump to definition of current symbol.
nmap <silent> gd <Plug>(coc-definition)
" Jump to references of current symbol.
nmap <silent> gr <Plug>(coc-references)
nmap <silent> gi <Plug>(coc-implementation)
command! -nargs=0 Rename call CocAction('rename')
" Use [c and ]c for navigating diagnostics.
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Show documentation for the current word.
function! s:showDocumentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocActionAsync('doHover')
endif
endfunction
nnoremap <silent> K :call <SID>showDocumentation()<CR>
" }}}
" python-syntax {{{
let g:python_highlight_all = 1
let g:python_highlight_space_errors = 0
let g:python_highlight_indent_errors = 0
" }}}
" vim-markdown {{{
let g:vim_markdown_no_default_key_mappings = 1
let g:vim_markdown_strikethrough = 1
let g:vim_markdown_emphasis_multiline = 1
let g:vim_markdown_autowrite = 0
let g:vim_markdown_edit_url_in = 'current'
let g:vim_markdown_no_extensions_in_markdown = 0
" this is annoying
let g:vim_markdown_new_list_item_indent = 0
" and this
let g:vim_markdown_auto_insert_bullets = 0
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
let g:tex_conceal = '' " disables Latex concealing
let g:vim_markdown_math = 0 " requires me to escape every dollar sign :(
let g:vim_markdown_frontmatter = 1 " jekyll
let g:vim_markdown_toml_frontmatter = 0 " hugo
let g:vim_markdown_json_frontmatter = 0 " hugo
" }}}
" UltiSnips {{{
let g:UltiSnipsExpandTrigger = '<C-Space>'
let g:UltiSnipsJumpForwardTrigger = '<C-j>'
let g:UltiSnipsJumpBackwardTrigger = '<C-k>'
let g:UltiSnipsListSnippets = '<Nop>' " use FzfSnippets
let g:UltiSnipsSnippetDirectories = [$HOME . '/dotfiles/vim/ultisnips']
command! Ulti UltiSnipsEdit
" }}}
" lightline.vim {{{
set noshowmode " Don't show the default mode indicator.
let g:lightline = {
\ 'colorscheme': 'gruvbox',
\ 'enable': {
\ 'tabline': 1,
\ 'statusline': 1,
\ },
\ 'active': {
\ 'left': [
\ ['mode', 'paste'],
\ ['readonly', 'filename', 'modified']
\ ],
\ 'right': [
\ ['lineinfo'],
\ ['percent'],
\ ['cocstatus', 'fileformat', 'fileencoding', 'filetype']
\ ]
\ },
\ 'component_function': {
\ 'mode': 'LightlineMode',
\ 'filename': 'LightlineFilename',
\ 'modified': 'LightlineModified',
\ 'fileformat': 'LightlineFileformat',
\ 'fileencoding': 'LightlineFileencoding',
\ 'filetype': 'LightlineFiletype',
\ 'cocstatus': 'coc#status'
\ },
\ 'subseparator': {
\ 'left': '│',
\ 'right': '│'
\ }
\ }
function! LightlineMode()
let fname = expand('%:t')
return &filetype ==# 'nerdtree' ? '' :
\ &filetype ==# 'tagbar' ? '' :
\ &filetype ==# 'qf' ? '' :
\ &filetype ==# 'fzf' ? '' :
\ winwidth(0) > 60 ? lightline#mode() : ''
endfunction
function! LightlineFilename()
let fname = expand('%:t')
return &filetype ==# 'nerdtree' ? 'NERDTree' :
\ &filetype ==# 'tagbar' ? 'Tagbar' :
\ &filetype ==# 'qf' ? 'QuickFix' :
\ &filetype ==# 'fzf' ? 'fzf' :
\ fname !=# '' ? fname : '[No Name]'
endfunction
function! LightlineModified()
return &modified ? '+' : ''
endfunction
function! LightlineFileformat()
return winwidth(0) > 80 ? &fileformat : ''
endfunction
function! LightlineFileencoding()
return winwidth(0) > 80 ? (strlen(&fileencoding) ? &fileencoding : &encoding) : ''
endfunction
function! LightlineFiletype()
return winwidth(0) > 80 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
" }}}
" }}}
" === Prose === {{{
function! SetProseOptions()
" Fix common typos.
call litecorrect#init()
" NOTE: Enable the below flags when autocompletion is too noisy.
" " Disable COC's autocompletion—it's too noisy while writing.
" let b:coc_suggest_disable = 1
" " Dictionary completion when <Tab> is pressed.
" let b:coc_suggest_disable_use_dict = 1
" For dictionary completion with coc.nvim.
setlocal dictionary=/usr/share/dict/words
setlocal spell softtabstop=4 tabstop=4 shiftwidth=4
" Ignore vim-markdown's indentexpr
setlocal indentexpr=""
" Format list bullets like Vim formats comments.
setlocal comments=fb:*,fb:-,fb:+,n:>
" quote syntax
setlocal commentstring=>\ %s
" docs: Where it makes sense, remove a comment leader when joining lines
setlocal formatoptions=j
" docs: Automatic formatting for text and comments
setlocal formatoptions+=tc
" docs: Allow formatting of comments with "gq"
setlocal formatoptions+=q
" docs: Long lines are not broken in insert mode
setlocal formatoptions+=l
" docs: When formatting text, recognize numbered lists (doesn't work well with 2)
setlocal formatoptions+=n
" docs: Don't break lines at single spaces that follow periods.
setlocal formatoptions+=p
" " disable: Automatically insert the current comment leader
" setlocal formatoptions-=r
" " disable: Automatically insert the current comment leader after hitting
" setlocal formatoptions-=o
" improved gq formatting (credit: https://github.com/jparise/dotfiles/blob/90a2a6baa01b92f11d9673ecd8176f3bc9aaa36e/vim/after/ftplugin/text.vim#L6-L17)
setlocal formatlistpat=^\\s* " Optional leading whitespace
setlocal formatlistpat+=[ " Start class
setlocal formatlistpat+=\\[({]\\? " | Optionally match opening punctuation
setlocal formatlistpat+=\\( " | Start group
setlocal formatlistpat+=[0-9]\\+ " | | A number
setlocal formatlistpat+=\\\|[iIvVxXlLcCdDmM]\\+ " | | Roman numerals
setlocal formatlistpat+=\\\|[a-zA-Z] " | | A single letter
setlocal formatlistpat+=\\) " | End group
setlocal formatlistpat+=[\\]:.)} " | Closing punctuation
setlocal formatlistpat+=] " End class
setlocal formatlistpat+=\\s\\+ " One or more spaces
setlocal formatlistpat+=\\\|^\\s*[-–+o*]\\s\\+ " Or ASCII style bullet points
" visual tweaks
highlight link mkdListItem GruvboxGreenBold
highlight link mkdLink markdownUrl
highlight link mkdInlineUrl markdownUrl
highlight link mkdHeading GruvboxPurpleBold
highlight link htmlH1 GruvboxBlueBold
highlight link htmlH2 GruvboxGreen
highlight link htmlH3 GruvboxGreen
highlight link htmlH4 GruvboxGreen
highlight link htmlH5 GruvboxGreen
highlight link htmlH6 GruvboxGreen
" Dim the body text color.
highlight link mkdNonListItemBlock GruvboxFg2
highlight link mkdListItemLine GruvboxFg2
" Fix the previous misspelling.
nnoremap <buffer> <C-f> [s1z=