-
Notifications
You must be signed in to change notification settings - Fork 18
/
vimrc
1113 lines (909 loc) · 33.7 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> \
" disable bracketed paste
" set t_BE=
set background=dark " tell vim what the background color looks like
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
" set shell to zsh
set shell=/bin/zsh
" 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) ----- {{{
" ====================================
" WinResizer:
" ====================================
nnoremap <C-w>r :WinResizerStartResize<CR>
" ====================================
" UndoTree:
" ====================================
nnoremap <silent> <leader>ut :UndotreeToggle<CR>
" ====================================
" NeovimCompletionManager:
" ====================================
" use tab to cycle through completions
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" use enter to complete snippets - not working
" imap <expr> <CR> (pumvisible() ? "\<c-y>\<Plug>(expand_or_nl)" : "\<CR>")
" imap <expr> <Plug>(expand_or_nl) (cm#completed_is_snippet() ? "\<C-U>":"\<CR>")
" ====================================
" 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
" ====================================
" LanguageClient-neovim:
" ====================================
let g:LanguageClient_serverCommands = {
\ 'rust': ['rustup', 'run', 'nightly', 'rls'],
\ 'javascript.jsx': ['javascript-typescript-stdio'],
\ 'haskell': ['hie', '--lsp'],
\ 'elixir': ['elixir-ls'],
\ }
" let g:lsp_servers = [
" \ {
" \ 'name': 'elixir-ls',
" \ 'cmd': {server_info->[&shell, &shellcmdflag, 'env ERL_LIBS=/Users/hauleth/Workspace/JakeBecker/elixir-ls/lsp mix elixir_ls.language_server']},
" \ 'whitelist': ['elixir'],
" \ },
" \ {
" \ 'name': 'rls',
" \ 'cmd': {server_info->['rustup', 'run', 'nightly', 'rls']},
" \ 'whitelist': ['rust'],
" \ },
" \ {
" \ 'name': 'vue-language-server',
" \ 'cmd': {server_info->['vls']},
" \ 'whitelist': ['vue'],
" \ }
" \ ]
" ====================================
" NeoTerm:
" ====================================
let g:neoterm_position = 'vertical'
let g:neoterm_repl_ruby = 'pry'
let g:neoterm_autoscroll = 1
" ====================================
" Gist:
" ====================================
map <leader>gst :Gist<cr>
" ====================================
" GitGutter:
" ====================================
nnoremap <silent> <cr> :GitGutterNextHunk<cr>
nnoremap <silent> <backspace> :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
" ====================================
" NeoFormat:
" ====================================
let g:neoformat_try_formatprg = 1
let g:neoformat_only_msg_on_error = 1
" ONLY PRETTIER (don't run any other formatters for these file types)
let g:neoformat_enabled_javascript = ['prettier']
let g:neoformat_enabled_css = ['prettier']
let g:neoformat_enabled_scss = ['prettier']
let g:neoformat_enabled_json = ['prettier']
let g:neoformat_javascript_prettier = {
\ 'exe': 'prettier',
\ 'args': ['--stdin', '--print-width 80', '--single-quote', '--trailing-comma es5'],
\ 'stdin': 1,
\ }
augroup NeoformatAutoFormat
autocmd!
autocmd FileType zsh setlocal formatprg=shfmt\ -i\ 2
autocmd BufWritePre *.{js,jsx,css,scss,json,ex,exs} Neoformat
autocmd BufWritePre .zshrc-dorian,.zshrc,.aliases Neoformat
" autocmd BufWritePre *.css,*.scss Neoformat stylefmt
augroup END
nnoremap <leader>nf :Neoformat<CR>
" ====================================
" 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 = '<C-l>'
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#tabline#enabled = 0
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#show_buffers = 0
let g:airline_left_sep = ''
let g:airline_right_sep = ''
" ====================================
" Bullets.vim:
" ====================================
let g:bullets_enabled_file_types = [
\ 'markdown',
\ 'text',
\ 'gitcommit',
\ 'scratch'
\]
" =====================================
" FZF
" =====================================
" set fzf's default input to AG instead of find. This also removes gitignore etc
let $FZF_DEFAULT_COMMAND = 'ag --hidden -l -g ""'
let g:fzf_files_options = '--preview "rougify {} | 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
nnoremap <silent> <C-b> :call FZFOpen(':Buffers')<CR>
nnoremap <silent> <C-g>g :call FZFOpen(':Ag')<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-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 "echo {} | tr -s \" \" \"\n\" | tail -1 | xargs rougify | 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:parts = split(a:item, ' ')
let l:file_path = get(l:parts, 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 :Ag "<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'],
\ ]
" ----------------------------------------------------------------------------
" Rail.vim
" ----------------------------------------------------------------------------
" Exclude Javascript files in :Rtags via rails.vim due to warnings when parsing
let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'"
" ----------------------------------------------------------------------------
" 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 = ''
highlight link ALEWarningSign Directory
highlight link ALEErrorSign WarningMsg
nnoremap <silent> <leader>ne :ALENextWrap<CR>
nnoremap <silent> <leader>pe :ALEPreviousWrap<CR>
" ----------------------------------------------------------------------------
" 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
nnoremap <Leader>nt :NERDTreeToggle<CR>
nnoremap <leader>d :e %:h<CR>
" ----------------------------------------------------------------------------
" 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:WebDevIconsUnicodeDecorateFileNodesPatternSymbols = {} " needed
let g:WebDevIconsUnicodeDecorateFileNodesPatternSymbols['.*vimrc.*'] = ''
" 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'
" ----------------------------------------------------------------------------
" 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)
augroup END
" ----------------------------------------------------------------------------
" goyo.vim + limelight.vim
" ----------------------------------------------------------------------------
let g:limelight_paragraph_span = 1
let g:limelight_priority = -1
function! s:goyo_enter()
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!'
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
" Load matchit.vim, but only if the user hasn't installed a newer version.
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
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 --------------------------------{{{
" " Gruvbox colorscheme allow italics
" let g:gruvbox_italic = 1
" let g:gruvbox_invert_selection=0
" default color scheme
" colorscheme dracula
set background=dark
colorscheme onedark
" when on dracula
" let g:limelight_conceal_ctermfg = 59
" let g:limelight_conceal_guifg = '#43475b'
" 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
" 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 *.md set filetype=markdown
" 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 =
augroup END
augroup Elm
autocmd!
autocmd FileType elm setlocal tabstop=4
autocmd BufWritePre *.elm :ElmFormat
augroup END
" }}}
" Vim Script file settings ------------------------ {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}
" Better split management, kept in sync with tmux' -- {{{
"" noremap <leader>- :sp<CR><C-w>j
"" noremap <leader>\| :vsp<CR><C-w>l
" }}}
" Key Mappings -------------------------------------------------- {{{
" replace word under cursor, globally, with confirmation
nnoremap <Leader>k :%s/\<<C-r><C-w>\>//gc<Left><Left><Left>
" remove highlighting on escape
map <silent> <esc> :noh<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($MYVIMRC)<cr>
nnoremap <silent> <leader>vb :call OpenConfigFile('~/.vimrc.bundles')<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>
" VimPlug:
nnoremap <leader>pi :PlugInstall<CR>
nnoremap <leader>pu :PlugUpdate<CR>
nnoremap <leader>pc :PlugClean<CR>
" change dir to current file's dir
nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>
" zoom a vim pane, <C-w> = to re-balance
nnoremap <leader>- :wincmd _<cr>:wincmd \|<cr>
nnoremap <leader>= :wincmd =<cr>
" close all other windows with <leader>o
nnoremap <leader>wo <c-w>o
" Index ctags from any project, including those outside Rails
map <Leader>ct :!ctags -R .<CR>
" Switch between the last two files
nnoremap <tab><tab> <c-^>
" command typo mapping
cnoremap WQ wq
cnoremap Wq wq
cnoremap QA qa
cnoremap qA qa
cnoremap Q! q!
" copy to end of line
nnoremap Y y$
" copy to system clipboard
noremap gy "+y
" copy whole file to system clipboard
nnoremap gY gg"+yG
" Prettier:
" shows you the output from prettier - useful when you have a syntax error
nnoremap <leader>p :!prettier %<CR>
" CtrlSF:
nnoremap <C-F>f :CtrlSF
nnoremap <C-F>g :CtrlSF<CR>
" easier new tab
noremap <C-t> <esc>:tabnew<CR>
noremap <C-c> <esc>:tabclose<CR>
" disable arrow keys in normal mode
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
" last typed word to lower case
inoremap <C-w>u <esc>guawA
" last typed word to UPPER CASE
inoremap <C-w>U <esc>gUawA
" entire line to lower case
inoremap <C-g>u <esc>guuA
" entire line to UPPER CASE
inoremap <C-g>U <esc>gUUA
" last word to title case
inoremap <C-w>t <esc>bvgU<esc>A
" current line to title case
inoremap <C-g>t <esc>:s/\v<(.)(\w*)/\u\1\L\2/g<cr>A
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" Incsearch:
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
" Open files relative to current path:
nnoremap <leader>e :edit <C-R>=expand("%:p:h") . "/" <CR>
nnoremap <leader>s :split <C-R>=expand("%:p:h") . "/" <CR>
" --------------------- Key Mappings ---------------------------- }}}
" Abbreviations --------------------------------------- {{{
iabbrev @@ dkarter@gmail.com
iabbrev ccopy Copyleft 2016 Dorian Karter.
iabbrev bpry require 'pry'; binding.pry;
iabbrev ipry require IEx; IEx.pry;
" Local config
if filereadable($HOME . '/.vimrc.local')
source ~/.vimrc.local
endif