forked from dkarter/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
1240 lines (1010 loc) · 38.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
" ▄█ █▄ ▄█ ▄▄▄▄███▄▄▄▄
" ███ ███ ███ ▄██▀▀▀███▀▀▀██▄
" ███ ███ ███▌ ███ ███ ███
" ███ ███ ███▌ ███ ███ ███
" ███ ███ ███▌ ███ ███ ███
" ███ ███ ███ ███ ███ ███
" ███ ███ ███ ███ ███ ███
" ▀██████▀ █▀ ▀█ ███ █▀
" General settings {{{
scriptencoding utf-16 " allow emojis in vimrc
set nocompatible " vim, not vi
syntax on " syntax highlighting
filetype plugin indent on " try to recognize filetypes and load rel' plugins
" }}}
" Behavior Modification ---------------------- {{{
" set leader key
let g:mapleader="\\"
" alias for leader key
nmap <space> \
xmap <space> \
set backspace=2 " Backspace deletes like most programs in insert mode
set history=200 " how many : commands to save in history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set laststatus=2 " Always display the status line
set autowrite " Automatically :write before running commands
set ignorecase " ignore case in searches
set smartcase " use case sensitive if capital letter present or \C
set magic " Use 'magic' patterns (extended regular expressions).
set guioptions= " remove scrollbars on macvim
set noshowmode " don't show mode as airline already does
set showcmd " show any commands
set foldmethod=manual " set folds by syntax of current language
set mouse=a " enable mouse (selection, resizing windows)
set iskeyword+=- " treat dash separated words as a word text object
set tabstop=2 " Softtabs or die! use 2 spaces for tabs.
set shiftwidth=2 " Number of spaces to use for each step of (auto)indent.
set expandtab " insert tab with right amount of spacing
set shiftround " Round indent to multiple of 'shiftwidth'
set termguicolors " enable true colors
set hidden " enable hidden unsaved buffers
if !has('nvim') " does not work on neovim
set emoji " treat emojis 😄 as full width characters
set cryptmethod=blowfish2 " set encryption to use blowfish2 (vim -x file.txt)
end
set ttyfast " should make scrolling faster
set lazyredraw " should make scrolling faster
" visual bell for errors
set visualbell
" wildmenu
set wildmenu " enable wildmenu
set wildmode=list:longest,list:full " configure wildmenu
" text appearance
set textwidth=80
set nowrap " nowrap by default
set list " show invisible characters
set listchars=tab:»·,trail:·,nbsp:· " Display extra whitespace
" Numbers
set number
set numberwidth=1
" set where swap file and undo/backup files are saved
set backupdir=~/.vim/tmp,.
set directory=~/.vim/tmp,.
" persistent undo between file reloads
if has('persistent_undo')
set undofile
set undodir=~/.vim/tmp,.
endif
" Open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
" Set spellfile to location that is guaranteed to exist, can be symlinked to
" Dropbox or kept in Git
set spellfile=$HOME/.vim-spell-en.utf-8.add
" Autocomplete with dictionary words when spell check is on
set complete+=kspell
" Always use vertical diffs
set diffopt+=vertical
" highlight fenced code blocks in markdown
let g:markdown_fenced_languages = [
\ 'html',
\ 'elm',
\ 'vim',
\ 'js=javascript',
\ 'json',
\ 'python',
\ 'ruby',
\ 'elixir',
\ 'sql',
\ 'bash=sh'
\ ]
" enable folding in bash files
let g:sh_fold_enabled=1
" }}}
" Plugin Modifications (BEFORE loading bundles) ----- {{{
" ====================================
" VimMatchUp:
" ====================================
let g:matchup_matchparen_deferred = 1
" ====================================
" WinResizer:
" ====================================
nnoremap <C-w>r :WinResizerStartResize<CR>
"" ====================================
" UndoTree:
" ====================================
nnoremap <silent> <leader>ut :UndotreeToggle<CR>
" ====================================
" COC
" ====================================
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
augroup CocConfig
autocmd!
" coc-highlight: enable highlighting for symbol under cursor
autocmd CursorHold * silent call CocActionAsync('highlight')
augroup END
" set coc as nvim man page provider for functions
" TODO: maybe need to check if coc is enabled for file and do setlocal?
set keywordprg=:call\ CocAction('doHover')
" ====================================
" Carbon Now Screenshots (vim-carbon-now-sh)
" ====================================
vnoremap <F5> :CarbonNowSh<CR>
" ====================================
" Neosnippet:
" ====================================
let g:neosnippet#enable_completed_snippet = 1
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <expr><TAB>
\ pumvisible() ? "\<C-n>" :
\ neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
let g:neosnippet#enable_snipmate_compatibility = 1
" ====================================
" PivotalTracker.vim:
" ====================================
augroup PivotalTracker
autocmd!
autocmd FileType gitcommit setlocal completefunc=pivotaltracker#stories
autocmd FileType gitcommit setlocal omnifunc=pivotaltracker#stories
augroup END
" ====================================
" Alchemist.vim
" ====================================
let g:alchemist#elixir_erlang_src = "/Users/dkarter/dev/forks/elixir+otp"
augroup ElixirIex
autocmd!
autocmd FileType elixir nnoremap <silent> <buffer> <leader>x :IEx<CR>
augroup END
" for toggling from terminal
if has('nvim')
tnoremap <silent> <leader>x <C-\><C-n>:IEx<CR>
endif
" ====================================
" NeoTerm:
" ====================================
let g:neoterm_repl_ruby = 'pry'
let g:neoterm_autoscroll = 1
" ====================================
" Gist:
" ====================================
map <leader>gst :Gist<cr>
" ====================================
" GitGutter:
" ====================================
nnoremap <silent> + :GitGutterNextHunk<cr>
nnoremap <silent> _ :GitGutterPrevHunk<cr>
" ====================================
" Vim Scriptease:
" ====================================
" Run commands that require an interactive shell
nnoremap <Leader>ri :RunInInteractiveShell<space>
" Reload current vim plugin
nnoremap <Leader>rr :Runtime<cr>
" ====================================
" CopyRTF: Copy code as RTF
" ====================================
nnoremap <silent> <leader><C-c> :set nonumber<CR>:CopyRTF<CR>:set number<CR>
" ====================================
" SplitJoin:
" ====================================
let g:splitjoin_align = 1
let g:splitjoin_trailing_comma = 1
let g:splitjoin_ruby_curly_braces = 0
let g:splitjoin_ruby_hanging_args = 0
" ====================================
" MatchTagAlways:
" ====================================
let g:mta_filetypes = {
\ 'jinja': 1,
\ 'xhtml': 1,
\ 'xml': 1,
\ 'html': 1,
\ 'django': 1,
\ 'javascript.jsx': 1,
\ 'eruby': 1,
\ }
" ====================================
" Snippets (UltiSnips):
" ====================================
let g:UltiSnipsExpandTrigger="<NUL>"
let g:UltiSnipsListSnippets="<NUL>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" :UltiSnipsEdit opens in a vertical split
let g:UltiSnipsEditSplit = 'vertical'
let g:UltiSnipsSnippetsDir = $HOME . '/dotfiles/vim/UltiSnips'
" ====================================
" indentLine
" ====================================
let g:indentLine_fileType = [
\ 'java',
\ 'ruby',
\ 'elixir',
\ 'javascript',
\ 'javascript.jsx',
\ 'html',
\ 'eruby',
\ 'vim'
\ ]
let g:indentLine_char = '│'
let g:indentLine_color_term = 238
let g:indentLine_color_gui = '#454C5A'
" ====================================
" setup airline
" ====================================
let g:airline#extensions#branch#enabled = 0
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#show_buffers = 0
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_mode_map = {
\ '__' : '-',
\ 'n' : 'N',
\ 'i' : 'I',
\ 'R' : 'R',
\ 'c' : 'C',
\ 'v' : 'V',
\ 'V' : 'V',
\ '' : 'V',
\ 's' : 'S',
\ 'S' : 'S',
\ '' : 'S',
\ }
" ====================================
" Bullets.vim:
" ====================================
let g:bullets_enabled_file_types = [
\ 'markdown',
\ 'text',
\ 'gitcommit',
\ 'scratch'
\]
" =====================================
" FZF
" =====================================
" set fzf's default input to ripgrep instead of find. This also removes gitignore etc
" let $FZF_DEFAULT_COMMAND = 'rg --files --hidden'
let $FZF_DEFAULT_COMMAND = 'fd --type f --hidden --follow --color=always --exclude .git --ignore-file ~/.gitignore'
let $FZF_DEFAULT_OPTS='--ansi'
let g:fzf_files_options = '--preview "(bat --color \"always\" --line-range 0:100 {} || head -'.&lines.' {})"'
function! FZFOpen(command_str)
if (expand('%') =~# 'NERD_tree' && winnr('$') > 1)
exe "normal! \<c-w>\<c-w>"
endif
exe 'normal! ' . a:command_str . "\<cr>"
endfunction
command! -bang -nargs=* FzfRg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
nnoremap <silent> <C-b> :call FZFOpen(':Buffers')<CR>
nnoremap <silent> <C-g>g :call FZFOpen(':FzfRg!')<CR>
nnoremap <silent> <C-g>c :call FZFOpen(':Commands')<CR>
nnoremap <silent> <C-g>l :call FZFOpen(':BLines')<CR>
nnoremap <silent> <C-p> :call FZFOpen(':Files')<CR>
nnoremap <silent> <C-h> :call FZFOpen(':History')<CR>
" nnoremap <silent> <C-p> :call FZFOpen(':call Fzf_dev()')<CR>
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
" ======================================
" FZF + DevIcons
" ======================================
" Files + devicons
function! Fzf_dev()
let l:fzf_files_options = '--preview "rougify {2..-1} | head -'.&lines.'"'
function! s:files()
let l:files = split(system($FZF_DEFAULT_COMMAND), '\n')
return s:prepend_icon(l:files)
endfunction
function! s:prepend_icon(candidates)
let l:result = []
for l:candidate in a:candidates
let l:filename = fnamemodify(l:candidate, ':p:t')
let l:icon = WebDevIconsGetFileTypeSymbol(l:filename, isdirectory(l:filename))
call add(l:result, printf('%s %s', l:icon, l:candidate))
endfor
return l:result
endfunction
function! s:edit_file(item)
let l:pos = stridx(a:item, ' ')
let l:file_path = a:item[pos+1:-1]
" TODO: not working
let l:cmd = get({
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vertical split',
\ 'ctrl-t': 'tabe'
\ }, a:item[0], 'e')
execute 'silent ' . l:cmd . ' ' . l:file_path
endfunction
call fzf#run({
\ 'source': <sid>files(),
\ 'sink': function('s:edit_file'),
\ 'options': '-m --expect=ctrl-t,ctrl-v,ctrl-x '.
\ l:fzf_files_options,
\ 'down': '40%' })
endfunction
" Custom FZF commands ----------------------------- {{{
fun! s:change_branch(e)
let l:_ = system('git checkout ' . a:e)
:e!
:AirlineRefresh
echom 'Changed branch to' . a:e
endfun
fun! s:parse_pivotal_story(entry)
let l:stories = pivotaltracker#stories('', '')
let l:filtered = filter(l:stories, {_idx, val -> val.menu == a:entry[0]})
return l:filtered[0].word
endfun
inoremap <expr> <c-x># fzf#complete(
\ {
\ 'source': map(pivotaltracker#stories('', ''), {_key, val -> val.menu}),
\ 'reducer': function('<sid>parse_pivotal_story'),
\ 'options': '-m',
\ 'down': '20%'
\ })
inoremap <expr> <c-x>t fzf#complete(
\ {
\ 'source': map(pivotaltracker#stories('', ''), {_key, val -> val.menu}),
\ 'options': '-m',
\ 'down': '20%'
\ })
command! Gbranch call fzf#run(
\ {
\ 'source': 'git branch',
\ 'sink': function('<sid>change_branch'),
\ 'options': '-m',
\ 'down': '20%'
\ })
fun! s:change_remote_branch(e)
let l:_ = system('git checkout --track ' . a:e)
:e!
:AirlineRefresh
echom 'Changed to remote branch' . a:e
endfun
command! Grbranch call fzf#run(
\ {
\ 'source': 'git branch -r',
\ 'sink': function('<sid>change_remote_branch'),
\ 'options': '-m',
\ 'down': '20%'
\ })
" --------------------------------------------------}}}
" =====================================
" JSX
" =====================================
" Allow JSX in normal JS files
let g:jsx_ext_required = 0
" =====================================
" Ack + Ag
" =====================================
" Grep selection with Ag
xnoremap <leader>g y :Ack "<CR>
nnoremap <Leader>g :Ack <C-r><C-w><CR>
" Use The Silver Searcher for grep https://github.com/ggreer/the_silver_searcher
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use Ag for Ack
let g:ackprg = 'ag --vimgrep --smart-case'
endif
nnoremap <leader>f :Ack!<Space>
" ----------------------------------------------------------------------------
" vim slime
" ----------------------------------------------------------------------------
let g:slime_target='tmux'
" ----------------------------------------------------------------------------
" Scratch.vim
" ----------------------------------------------------------------------------
let g:scratch_no_mappings=1
nnoremap <leader>sc :Scratch<CR>
augroup ScratchToggle
autocmd!
autocmd FileType scratch nnoremap <buffer> <leader>sc :q<CR>
augroup END
" ----------------------------------------------------------------------------
" Emmet
" ----------------------------------------------------------------------------
" better emmet leader key (must be followed with ,)
let g:user_emmet_leader_key='<C-e>'
" ----------------------------------------------------------------------------
" Switch.vim
" ----------------------------------------------------------------------------
let g:switch_custom_definitions =
\ [
\ ['up', 'down', 'change'],
\ ['add', 'drop', 'remove'],
\ ['create', 'drop'],
\ ['row', 'column'],
\ ['first', 'second', 'third', 'fourth', 'fifth'],
\ ]
" ----------------------------------------------------------------------------
" Vim RSpec
" ----------------------------------------------------------------------------
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'
nnoremap <Leader>t :call RunCurrentSpecFile()<CR>
nnoremap <Leader>T :call RunNearestSpec()<CR>
nnoremap <Leader>l :call RunLastSpec()<CR>
nnoremap <Leader>sa :call RunAllSpecs()<CR>
" ----------------------------------------------------------------------------
" Vim Flow JS
" ----------------------------------------------------------------------------
let g:flow#autoclose = 1
" ----------------------------------------------------------------------------
" ALE
" ----------------------------------------------------------------------------
let g:airline#extensions#ale#enabled = 1
let g:ale_sign_error = ''
let g:ale_sign_warning = ''
" ALE automatically updates the loclist which makes it impossible to use some
" other plugins such as GV
let g:ale_set_loclist = 0
highlight link ALEWarningSign Directory
highlight link ALEErrorSign WarningMsg
nnoremap <silent> <leader>ne :ALENextWrap<CR>
nnoremap <silent> <leader>pe :ALEPreviousWrap<CR>
let g:ale_fixers = {
\ 'typescript': ['prettier'],
\ 'typescript.tsx': ['prettier'],
\ 'javascript': ['prettier'],
\ 'javascript.jsx': ['prettier'],
\ 'json': ['prettier'],
\ 'scss': ['prettier'],
\ 'bash': ['shfmt'],
\ 'zsh': ['shfmt'],
\ 'elixir': ['mix_format'],
\ 'ruby': ['rubocop'],
\ 'rust': ['rustfmt'],
\ 'elm': ['elm-format'],
\}
let g:ale_sh_shfmt_options = '-i 2 -ci'
let g:ale_fix_on_save = 1
" ----------------------------------------------------------------------------
" Investigate
" ----------------------------------------------------------------------------
" Use Dash.app for documentation of word under cursor
let g:investigate_use_dash=1
let g:investigate_syntax_for_rspec='ruby'
" ----------------------------------------------------------------------------
" Startify
" ----------------------------------------------------------------------------
let g:startify_files_number = 5
" ----------------------------------------------------------------------------
" Vim Hashrocket
" ----------------------------------------------------------------------------
"Change cursor on insert mode (vim-hashrocket)
if !has('nvim')
let g:use_cursor_shapes = 1
end
" ----------------------------------------------------------------------------
" Elm-vim
" ----------------------------------------------------------------------------
" let g:elm_format_autosave=1
let g:elm_detailed_complete = 1
" ----------------------------------------------------------------------------
" NERDTree
" ----------------------------------------------------------------------------
let g:NERDTreeIgnore = [
\ '\.vim$',
\ '\~$',
\ '\.beam',
\ 'elm-stuff',
\ 'deps',
\ '_build',
\ '.git',
\ 'node_modules',
\ 'tags',
\ ]
let g:NERDTreeShowHidden = 1
let g:NERDTreeAutoDeleteBuffer=1
" keep alternate files and jumps
let g:NERDTreeCreatePrefix='silent keepalt keepjumps'
nnoremap <Leader>nt :NERDTreeToggle<CR>
" not necessarily NTree related but uses NERDTree because I have it setup
nnoremap <leader>d :e %:h<CR>
augroup NERDTreeAuCmds
autocmd!
autocmd FileType nerdtree nmap <buffer> <expr> - g:NERDTreeMapUpdir
augroup END
" move up a directory with "-" like using vim-vinegar (usually "u" does that)
" ----------------------------------------------------------------------------
" WebDevIcons
" ----------------------------------------------------------------------------
let g:WebDevIconsUnicodeDecorateFolderNodes = 1
let g:DevIconsEnableFoldersOpenClose = 1
let g:webdevicons_conceal_nerdtree_brackets = 1
let g:webdevicons_enable_airline_statusline = 1
let g:webdevicons_enable_airline_tabline = 1
let g:WebDevIconsOS = 'Darwin'
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols = {}
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['ex'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['exs'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['js'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['jsx'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['vim'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['md'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['rb'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['rabl'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['erb'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['yaml'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['yml'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['svg'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['json'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['elm'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols = {} " needed
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.*vimrc.*'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.ruby-version'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.ruby-gemset'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.rspec'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['Rakefile'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['application.rb'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['environment.rb'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['routes.rb'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['spring.rb'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.keep'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['package.json'] = ''
" Useful alternatives:
" after a re-source, fix syntax matching issues (concealing brackets):
if exists('g:loaded_webdevicons')
call webdevicons#refresh()
endif
" ----------------------------------------------------------------------------
" vim-nerdtree-syntax-highlight:
" ----------------------------------------------------------------------------
let g:NERDTreeFileExtensionHighlightFullName = 1
let g:NERDTreeExactMatchHighlightFullName = 1
let g:NERDTreePatternMatchHighlightFullName = 1
let g:NERDTreeExtensionHighlightColor = {}
let g:NERDTreeExtensionHighlightColor['ex'] = '834F79'
let g:NERDTreeExtensionHighlightColor['exs'] = 'c57bd8'
let g:NERDTreeExtensionHighlightColor['rabl'] = 'ac4142'
let g:NERDTreeExtensionHighlightColor['yml'] = 'f4bf70'
let g:NERDTreeExtensionHighlightColor['yaml'] = 'f4bf70'
let g:NERDTreeExtensionHighlightColor['elm'] = '39B7CF'
" ----------------------------------------------------------------------------
" vim-go
" ----------------------------------------------------------------------------
augroup CustomGoVimMappings
autocmd!
autocmd FileType go setlocal nolist listchars=tab:>-,trail:·,nbsp:·
autocmd FileType go nmap <buffer> <leader>r <Plug>(go-run)
autocmd FileType go nmap <buffer> <leader>b <Plug>(go-build)
autocmd FileType go nmap <buffer> <leader>t <Plug>(go-test)
autocmd FileType go nmap <buffer> <leader>c <Plug>(go-coverage)
autocmd Filetype go
\ command! -bang A call go#alternate#Switch(<bang>0, 'edit')
\| command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
\| command! -bang AS call go#alternate#Switch(<bang>0, 'split')
augroup END
let g:go_fmt_autosave = 1
let g:go_term_mode = 'vsplit'
let g:go_fmt_command='goimports'
" ----------------------------------------------------------------------------
" goyo.vim + limelight.vim
" ----------------------------------------------------------------------------
let g:limelight_paragraph_span = 1
let g:limelight_priority = -1
let g:background_before_goyo = &background
function! s:goyo_enter()
let g:background_before_goyo = &background
if has('gui_running')
set linespace=7
elseif exists('$TMUX')
silent !tmux set status off
endif
Limelight
endfunction
function! s:goyo_leave()
if has('gui_running')
set linespace=0
elseif exists('$TMUX')
silent !tmux set status on
endif
execute 'Limelight!'
execute 'set background=' . g:background_before_goyo
endfunction
augroup GOYO
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
augroup END
" ----------------------------------------------------------------------------
" vim-legend
" ----------------------------------------------------------------------------
let g:legend_active_auto = 0
let g:legend_hit_color = 'ctermfg=64 cterm=bold gui=bold guifg=Green'
let g:legend_ignored_sign = '◌'
let g:legend_ignored_color = 'ctermfg=234'
let g:legend_mapping_toggle = '<Leader>cv'
let g:legend_mapping_toggle_line = '<localleader>cv'
" --------------------------------------------
" vim-ruby:
" --------------------------------------------
" support ruby on rails omnicompletions
let g:rubycomplete_rails = 1
" ----------------------------------------------------- }}}
" Load all plugins ------------------------------- {{{
if filereadable(expand('~/.vimrc.bundles'))
source ~/.vimrc.bundles
endif
" }}}
" Plugin Modifications (AFTER loading bundles) ----- {{{
if has('nvim') && !exists('$TMUX')
" ------------------------------------
" NVIMUX:
" ------------------------------------
lua << EOF
local nvimux = require('nvimux')
-- Nvimux configuration
nvimux.config.set_all{
prefix = '<C-z>',
open_term_by_default = true,
new_window_buffer = 'single',
quickterm_direction = 'botright',
quickterm_orientation = 'vertical',
-- Use 'g' for global quickterm
quickterm_scope = 't',
quickterm_size = '80',
}
-- Nvimux custom bindings
nvimux.bindings.bind_all{
{'s', ':NvimuxHorizontalSplit', {'n', 'v', 'i', 't'}},
{'v', ':NvimuxVerticalSplit', {'n', 'v', 'i', 't'}},
}
-- Required so nvimux sets the mappings correctly
nvimux.bootstrap()
EOF
endif
" }}}
" UI Customizations --------------------------------{{{
if match($ITERM_PROFILE, 'light') >= 0
set background=light
else
set background=dark
endif
colorscheme one
let g:one_allow_italics = 1
call one#highlight('elixirInclude', 'e06c75', '', 'none')
call one#highlight('elixirOperator', 'd19a66', '', 'none')
call one#highlight('vimTodo', '000000', 'ffec8b', 'none')
let g:limelight_conceal_ctermfg = '#454d5a'
let g:limelight_conceal_guifg = '#454d5a'
" Make it obvious where 80 characters is
" cheatsheet https://jonasjacek.github.io/colors/
highlight ColorColumn ctermbg=236 guibg=#303030
let &colorcolumn=join(range(80,999),',')
" solid window border requires FuraCode Nerd Font
set fillchars+=vert:│
" hide vertical split
hi vertsplit guifg=fg guibg=bg
" }}}
" Own commands --------------------------------------------- {{{
command! PrettyPrintJSON %!python -m json.tool
command! PrettyPrintHTML !tidy -mi -html -wrap 0 %
command! PrettyPrintXML !tidy -mi -xml -wrap 0 %
command! BreakLineAtComma :normal! f,.
command! Retab :set ts=2 sw=2 et<CR>:retab<CR>
" }}}
" Auto commands ------------------------------------------------- {{{
augroup vimrcEx
autocmd!
" Remove trailing whitespace on save for ruby files.
autocmd BufWritePre *.rb,*.ex,*.exs :%s/\s\+$//e
if exists('$ITERM_PROFILE')
" Preview images in vim (while in iterm)
autocmd BufEnter *.png,*.jpg,*gif exec "! ~/.iterm2/imgcat ".expand("%") | :bw
endif
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Set syntax highlighting for specific file types
autocmd BufRead,BufNewFile Appraisals,*.rabl set filetype=ruby
autocmd BufRead,BufNewFile .babelrc set filetype=json
autocmd BufRead,BufNewFile *.yrl set filetype=erlang
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile .eslintrc,.prettierrc set filetype=json
" Enable spellchecking for Markdown
autocmd FileType markdown setlocal spell
" Automatically wrap at 80 characters for Markdown
autocmd BufRead,BufNewFile *.md setlocal textwidth=80
" Automatically wrap at 72 characters and spell check git commit messages
autocmd FileType gitcommit setlocal textwidth=72
autocmd FileType gitcommit setlocal spell
" Allow stylesheets to autocomplete hyphenated words
autocmd FileType css,scss,sass setlocal iskeyword+=-
" Vim/tmux layout rebalancing
" automatically rebalance windows on vim resize
autocmd VimResized * :wincmd =
" add support for comments in json (jsonc format used as configuration for
" many utilities)
autocmd FileType json syntax match Comment +\/\/.\+$+
" notify if file changed outside of vim to avoid multiple versions
autocmd FocusGained * checktime
augroup END
" }}}
" Vim Script file settings ------------------------ {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}
" Key Mappings -------------------------------------------------- {{{
" Delete current buffer without losing the split
nnoremap <silent> <C-x> :bp\|bd #<CR>
" open FZF in current file's directory
nnoremap <silent> <Leader>_ :Files <C-R>=expand('%:h')<CR><CR>
" fold file based on syntax
nnoremap <silent> <leader>zs :setlocal foldmethod=syntax<CR>
" rename current file
nnoremap <Leader>rn :Move <C-R>=expand("%")<CR>
" replace word under cursor, globally, with confirmation
nnoremap <Leader>k :%s/\<<C-r><C-w>\>//gc<Left><Left><Left>
vnoremap <Leader>k y :%s/<C-r>"//gc<Left><Left><Left>
" insert frozen string literal comment at the top of the file (ruby)
map <leader>fsl ggO# frozen_string_literal: true<esc>jO<esc>
" remove highlighting on escape
map <silent> <esc> :nohlsearch<cr>
" sort selected lines
vmap gs :sort<CR>
" Pasting support
set pastetoggle=<F2> " Press F2 in insert mode to preserve tabs when
" pasting from clipboard into terminal
" re-indent file and jump back to where the cursor was
map <F7> mzgg=G`z
" Allow j and k to work on visual lines (when wrapping)
noremap <silent> <Leader>w :call ToggleWrap()<CR>
function! ToggleWrap()
if &wrap
echo 'Wrap OFF'
setlocal nowrap
set virtualedit=all
silent! nunmap <buffer> j
silent! nunmap <buffer> k
else
echo 'Wrap ON'
setlocal wrap linebreak nolist
set virtualedit=
setlocal display+=lastline
noremap <buffer> <silent> k gk
noremap <buffer> <silent> j gj
inoremap <buffer> <silent> <Up> <C-o>gk
inoremap <buffer> <silent> <Down> <C-o>gj
endif
endfunction
" prevent entering ex mode accidentally
nnoremap Q <Nop>
" Tab/shift-tab to indent/outdent in visual mode.
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" Keep selection when indenting/outdenting.
vnoremap > >gv
vnoremap < <gv
" Search for selected text
vnoremap * "xy/<C-R>x<CR>
" Split edit your vimrc. Type space, v, r in sequence to trigger
fun! OpenConfigFile(file)
if (&filetype ==? 'startify')
execute 'e ' . a:file
else
execute 'tabe ' . a:file
endif
endfun
nnoremap <silent> <leader>vr :call OpenConfigFile('~/.vimrc')<cr>
nnoremap <silent> <leader>vb :call OpenConfigFile('~/.vimrc.bundles')<cr>
" toggle background light / dark
fun! ToggleBackground()
if (&background ==? 'dark')
set background=light
else
set background=dark
endif
endfun
nnoremap <silent> <F10> :call ToggleBackground()<CR>
" Source (reload) your vimrc. Type space, s, o in sequence to trigger
nnoremap <leader>so :source $MYVIMRC<cr>
"split edit your tmux conf
nnoremap <leader>mux :vsp ~/.tmux.conf<cr>