-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
1101 lines (992 loc) · 42.7 KB
/
Copy pathvimrc
File metadata and controls
1101 lines (992 loc) · 42.7 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
" This must be first, because it changes other options as a side effect.
set nocompatible
unlet $DYLD_INSERT_LIBRARIES
let mapleader = "," " \ is the default leader character
let maplocalleader = ',' " \ is the default
set runtimepath^=~/.dotfiles/vim
set runtimepath+=~/.homebrew/share/vim,~/.dotfiles/vim/after
" General settings {{{
set timeout
set ttimeout
set timeoutlen=300
set title
set writeany " Try and write without requiring !
set history=1000 " keep 1000 lines of command line history
set showcmd " display incomplete commands
set incsearch " do incremental searching
set virtualedit=block " allows editing inside of characters that may not actually exist
set noshowmode " The much improved statusline makes it trivial to know your mode
set scrolljump=3 " make the window jump 10 lines when reaching an edge, helpful to prevent slow scrolling
set scrolloff=10 " Don't put the cursor so close to a windows edge
set sidescrolloff=7 " sides can be a little more forgiving
set sidescroll=1 " mode the side by 1
set visualbell t_vb= " disable the stupid bell
set cmdheight=1 " Reduce the number of times the hit enter dialog comes up
set shortmess+=aIWsc " Make messages even shorter
set laststatus=2 " Always display the status line
set autoindent " always set auto indenting on
set smartindent " automatically adjust the level of indentation with language constructs
set tabstop=2 " how many spaces to use for a tab
set softtabstop=2 " number of spaces a tab counts for
set shiftwidth=2 " how much to shift text when using << or >>
set expandtab " expand tabs into spaces
set shiftround " when at an odd number of spaces and using >>/<< go to correct multiple
set smarttab " Insert the shiftwidth number of space at start of non empty line when using <Tab>
set numberwidth=3 " and always show room for 2 numbers since it is only relative numbers
set ignorecase " don't use case when searching
set smartcase " unless I type an uppercase letter, then care
set hidden " Make Vim more accepting of hidden buffer
set confirm " Ask me what to do when quiting or saving fails
set autoread " Automatically reload files that change on disk
set showmatch " Jump to matching }] briefly when typing
set matchtime=3 " Tenths of a second to show matching paren
" set splitbelow " Where to make splits by default
" set splitright " Where to make splits by default
set fillchars=diff:\ " Don't put annoying - in deleted diff lines
set nostartofline " Don't jump to start of line as side effect, e.g. <<
set updatetime=1500 " Make man auto command macros fire quicker, more often
set pumheight=10 " control how many options are shown before scrolling on auto completion
set mouse=a " Turn on mouse support
if !has('nvim')
set ttymouse=sgr " Support ultra wide terminals (> 223 columns)
set cryptmethod=blowfish " use a strong encryption method instead of weak one
else
set inccommand=nosplit
endif
set nojoinspaces " Don't add extra space when using SHIFT-J
set display+=lastline " Show the whole of a last line when it is wrapped
set cpoptions+=yd " allow yank commands to be repeated with '.'
set cinoptions=:0,l1,g0,t0,(0,Ws
set gdefault " make substitutions default to replacing all on line
set pastetoggle=<F2> " Paste mode to turn off autoindention
set fileformats=unix,dos " Make the default fileformat be unix line endings
set encoding=utf-8 " Make default text encoding utf-8
set termencoding=utf-8 " Make default termainl encoding utf-8
" set number " Use number for now because relative is slow
set relativenumber " Make line numbers relative to my cursor for easy jumping
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave *
\ if &number == 1 |
\ setlocal relativenumber nonumber |
\ endif
autocmd BufLeave,FocusLost,InsertEnter *
\ if &relativenumber == 1 |
\ setlocal norelativenumber number |
\ end
augroup END
set lazyredraw " don't redraw the screen during macros
set cursorline " start with cursor shown
set clipboard=unnamed,unnamedplus " make copying put on the system clipboard and pasting get from it
set maxmempattern=10000
if has("persistent_undo")
set undofile
set undodir=~/.dotfiles/vim/undo,tmp
endif
set backupdir=~/.dotfiles/vim/backup
set backup
set backupcopy=yes
set noswapfile
if has("spell")
set spellfile=~/.dotfiles/vim/spell/common.utf-8.add " store common correct/incorrect works in a shared place
endif
" Set command completion options to open a selectable menu
set wildmenu
set wildmode=longest:full,full
set wildignore=*.o,*.rbc,*.obj,*.pyc,.git,CVS,.svn,tags,.hg
set wildignorecase
" Tab completion options
" (only complete to the longest unambiguous match, and show a menu)
set completeopt=menuone,noselect,noinsert
set complete=.,t,i,b,w,kspell
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set formatoptions=cq1nrj
set colorcolumn=+1 " Always be aware of the best file width
set textwidth=79
set wrap linebreak showbreak=… cpoptions+=n " Use soft wrapping, and adjust mappings for edit keys
set list listchars=tab:▸\ ,eol:¬,precedes:<,extends:>,nbsp:· " Display extra whitespace
sign define LspDiagnosticsSignError text=✖ texthl=LspDiagnosticsSignError
sign define LspDiagnosticsSignWarning text=‼ texthl=LspDiagnosticsSignWarning
sign define LspDiagnosticsSignInformation text=⚑ texthl=LspDiagnosticsSignInformation
sign define LspDiagnosticsSignHint text=➜ texthl=LspDiagnosticsSignHint
" Enable file type detection.
filetype plugin indent on
" Only enable syntax once to prevent losing styles
if !exists("syntax_on")
syntax enable
endif
" }}}
" General Mappings {{{
" Allows moving up by screen lines, not file lines
map j gj
map k gk
" Don't use Ex mode, use Q for formatting
map Q gq
" Make Y consistent with C and D
nnoremap Y y$
" Keep searches in middle of screen
nnoremap * *zzzv
nnoremap # #zzzv
nnoremap n nzzzv
nnoremap N Nzzzv
" Shortcut to redraw screen
nnoremap <silent> <Leader><C-l> :redraw!<CR>
vnoremap <silent> <Leader><C-l> :redraw!<CR>
" Don't move the cursor after pasting
" noremap p p`[
" noremap P P`[
" Open an edit path relative to current file
nnoremap <Leader>el :e <C-r>=expand('%:p:h')<CR>/
" Select just pasted text in last used visual mode
nnoremap <expr> <Leader>v '`[' . visualmode() . '`]'
" Shortcut to edit .vimrc
noremap <Leader>ev :edit ~/.dotfiles/vimrc<CR>
" Simplistic buffer removal but keeping window
nnoremap <silent> <Leader>bd :Bdelete!<CR>
nnoremap <silent> <Leader>bw :Bwipeout!<CR>
" Paste without losing the item being pasted
" vnoremap P p :call setreg(&clipboard =~# 'unnamed' ? '*' : '"', getreg('0')) <CR>
" Screw the manual searching on shift K
nnoremap K <nop>
" Better movement in command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
" Make it easy to select the whole buffer
vnoremap ae ggVoG$
" Easy abbreviation to get path to current file
cabbrev %% <C-R>=expand('%:p:h')<CR>
" Easy jump between last file
nnoremap <Leader><Leader> <C-^>
" When killing the current line, make it start a new undo at that point
inoremap <C-U> <C-G>u<C-U>
" }}}
" Terminal/GUI Setup {{{
set background=dark
if !has("gui_running")
if !has('nvim')
" Workaround for making things like arrow keys work under screen
if $TERM == 'screen*'
set term=xterm
elseif $TERM == 'screen-256color'
set term=xterm-256color
end
else
" set termguicolors
endif
" Color scheme
let g:solarized_underline = 0
if &t_Co > 255
" colorscheme solarized
colorscheme plasticcodewrap
else
colorscheme solarized
colorscheme ir_black
endif
endif
" }}}
" Tabline {{{
" set up tab labels with tab number, buffer name, number of windows
function! TabLabel()
let label = ''
let i = 1
let current = tabpagenr()
while i <= tabpagenr('$')
let bufnrlist = tabpagebuflist(i)
" Let vim know which tab this delineates
let label .= '%#TabLine# '
let label .= '%' . (i == current ? '#TabLineSel#' : '#TabLine#') . '%' . i . 'T'
" Append the tab number
let label .= i . ': '
" Append the buffer name
let name = bufname(bufnrlist[tabpagewinnr(i) - 1])
if name == ''
" give a name to no-name documents
if &buftype=='quickfix'
let name = '[Quickfix List]'
else
let name = '[No Name]'
endif
else
" get only the file name
let name = fnamemodify(name,":p:t")
endif
let label .= name . ' '
" Add '+' if one of the buffers in the tab page is modified
for bufnr in bufnrlist
if getbufvar(bufnr, "&modified")
let label .= '[+]'
break
endif
endfor
" Append the number of windows in the tab page
let label .= '[' . tabpagewinnr(i, '$') . ']' . (i == current ? '' : '')
let i += 1
endwhile
let label .= '%T%#TabLineFill#%=%999%X'
return label
endfunction
set tabline=%!TabLabel()
" }}}
if has("autocmd")
augroup GeneralSettings " {{{
au!
" Equalize windows when resized
au VimResized * wincmd =
" Reload vimrc after editing
" autocmd BufWritePost .vimrc source $MYVIMRC
autocmd BufNewFile,BufRead *.txt setfiletype text
autocmd BufNewFile,BufRead .envrc setfiletype bash
autocmd FileType diff setlocal nolist nospell
" Ruby functions can have these in thier names
autocmd FileType eruby,ruby setlocal iskeyword+=!,?
autocmd BufRead,BufNewFile config.ru,Guardfile set ft=ruby
autocmd BufRead,BufNewFile *.cjs set ft=javascript
" Maintain tabs for idiomatic go code
autocmd FileType go,gomod setlocal noexpandtab listchars+=tab:\ \ softtabstop=2 tabstop=2
autocmd BufWrite *.go :call <SID>TrimTrailingWhitespace()
autocmd BufWrite *.py :call <SID>TrimTrailingWhitespace()
autocmd BufWrite *.rb :call <SID>TrimTrailingWhitespace()
autocmd BufWrite *.md :call <SID>TrimTrailingWhitespace()
" Help Window Customization {{{
function! s:SetupHelpWindow()
wincmd L
vertical resize 80
setlocal nonumber winfixwidth colorcolumn=
setlocal norelativenumber nolist nospell readonly
setlocal foldexpr& nofoldenable foldmethod& foldcolumn=0
let b:stl = "#[Branch] HELP #[BranchS]<NCUR>[>]</NCUR>#[FileNameS]<CUR>[>>]</CUR>#[FunctionName]%<%=#[LinePercentS]<CUR>[<<]</CUR>#[LinePercent] %p%% "
autocmd BufWinEnter <buffer> call <SID>SetupHelpWindow()
nnoremap <buffer> <Space> <C-]>
nnoremap <buffer> <CR> <C-]>
nnoremap <buffer> <BS> <C-T>
nnoremap <buffer> <silent> q :bd<CR>
endfunction
autocmd FileType help call <SID>SetupHelpWindow()
" }}}
" Man Window Customization {{{
" Tell the plugin to compute manpage width based on actual window size
" instead of 999
let g:man_hardwrap=1
let $MANWIDTH=80
function! s:SetupManWindow()
wincmd L
vertical resize 80
setlocal nonumber winfixwidth colorcolumn=
setlocal norelativenumber nolist nospell readonly
setlocal foldexpr& nofoldenable foldmethod& foldcolumn=0
setlocal showbreak=
let b:stl = "#[Branch] MANPAGE#[BranchS] [>] #[Filename]%{expand('%:t:r:r')} #[FileNameS]<CUR>[>>]</CUR>#[FunctionName]%< %=<CUR>#[LinePercentS][<<]#[LinePercent]</CUR> %p%% "
autocmd BufWinEnter <buffer> call <SID>SetupManWindow()
nmap <buffer> <Space> <C-]>
nmap <buffer> <CR> <C-]>
nmap <buffer> <BS> <C-T>
nnoremap <buffer> <silent> q :bw<CR>
setlocal ft=man
endfunction
autocmd FileType man call <SID>SetupManWindow()
cabbrev man <C-R>=(getcmdtype() == ':' && getcmdpos() == 1 ? 'Man' : 'man')<CR>
" }}}
" Fast escape from insert {{{
autocmd InsertEnter * set timeoutlen=350
autocmd InsertLeave * set timeoutlen=700
" }}}
" Highighlight cursor row {{{
autocmd WinEnter,InsertLeave * setlocal cursorline
autocmd WinLeave,InsertEnter * setlocal nocursorline " }}}
" Restore last cursor position {{{
autocmd BufWinEnter *
\ if &filetype !~ 'commit\c' |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ exe "normal! zvzz" |
\ endif |
\ endif
" }}}
" Auto make directories on save {{{
autocmd BufWritePre,FileWritePre *
\ if !isdirectory(expand("<afile>:p:h")) |
\ call mkdir(expand("<afile>:p:h"), "p") |
\ endif
" }}}
augroup END " }}}
augroup CompletionSettings " {{{
au!
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
autocmd FileType vim,ruby setlocal formatoptions-=o formatoptions-=r
autocmd FileType vim setlocal foldmethod=marker foldmarker={{{,}}}
augroup END " }}}
" Statusline {{{
" Statusline updater {{{
function! s:StatusLineArrows(stl)
let stl = substitute(a:stl, '\[>>\]', '', 'g')
let stl = substitute(stl, '\[>\]', '', 'g')
let stl = substitute(stl, '\[<<\]', '', 'g')
let stl = substitute(stl, '\[<\]', '', 'g')
return stl
endfunction
" Inspired by StatusLineHighlight by Ingo Karkat
function! s:StatusLine(new_stl, type, current)
let current = (a:current ? "" : "NC")
let type = a:type
let new_stl = a:new_stl
" Prepare current buffer specific text
" Syntax: <CUR> ... </CUR>
let new_stl = substitute(new_stl, '<CUR>\(.\{-,}\)</CUR>', (a:current ? '\1' : ''), 'g')
let new_stl = substitute(new_stl, '<NCUR>\(.\{-,}\)</NCUR>', (a:current ? '' : '\1'), 'g')
" Prepare statusline colors
" Syntax: #[ ... ]
let new_stl = substitute(new_stl, '#\[\(\w\+\)\]', '%#StatusLine'.type.'\1'.current.'#', 'g')
" Append the syntax scope according to most specific rules to enable it, e.g. buffer then global preference
if exists('b:synid') && !b:synid
elseif exists('g:synid') && !g:synid
elseif exists('g:synid') || exists('b:synid')
let stack = string(reverse(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')))
if stack != '[]'
let stack = substitute(stack, "\\(\\['\\|'\\]\\)", '', 'g')
let stack = substitute(stack, "', '", ' [<] ', 'g')
let new_stl .= '[<] '.stack.' '
end
endif
let new_stl = <SID>StatusLineArrows(new_stl)
if &l:statusline ==# new_stl
" Statusline already set, nothing to do
return
endif
if empty(&l:statusline)
" No statusline is set, use my_stl
let &l:statusline = new_stl
else
" Check if a custom statusline is set
let plain_stl = substitute(&l:statusline, '%#StatusLine\w\+#', '', 'g')
if &l:statusline ==# plain_stl
" A custom statusline is set, don't modify
return
endif
" No custom statusline is set, use new_stl
let &l:statusline = new_stl
endif
endfunction
" }}}
" Color dict parser {{{
function! s:StatusLineColors(colors)
for type in keys(a:colors)
for name in keys(a:colors[type])
let colors = {'c': a:colors[type][name][0], 'nc': a:colors[type][name][1]}
let type = (type == 'NONE' ? '' : type)
let name = (name == 'NONE' ? '' : name)
if exists("colors['c'][0]")
exec 'hi StatusLine'.type.name.' ctermbg='.colors['c'][0].' ctermfg='.colors['c'][1].' cterm='.colors['c'][2].' guibg='.colors['c'][3].' guifg='.colors['c'][4].' gui='.colors['c'][2]
endif
if exists("colors['nc'][0]")
exec 'hi StatusLine'.type.name.'NC ctermbg='.colors['nc'][0].' ctermfg='.colors['nc'][1].' cterm='.colors['nc'][2].' guibg='.colors['nc'][3].' guifg='.colors['nc'][4].' gui='.colors['nc'][2]
endif
endfor
endfor
endfunction
" }}}
" Color dict {{{
let s:gui_yellow = "#af8700"
let s:gui_red = "#d70000"
let s:gui_bgbg = "#1c1c1c"
let s:gui_botfg = "#e4e4e4"
let s:gui_darkbg = "#262626"
let s:gui_midbg = "#585858"
let s:gui_midfg = "#ffffd7"
let s:gui_topbg = "#ffffd7"
let s:yellow = 3
let s:red = 1
let s:bgbg = 8
let s:botfg = 7
let s:darkbg = 0
let s:midbg = 10
let s:midfg = 15
let s:topbg = 15
let s:statuscolors = {
\ 'NONE': {
\ 'NONE' : [[ s:darkbg, s:midbg, 'bold', s:gui_darkbg, s:gui_midbg], [ s:darkbg, 242, 'none', s:gui_bgbg, s:gui_darkbg]]
\ }
\ , 'Normal': {
\ 'Mode' : [[ s:yellow, s:bgbg, 'bold', s:gui_yellow, s:gui_bgbg], []]
\ , 'ModeS' : [[ s:midbg, s:yellow, 'bold', s:gui_midbg, s:gui_yellow], []]
\, 'Branch' : [[ s:midbg, s:botfg, 'none', s:gui_midbg, s:gui_botfg], [ s:darkbg, s:midbg, 'none', s:gui_darkbg, s:gui_midbg]]
\, 'BranchS' : [[ s:midbg, s:midfg, 'bold', s:gui_midbg, s:gui_midfg], [ s:darkbg, s:midbg, 'bold', s:gui_darkbg, s:gui_midbg]]
\, 'FileName' : [[ s:midbg, s:midfg, 'bold', s:gui_midbg, s:gui_midfg], [ s:darkbg, s:midbg, 'bold', s:gui_darkbg, s:gui_midfg]]
\, 'FileNameS' : [[ s:darkbg, s:midbg, 'bold', s:gui_darkbg, s:gui_midbg], [ s:midbg, s:darkbg, 'none', s:gui_bgbg, s:gui_darkbg]]
\, 'Error' : [[ s:midbg, s:red, 'bold', s:gui_midbg, s:gui_red], [ s:darkbg, s:midbg, 'none', s:gui_darkbg, s:gui_midbg]]
\, 'ModFlag' : [[ s:midbg, s:red, 'bold', s:gui_midbg, s:gui_red], [ s:darkbg, s:midbg, 'none', s:gui_darkbg, s:gui_midbg]]
\, 'BufFlag' : [[ s:midbg, s:darkbg, 'none', s:gui_midbg, s:gui_darkbg], [ s:darkbg, s:midbg, 'none', s:gui_darkbg, s:gui_midbg]]
\, 'FunctionName' : [[ s:darkbg, s:midbg, 'none', s:gui_darkbg, s:gui_midbg], [ s:darkbg, s:midbg, 'none', s:gui_bgbg, s:gui_darkbg]]
\, 'FileFormat' : [[ s:darkbg, s:midbg, 'none', s:gui_darkbg, s:gui_midbg], [ s:darkbg, s:midbg, 'none', s:gui_bgbg, s:gui_darkbg]]
\, 'FileEncoding' : [[ s:darkbg, s:midbg, 'none', s:gui_darkbg, s:gui_midbg], [ s:darkbg, s:midbg, 'none', s:gui_bgbg, s:gui_darkbg]]
\, 'Separator' : [[ s:darkbg, s:midbg, 'bold', s:gui_darkbg, s:gui_midbg], [ s:darkbg, s:midbg, 'none', s:gui_bgbg, s:gui_darkbg]]
\, 'FileType' : [[ s:darkbg, s:botfg, 'none', s:gui_darkbg, s:gui_botfg], [ s:darkbg, s:midbg, 'none', s:gui_bgbg, s:gui_darkbg]]
\, 'LinePercentS' : [[ s:darkbg, s:midbg, 'bold', s:gui_darkbg, s:gui_midbg], [ s:midbg, s:darkbg, 'none', s:gui_bgbg, s:gui_bgbg]]
\, 'LinePercent' : [[ s:midbg, s:midfg, 'none', s:gui_midbg, s:gui_midfg], [ s:darkbg, s:midbg, 'bold', s:gui_bgbg, s:gui_midbg]]
\, 'LineNumberS' : [[ s:midbg, s:topbg, 'bold', s:gui_midbg, s:gui_topbg], [ s:darkbg, s:midbg, 'none', s:gui_darkbg, s:gui_bgbg]]
\, 'LineNumber' : [[ s:topbg, s:darkbg, 'bold', s:gui_topbg, s:gui_darkbg], [ s:darkbg, s:midbg, 'bold', s:gui_darkbg, s:gui_midbg]]
\, 'LineColumn' : [[ s:topbg, s:midbg, 'none', s:gui_topbg, s:gui_midbg], [ s:darkbg, s:midbg, 'none', s:gui_darkbg, s:gui_midbg]]
\ }
\ , 'Insert': {
\ 'Mode' : [[ 153, 23, 'bold', '#afd7ff', '#005f5f'], []]
\ , 'ModeS' : [[ 31, 153, 'bold', '#0087af', '#afd7ff'], []]
\ , 'Branch' : [[ 31, 117, 'none', '#0087af', '#87d7ff'], []]
\ , 'BranchS' : [[ 31, 117, 'bold', '#0087af', '#87d7ff'], []]
\ , 'FileName' : [[ 31, 231, 'bold', '#0087af', '#ffffff'], []]
\ , 'FileNameS' : [[ 24, 31, 'bold', '#005f87', '#0087af'], []]
\ , 'Error' : [[ 31, 202, 'bold', '#0087af', '#ff5f00'], []]
\ , 'ModFlag' : [[ 31, 196, 'bold', '#0087af', '#ff0000'], []]
\ , 'BufFlag' : [[ 31, 75, 'none', '#0087af', '#5fafff'], []]
\ , 'FunctionName' : [[ 24, 117, 'none', '#005f87', '#87d7ff'], []]
\ , 'FileFormat' : [[ 24, 75, 'none', '#005f87', '#5fafff'], []]
\ , 'FileEncoding' : [[ 24, 75, 'none', '#005f87', '#5fafff'], []]
\ , 'Separator' : [[ 24, 37, 'bold', '#005f87', '#00afaf'], []]
\ , 'FileType' : [[ 24, 81, 'none', '#005f87', '#5fd7ff'], []]
\ , 'LinePercentS' : [[ 24, 31, 'bold', '#005f87', '#0087af'], []]
\ , 'LinePercent' : [[ 31, 117, 'none', '#0087af', '#87d7ff'], []]
\ , 'LineNumberS' : [[ 31, 117, 'bold', '#0087af', '#87d7ff'], []]
\ , 'LineNumber' : [[ 117, 23, 'bold', '#87d7ff', '#005f5f'], []]
\ , 'LineColumn' : [[ 117, 31, 'none', '#87d7ff', '#0087af'], []]
\ }
\ }
" }}}
" Default statusline {{{
let g:default_stl = ""
let g:default_stl .= "<CUR>#[Mode] %{&paste ? 'PASTE [>] ' : ''}%{strtrans(mode())} #[ModeS][>>]</CUR>"
let g:default_stl .= "#[Branch] %(%{exists('*fugitive#statusline') ? substitute(fugitive#statusline(), '\\[GIT(\\([a-z0-9\\-_\\./:]\\+\\))\\]', ' \\1', 'gi') : ''}#[BranchS] [>]%)" " Git branch
let g:default_stl .= "#[ModFlag]%{&readonly ? ' ' : ''}#[FileName] %t " " File name
let g:default_stl .= "#[ModFlag]%(%M %)" " Modified flag
let g:default_stl .= "#[BufFlag]%(%H%W %)" " HLP,PRV flags
let g:default_stl .= "#[FileNameS]<CUR>[>>]</CUR>" " Separator
let g:default_stl .= "#[FunctionName] " " Padding/HL group
let g:default_stl .= "%<" " Truncate right
let g:default_stl .= "%= " " Right align
let g:default_stl .= "<CUR>#[FileFormat]%{&fileformat} %{WebDevIconsGetFileFormatSymbol()} </CUR>" " File format
let g:default_stl .= "<CUR>#[FileEncoding]%{(&fenc == '' ? &enc : &fenc)} </CUR>" " File encoding
let g:default_stl .= "<CUR>#[Separator][<] %{WebDevIconsGetFileTypeSymbol()} #[FileType]%{strlen(&ft) ? &ft : 'n/a'} </CUR>" " File type
let g:default_stl .= "<CUR>#[LinePercentS][<<]#[LinePercent]</CUR> %p%% " " Line percentage
let g:default_stl .= "#[LineNumberS]<CUR>[<<]</CUR><NCUR>[<] </NCUR>#[LineNumber]"
let g:default_stl .= " %l#[LineColumn]:%c%V%{&ft =~ 'csv' ? ' C:'.CSV_WCol() : ''} " " Line/column/virtual column, Line percentage
" }}}
call <SID>StatusLineColors(s:statuscolors) " Make the status line become colorful on sourcing after startup
" }}}
augroup CustomStatusLines " {{{
au!
" Custom Status Lines {{{
" Tagbar {{{
au BufEnter __Tagbar__* if !exists('b:stl')
\ | let b:stl = "#[FileName] Tagbar <NCUR>[>]</NCUR>#[FileNameS]<CUR>[>>]</CUR>#[FunctionName] %{g:tagbar_sort ? 'Name' : 'Declaration'}%<%=#[LinePercentS]<CUR>[<<]</CUR>#[LinePercent] %p%% "
\ | endif
au FileType vista,vista_kind nnoremap <buffer> <silent> / :<c-u>call vista#finder#fzf#Run()<CR>
au BufEnter __vista__* if !exists('b:stl')
\ | let b:stl = "#[FileName] Vista <NCUR>[>]</NCUR>#[FileNameS]<CUR>[>>]</CUR>#[FunctionName] %{get(g:vista.source, 'fname', '')}%<%=#[LinePercentS]<CUR>[<<]</CUR>#[LinePercent] %p%% "
\ | endif
" }}}
" Splie HUD {{{
au BufEnter __Splice_HUD__ if !exists('b:stl')
\ | let b:stl = "#[FileName] Splice HUD #[FileNameS][>>]%<%="
\ | endif
" }}}
" Quickfix {{{
au BufWinEnter quickfix if !exists('b:stl')
\ | set statusline=
\ | let b:stl = "#[FileName] Quickfix <NCUR>[>]</NCUR>#[FileNameS]<CUR>[>>]</CUR>#[FunctionName]%<%=#[LinePercentS]<CUR>[<<]</CUR>#[LinePercent] %l "
\ | endif
\ | nnoremap <buffer> q :q<CR>
" }}}
" DadBod {{{
au BufEnter dbui if !exists('b:stl')
\ | let b:stl = "#[FileName] DB <NCUR>[>]</NCUR>#[FileNameS]<CUR>[>>]</CUR>#[FunctionName]%<%=#[LinePercentS]<CUR>[<<]</CUR>#[LinePercent] %l "
\ | endif
au BufEnter *.dbout if !exists('b:stl')
\ | let b:stl = "#[FileName] Result <NCUR>[>]</NCUR>#[FileNameS]<CUR>[>>]</CUR>%{b:db}#[FunctionName]%<%=#[LinePercentS]<CUR>[<<]</CUR>#[LinePercent] %l "
\ | endif
" }}}
" Scratch {{{
au BufEnter __Scratch__ if !exists('b:stl')
\ | let b:stl = "<CUR>#[Mode] %{&paste ? 'PASTE [>] ' : ''}%{strtrans(mode())} #[ModeS][>>]</CUR>#[FileName] Scratch <NCUR>[>]</NCUR>#[FileNameS]<CUR>[>>]</CUR>#[FunctionName]%<%=#[LinePercentS]<CUR>[<<]</CUR>#[LinePercent] %p%% #[LineNumberS]<CUR>[<<]</CUR><NCUR>[<] </NCUR>#[LineNumber] %l#[LineColumn]:%c%V"
\ | endif
\ | setlocal nobuflisted
\ | imap <expr><buffer> <Return> exists('b:pane_id') ? "<Esc><S-v>mso" : "<Return>"
\ | nnoremap <expr><buffer><silent> <Return> exists('b:pane_id') ? "<S-v>\"my:TxSend(@m)<CR>" : "<Return>"
" }}}
" UndoTree {{{
au WinEnter undotree_* if !exists('b:stl')
\ | set statusline=
\ | let b:stl = "#[FileName] UndoTree <NCUR>[>]</NCUR>#[FileNameS]<CUR>[>>]</CUR>#[FunctionName]%<%=#[LinePercent]"
\ | endif
au WinEnter diffpanel_* if !exists('b:stl')
\ | set statusline=
\ | let b:stl = "#[FileName] Changes <NCUR>[>]</NCUR>#[FileNameS]<CUR>[>>]</CUR>#[FunctionName]%<%=#[LinePercent]"
\ | endif
" }}}
" }}}
" Main Statusline Highlighting {{{
" These need to happen after the above form them to take effect
au ColorScheme * call <SID>StatusLineColors(s:statuscolors)
au BufEnter,BufWinEnter,WinEnter,CmdwinEnter,CursorHold,BufWritePost,InsertLeave * call <SID>StatusLine((exists('b:stl') ? b:stl : g:default_stl), 'Normal', 1)
au BufLeave,BufWinLeave,WinLeave,CmdwinLeave * call <SID>StatusLine((exists('b:stl') ? b:stl : g:default_stl), 'Normal', 0)
au InsertEnter,CursorHoldI * call <SID>StatusLine((exists('b:stl') ? b:stl : g:default_stl), 'Insert', 1)
"}}}
augroup END " }}}
augroup GitShortcuts " {{{
au!
autocmd FileType gitrebase
\ nnoremap <buffer> p :Pick<CR>|
\ nnoremap <buffer> s :Squash<CR>|
\ nnoremap <buffer> e :Edit<CR>|
\ nnoremap <buffer> r :Reword<CR>|
\ nnoremap <buffer> f :Fixup<CR>|
\ nnoremap <buffer> <C-j> :m +1<CR>|
\ nnoremap <buffer> <C-k> :m -2<CR>
autocmd BufNewFile,BufReadPost * if !empty(FugitiveGitDir()) |
\ nnoremap <silent> <buffer> <Leader>gs :Git<CR>|
\ nnoremap <silent> <buffer> <Leader>gc :Git commit<CR>|
\ nnoremap <silent> <buffer> <Leader>gw :Gwrite!<CR>:redraw!<CR>|
\ nnoremap <silent> <buffer> <Leader>gl :Glog<CR>|
\ nnoremap <silent> <buffer> <Leader>gd :call <SID>GdiffToggle()<CR>|
\ nnoremap <silent> <Leader>gv :Git log <CR>
\ endif
" \ nnoremap <silent> <Leader>gV :Gitv! --all<CR>
autocmd FileType gitcommit setlocal spell
function! s:GdiffToggle()
if !&diff
Gdiff
else
if bufname('#') =~ '^fugitive:'
exec bufwinnr('#').'wincmd w'
endif
bd
endif
endfunction
" Make running git easier
cabbrev git <C-R>=(getcmdtype() == ':' && getcmdpos() == 1 ? 'Git' : 'git')<CR>
augroup END " }}}
augroup RailsShortcuts " {{{
au!
autocmd User Rails
\ map <buffer> <Leader>grm :Emodel |
\ map <buffer> <Leader>grc :Econtroller |
\ map <buffer> <Leader>grv :Eview |
\ map <buffer> <Leader>gvl :Elayout |
\ map <buffer> <Leader>gll :Elib |
\ map <buffer> <Leader>gut :Eunittest |
\ map <buffer> <Leader>grd :Emigration |
\ map <buffer> <Leader>gft :Efunctionaltest |
\ map <buffer> <Leader>git :Eintegrationtest |
\ map <buffer> <Leader>grs :Espec |
\ map <buffer> <Leader>gre :Eenvironment |
\ map <buffer> <Leader>grt :Etask |
\ map <buffer> <Leader>gro :Eobserver |
\ map <buffer> <Leader>grj :Ejavascript |
\ map <buffer> <Leader>gri :Einitializer |
\ map <buffer> <Leader>grl :Elocale |
\ map <buffer> <Leader>grh :Ehelper |
\ map <buffer> <Leader>gam :Emailer |
\ :Rnavcommand job app/jobs -glob=**/* |
\ map <buffer> <Leader>gbj :Rjob |
" automatically make the current working directory be the repo root
autocmd BufEnter,BufWinEnter * if exists("b:git_dir") | silent! Glcd | endif
autocmd FileType cucumber set expandtab
augroup END " }}}
augroup RubyTestHighlighting " {{{
au!
autocmd BufNewFile,BufReadPre *_test.rb syn keyword rubyTestMethod assert assert_block assert_equal assert_in_delta assert_instance_of assert_kind_of assert_match assert_nil assert_no_match assert_not_equal assert_not_nil assert_not_same assert_nothing_raised assert_nothing_thrown assert_operator assert_raise assert_respond_to assert_same assert_send assert_throws flunk assert_difference assert_no_difference assert_named_route tests
augroup END "}}}
else
" Custom status line using to show git branch info, has ruler set
set statusline=%<%f\ %h%m%r%{exists('*fugitive#statusline') ? fugitive#statusline() : ''}%=%-14.(%c%V,%l/%L%)\ %P\ %y
endif
" Folding Config {{{
if has("folding")
function! SimpleFold() " {{{
let line = getline(v:foldstart)
let nucolwidth = &foldcolumn + (&number + &relativenumber) * &numberwidth
if &textwidth != 0 && winwidth(0) > &textwidth
let windowwidth = &textwidth
else
let windowwidth = winwidth(0) - nucolwidth - 3
endif
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 1 - len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
return line . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
endfunction " }}}
set foldtext=SimpleFold()
set foldcolumn=0
set foldenable
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()
set foldlevelstart=99 " How far down fold tree to go before folding code on opening file
set foldnestmax=10
set foldminlines=1
" Make folding not effect insert by disabling it in insert mode
augroup FoldingInsert
autocmd!
" Start with all fold open and foldlevel set to max for file
autocmd Syntax * normal zR
" Make folding not effect insert by disabling it in insert mode
autocmd InsertEnter *
\ if !exists('w:last_fdm') |
\ let w:last_fdm = &foldmethod |
\ setlocal foldmethod=manual |
\ endif
autocmd InsertLeave,WinLeave *
\ if exists('w:last_fdm') |
\ let &l:foldmethod = w:last_fdm |
\ unlet w:last_fdm |
\ endif
autocmd BufNewFile * setlocal foldlevel=99
augroup END
nnoremap <Space> za
vnoremap <Space> za
endif
" }}}
function! s:MyFollowSymlink(...)
let fname = fnameescape(a:0 ? a:1 : expand('%'))
if getftype(fname) == 'link'
bwipeout #
exec 'silent! edit ' . fnameescape(fnamemodify(resolve(fname), ':p'))
endif
endfunction
command! FollowSymlink call <SID>MyFollowSymlink()
" HTML5 Vim Settings {{{
let g:event_handler_attributes_complete = 0
let g:rdfa_attributes_complete = 0
let g:microdata_attributes_complete = 0
let g:atia_attributes_complete = 0
" }}}
" Ruby Syntax and Completion {{{
let g:ruby_operators = 1
let g:rubycomplete_rails = 1
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_include_object = 1
let g:rubycomplete_include_objectspace = 1
let g:rails_statusline = 0
" }}}
" delimitMate settings {{{
let g:delimitMate_expand_space = 1
let g:delimitMate_expand_cr = 1
let g:delimitMate_balance_matchpairs = 1
" Allow for quick jumping over delimiters instead of S-Tab
inoremap <silent><expr> ; delimitMate#ShouldJump() ? "<C-R>=delimitMate#JumpAny(';')<CR>" : ";"
" }}}
" Tagbar - the better taglist {{{
let g:vista_sidebar_width = 40
let g:vista_echo_cursor_strategy = "floating_win"
let g:vista_stay_on_open = 1
let g:vista_disable_statusline = 1
let g:vista#renderer#enable_icon = 0
let g:vista_close_on_jump = 1
let g:vista_enable_centering_jump = 0
let g:vista_default_executive = 'nvim_lsp'
let g:vista_finder_alternative_executives = ['ctags']
let g:vista_cursor_delay = 600
let g:tagbar_no_status_line = 1
" let g:tagbar_width = 40
" let g:tagbar_autoclose = 1
" let g:tagbar_autofocus = 1
" let g:tagbar_sort = 0
" let g:tagbar_compact = 1
" let g:tagbar_indent = 1
set tags=./tags,tags
" Add support for markdown files in tagbar.
" let g:tagbar_type_markdown = {
" \ 'ctagstype': 'markdown',
" \ 'ctagsbin' : expand('~/.dotfiles/vim/markdown2ctags.py'),
" \ 'ctagsargs' : '-f - --sort=yes',
" \ 'kinds' : [
" \ 's:sections',
" \ 'i:images'
" \ ],
" \ 'sro' : '|',
" \ 'kind2scope' : {
" \ 's' : 'section',
" \ },
" \ 'sort': 0,
" \ }
" Make accessing the taglist easier
" nnoremap <silent> <Leader>ll :TagbarToggle<CR>
nnoremap <silent> <Leader>ll :Vista!!<CR>
" }}}
" Undotree settings {{{
nnoremap <silent> <F5> :UndotreeToggle<CR>
let g:undotree_SplitWidth = 50
let g:undotree_SetFocusWhenToggle = 1
" }}}
" CtrlP Settings {{{
" let g:ctrlp_prompt_mappings = { 'MarkToOpen()': ['<c-z>'] }
" Open files in current window
let g:ctrlp_open_new_file = 'r'
let g:ctrlp_open_multiple_files = 'vr'
let g:ctrlp_extensions = ['commandline']
" Default to searching from current files dir if not subdirectory of repo
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_user_command = {
\ 'types': {
\ 1: ['.git/', 'git --git-dir=%s/.git ls-files --others --cached --exclude-standard'],
\ 2: ['.hg/', 'hg --cwd %s status -numac -I . $(hg root)'],
\ },
\ 'fallback': 'find %s -type f'
\ }
if has('nvim')
nnoremap <silent> <Leader>o <cmd>Telescope buffers<CR>
nnoremap <silent> <Leader>p <cmd>Telescope find_files<CR>
nnoremap <silent> <leader>s <cmd>Telescope live_grep<CR>
nnoremap <silent> <leader>c <cmd>Telescope command_history<CR>
nnoremap <silent> <leader>m <cmd>Telescope man_pages<CR>
else
map <silent> <Leader>o :<C-U>CtrlPBuffer<CR>
map <silent> <Leader>m :<C-U>CtrlPMixed<CR>
map <silent> <Leader>p :<C-U>CtrlP<CR>
map <silent> <Leader>c :<C-U>CtrlPCommandline<CR>
command! CtrlPCommandline call ctrlp#init(ctrlp#commandline#id())
endif
" }}}
" UltiSnips settings {{{
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" }}}
" Markdown settings {{{
if has('macunix')
nnoremap <silent> <Leader>M :call system('open -g -F -a "Marked 2" '.shellescape(expand('%:p')))<CR>
endif
" }}}
" Scratch buffer mapping {{{
function! s:ScratchToggle() " {{{
if bufname('%') == '__Scratch__'
exec 'q'
else
exec "silent! normal! :Sscratch\<CR>\<C-W>J:resize 13\<CR>"
endif
endfunction
" }}}
noremap <silent> <Leader><Tab> :call <SID>ScratchToggle()<CR>
" }}}
" Objc {{{
let g:clang_use_library = 1
" let g:clang_library_path = expand($LPKG_PREFIX . '/lib')
let g:clang_complete_macros = 1 " Allow preprocessor directives to complete
let g:clang_complete_patterns = 0 " Don't complete clang snippets
let g:clang_snippets_engine = 'ultisnips'
let g:filetype_m = 'objc' " default to .m files being objc
" }}}
" GPG Configuraton {{{
let g:GPGExecutable = 'gpg'
let g:GPGDefaultRecipients = ['cehoffman@gmail.com']
let g:GPGUsePipes = 1
" }}}
" Terraform {{{
let g:terraform_align = 1
autocmd FileType terraform setlocal commentstring=#\ %s
" }}}
" Node conviences {{{
let g:js_indent_flat_switch = 1
" }}}
" Common projectionist mappings {{{
nnoremap <silent> <leader>d :Dispatch<CR><CR>
nnoremap <silent> <leader>qq :ccl<CR>
map geu :Eunittest |
map gem :Emodel |
map gec :Econtroller |
map gei :Eintegrationtest |
let g:projectionist_heuristics = {
\ "mix.exs": {
\ "lib/*.ex": {
\ "alternate": "test/{}_test.exs",
\ "type": "lib"
\ },
\ "test/*_test.exs": {
\ "alternate": "lib/{}.ex",
\ "type": "unittest"
\ },
\ "mix.exs": {
\ "type": "mix"
\ }
\ },
\ "go.mod": {
\ "*.go": {
\ "type": "go",
\ "alternate": "{}_test.go"
\ },
\ "*_test.go": {
\ "type": "test",
\ "alternate": "{}.go"
\ },
\ "go.mod": {
\ "type": "mod"
\ }
\ }
\}
" }}}
" Window Management {{{
" Open a yanked window {{{
function! s:HOpen(dir,what_to_open)
let [type,name] = a:what_to_open
if a:dir == 'left' || a:dir == 'right'
vsplit
elseif a:dir == 'up' || a:dir == 'down'
split
end
if a:dir == 'down' || a:dir == 'right'
exec "normal! \<C-W>\<C-W>"
end
if type == 'buffer'
exec 'buffer '.name
else
exec 'edit '.name
end
endfunction
" }}}
" Yank a window {{{
function! s:HYankWindow()
let s:window = winnr()
let s:buffer = bufnr('%')
let s:bufhidden = &bufhidden
endfunction
" }}}
" Delete a window {{{
function! s:HDeleteWindow()
call <SID>HYankWindow()
set bufhidden=hide
close
endfunction
" }}}
" Paste window in position {{{
function! s:HPasteWindow(direction)
let old_buffer = bufnr('%')
call <SID>HOpen(a:direction,['buffer',s:buffer])
let s:buffer = old_buffer
let &bufhidden = s:bufhidden
endfunction
" }}}
" Key Mappings {{{
" Copy/Pasting buffers to windows around
noremap <silent> <Leader>wd :call <SID>HDeleteWindow()<cr>
noremap <silent> <Leader>wy :call <SID>HYankWindow()<cr>
noremap <silent> <Leader>wpk :call <SID>HPasteWindow('up')<cr>
noremap <silent> <Leader>wpj :call <SID>HPasteWindow('down')<cr>
noremap <silent> <Leader>wph :call <SID>HPasteWindow('left')<cr>
noremap <silent> <Leader>wpl :call <SID>HPasteWindow('right')<cr>
noremap <silent> <Leader>wpp :call <SID>HPasteWindow('here')<cr>
noremap <silent> <Leader>wP :call <SID>HPasteWindow('here')<cr>
" Make moving between windows easy
noremap <C-J> <C-W>j
noremap <C-H> <C-W>h
noremap <C-K> <C-W>k
noremap <C-L> <C-W>l
tmap <C-J> <C-\><C-N><C-J>
tmap <C-H> <C-\><C-N><C-H>
tmap <C-K> <C-\><C-N><C-K>
tmap <C-L> <C-\><C-N><C-L>
tnoremap <Leader><Leader> <C-\><C-N><C-^>
" Opens a vertical window and moves to it
nnoremap <silent> <Leader>nv :vsplit<CR><C-W><C-W>
" Opens a horizontal split window and moves to it
nnoremap <silent> <Leader>ns :split<CR><C-W><C-W>
" Open a new blank tab
nnoremap <silent> <Leader>nt :tabnew<CR>
" Open current window in new tab
nnoremap <Leader>nT <C-W>T
" }}}
" }}}
" Custom Functions {{{
" Trim trailing whitespace {{{