forked from hit-ybai/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
954 lines (850 loc) · 30 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
"
" Author: Larry Lv <[email protected]>
" Last Modified: Jun 22, 2016
"
" Plugins -------------------------------------------------------------
" Load plugins {{{
filetype off
call plug#begin('~/.vim/bundle')
" Code Complete Engine
if !has('nvim')
Plug 'Valloric/YouCompleteMe' ", { 'do': './install.py --clang-completer' }
else
function! DoRemote(arg)
UpdateRemotePlugins
endfunction
Plug 'Shougo/deoplete.nvim', { 'do': function('DoRemote') }
let g:deoplete#enable_at_startup = 1
endif
Plug 'vim-ruby/vim-ruby'
Plug 'elixir-lang/vim-elixir', { 'for': ['elixir', 'eelixir'] }
Plug 'slashmili/alchemist.vim', { 'for': ['elixir', 'eelixir'] }
Plug 'larrylv/ycm-elixir', { 'for': ['elixir', 'eelixir'] }
Plug 'vim-erlang/vim-erlang-runtime', { 'for': 'erlang' }
Plug 'vim-erlang/vim-erlang-compiler', { 'for': 'erlang' }
Plug 'vim-erlang/vim-erlang-omnicomplete', { 'for': 'erlang' }
Plug 'vim-erlang/vim-erlang-tags', { 'for': 'erlang' }
Plug 'ten0s/syntaxerl', { 'for': 'erlang' }
Plug 'guns/vim-clojure-static', { 'for': 'clojure' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Plug 'guns/vim-sexp', { 'for': 'clojure' }
Plug 'elmcast/elm-vim', { 'for': 'elm' }
Plug 'fatih/vim-go', { 'for': 'go' }
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
Plug 'kchmck/vim-coffee-script', { 'for': ['javascript', 'coffee'] }
Plug 'mxw/vim-jsx', { 'for': 'javascript' }
Plug 'othree/html5.vim', { 'for': 'html'}
Plug 'mustache/vim-mustache-handlebars', { 'for': ['html.mustache', 'html.handlebars'] }
Plug 'hail2u/vim-css3-syntax', { 'for': ['css', 'sass', 'scss'] }
Plug 'ap/vim-css-color', { 'for': ['css', 'sass', 'scss'] }
Plug 'groenewege/vim-less', { 'for': 'less' }
Plug 'tpope/vim-haml', { 'for': 'haml' }
Plug 'cakebaker/scss-syntax.vim', { 'for': 'scss' }
Plug 'tpope/vim-markdown', { 'for': 'markdown' }
Plug 'larrylv/ShowMarks'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'ivalkeen/vim-ctrlp-tjump'
Plug 'tpope/vim-ragtag'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-obsession'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-vinegar'
Plug 'tpope/vim-rbenv'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rsi'
Plug 'SirVer/ultisnips'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/syntastic'
Plug 'tomtom/tcomment_vim'
Plug 'skalnik/vim-vroom'
Plug 'honza/vim-snippets'
Plug 'janko-m/vim-test'
Plug 'terryma/vim-multiple-cursors'
Plug 'mileszs/ack.vim'
Plug 'itchyny/lightline.vim'
Plug 'tudorprodan/html_annoyance.vim'
Plug 'majutsushi/tagbar'
Plug 'airblade/vim-gitgutter'
Plug 'ervandew/supertab'
Plug 'kana/vim-textobj-user'
Plug 'nelstrom/vim-textobj-rubyblock'
" Plug 'jwhitley/vim-colors-solarized'
Plug 'lifepillar/vim-solarized8'
Plug 'Raimondi/delimitMate'
Plug 'mattn/webapi-vim'
Plug 'mattn/gist-vim'
Plug 'benmills/vimux'
Plug 'eapache/rainbow_parentheses.vim'
Plug 'jlanzarotta/bufexplorer'
Plug 'vim-scripts/matchit.zip'
Plug 'vim-scripts/BufOnly.vim'
Plug 'thinca/vim-ref'
Plug 'mhinz/vim-startify'
Plug 'powerman/vim-plugin-AnsiEsc'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'junegunn/vim-easy-align'
" Add plugins to &runtimepath
call plug#end()
filetype plugin indent on
" }}}
" Settings ------------------------------------------------------------
runtime! plugin/sensible.vim
" Mapleader {{{
let mapleader=","
" }}}
" Make vim more useful {{{
if !has('nvim')
set nocompatible
endif
" }}}
" Syntax highlighting {{{
set t_Co=256
syntax on
" jwhitley/vim-colors-solarized
" let g:solarized_termtrans = 1
" let g:solarized_termcolors = 256
" let g:solarized_visibility = "high"
" let g:solarized_contrast = "high"
" set background=dark
" colorscheme solarized
" lifepillar/vim-solarized8
set background=dark
colorscheme solarized8_dark_flat
" dirty patch
hi! CursorLine cterm=NONE gui=NONE ctermfg=NONE guifg=NONE ctermbg=237 guibg=#3c3d3a
" }}}
" Set some junk"{{{
set ambiwidth=double
set autoindent " Copy indent from last line when starting new line
set autoread " Reload files changed outside automatically
set backspace=indent,eol,start " Allow backspacing over everything in insert mode
set cindent
set complete=.,w,b,u,t,i
set completeopt=longest,menu
" set cursorline " Highlight current line
set diffopt+=iwhite " Ignore whitespaces with vimdiff
set diffopt=filler " Add vertical spaces to keep right and left aligned
if !has('nvim')
set encoding=utf-8 nobomb " BOM often causes trouble
endif
set expandtab " Expand tabs to spaces
set fileencoding=utf-8
set fileencodings=utf-8,ucs-bom,chinese
set foldcolumn=0 " Column to show folds
set foldenable " Enable folding
" set foldlevel=0 " Close all folds by default
set foldlevelstart=99 " Open all folds by default
set foldmethod=marker " Syntax are used to specify folds
set foldminlines=0 " Allow folding single lines
set foldnestmax=5 " Set max fold nesting level
set formatoptions=
set formatoptions+=1 " Break before 1-letter words
set formatoptions+=2 " Use indent from 2nd line of a paragraph
" set formatoptions+=c " Format comments
set formatoptions+=l " Don't break lines that are already long
set formatoptions+=n " Recognize numbered lists
" set formatoptions+=o " Make comment when using o or O from comment line
set formatoptions+=q " Format comments with gq
" set formatoptions+=r " Continue comments by default
set history=1000 " Increase history from 20 default to 1000
set hlsearch " Highlight searches
set ignorecase " Ignore case of searches
set incsearch " Highlight dynamically as pattern is typed
set laststatus=2 " Always show status line
set lazyredraw " Don't redraw when we don't have to
set magic " Enable extended regexes
set modeline
set nobackup
set noerrorbells " Disable error bells
set nojoinspaces " Only insert single space after a '.', '?' and '!' with a join command
set noshowmode " Don't show the current mode (airline.vim takes care of us)
set nostartofline " Don't reset cursor to start of line when moving around
set notitle
set nu " Enable line numbers
set omnifunc=syntaxcomplete#Complete " Set omni-completion method
set regexpengine=1
set relativenumber
set ruler " Show the cursor position
set scrolloff=3 " Start scrolling three lines before horizontal border of window
set shiftwidth=2 " The # of spaces for indenting
set shortmess=atI " Don't show the intro message when starting vim
set showcmd " display incomplete commands
set smartcase " Ignore 'ignorecase' if search patter contains uppercase characters
set smarttab " At start of line, <Tab> inserts shiftwidth spaces, <Bs> deletes shiftwidth spaces
set softtabstop=2 " Tab key results in 2 spaces
set splitbelow " New window goes below
set splitright " New windows goes right
set tabstop=2
set tags=./tags;
set timeout timeoutlen=1000 ttimeoutlen=0 " No delay for entering normal mode
if !has('nvim')
set ttyfast " Send more characters at a given time
endif
set undodir=~/.vim/.undo
set undofile " Persistent Undo
set undolevels=1000
set undoreload=10000
set wildchar=<Tab> " Character for CLI expansion (TAB-completion)
set wildmenu " Hitting TAB in command mode will show possible completions above command line
set wildmode=list:longest " Complete only until point of ambiguity
set wrap " Wrap lines that are too long
set wrapscan " Searches wrap around end of file
set wildignore+=**/*.jpg,*.jpeg,*.gif,**/*.png,*.gif,*.psd,*.o,*.obj,*.min.js
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.sass-cache/*
if has('nvim')
" Get cmd+c work
set mouse=
" Switch cursor shape when using NeoVim
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 ""
" Bring back ctrl-h
nmap <BS> <C-W>h
endif
"}}}
" Configurations ------------------------------------------------------
" Leader Shortcuts"{{{
nnoremap <leader><leader> <c-^>
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>cc :ccl<cr>
map <leader>cn :cn<cr>
map <leader>cp :cp<cr>
" CtrlP
map <leader>dc :CtrlP app/controllers<cr>
map <leader>dh :CtrlP app/helpers<cr>
map <leader>dm :CtrlP app/models<cr>
map <leader>ds :CtrlP spec<cr>
map <leader>dt :CtrlP test<cr>
map <leader>dv :CtrlP app/views<cr>
" vim-projectionist && vim-rails
map <leader>ec :Econtroller
map <leader>ed :Eschema<cr>
map <leader>ef :Efixtures
map <leader>eg :Emigration<cr>
map <leader>eh :Ehelper
map <leader>ej :Ejavascript
map <leader>em :Emodel
map <leader>en :Echannel
map <leader>ep :Etemplate
map <leader>es :Espec
map <leader>et :Etest
map <leader>eu :Eunittest
map <leader>ev :Eview
" gitgutter.vim
map <leader>ga :GitGutterStageHunk<cr>
map <leader>gn :GitGutterNextHunk<cr>
map <leader>gp :GitGutterPrevHunk<cr>
map <leader>gu :GitGutterUndoHunk<cr>
map <leader>gv :GitGutterPreviewHunk<cr>
" splitjoin.vim
nmap <leader>kj :SplitjoinJoin<cr>
nmap <leader>ks :SplitjoinSplit<cr>
map <leader>p :echo @%<cr>
map <leader>q :BufOnly<cr>
" provided by vim-rails
map <leader>sd :Sschema<cr>
map <leader>sg :sp Gemfile<cr>
map <leader>so :source $MYVIMRC<cr>
map <leader>sr :sp config/routes.rb<cr>
map <leader>ss :source ./Session.vim<cr>
map <leader>sj :stjump
map <leader>st :stselect
" vim-easy-align
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap <leader>ta <Plug>(EasyAlign)
" Start interactive EasyAlign in visual and select mode (e.g. gaip)
vmap <leader>ta <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap <leader>ta <Plug>(EasyAlign)
xmap <leader>t= <Plug>(EasyAlign) =
vmap <leader>t= <Plug>(EasyAlign) =
nmap <leader>t= <Plug>(EasyAlign) =
xmap <leader>t: <Plug>(EasyAlign) :
vmap <leader>t: <Plug>(EasyAlign) :
nmap <leader>t: <Plug>(EasyAlign) :
map <leader>vr :tabe ~/.vimrc<CR>
" system yank: will copy into the system clipboard on OS X
vmap <leader>y :w !reattach-to-user-namespace pbcopy<CR><CR>
map <leader>z :CtrlPClearCache<cr>
" Search and replace word under cursor (,*)
nnoremap <leader>* :%s/\<<C-r><C-w>\>//<Left>
vnoremap <leader>* "hy:%s/\V<C-r>h//<left>
"}}}
" General"{{{
augroup general_config
autocmd!
" Better split switching (Ctrl-j, Ctrl-k, Ctrl-h, Ctrl-l, Ctrl-p) {{{
map <C-k> <C-W>k
map <C-j> <C-W>j
map <C-l> <C-W>l
map <C-h> <C-W>h
map <C-\> <C-W>p
" }}}
" Clear last search (Ctrl-n, ,h) {{{
map <silent> <C-n> <Esc>:nohlsearch<CR>
" }}}
" Remap keys for auto-completion menu {{{
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" }}}
" Paste toggle (<F3>) {{{
nnoremap <F3> :set invpaste paste?<CR>
set pastetoggle=<F3>
" }}}
" Yank from cursor to end of line {{{
nnoremap Y y$
" }}}
" Strip trailing whitespace (<F4>) {{{
nnoremap <silent> <F4> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" }}}
" Show git diff in tab"{{{
command! GdiffInTab tabedit %|vsplit|Gdiff
"}}}
" Generate ctags (<F5>)"{{{
map <F5> :!ctags -R --languages=-javascript --exclude=.git --exclude=log --exclude=target --fields=+ialS --extra=+q .<CR>
"}}}
" Remap <ESC> (jj) (Ctrl-c)"{{{
imap <c-c> <ESC>l
imap jj <ESC>l
"}}}
" Insert hash rocket (Ctrl-h)"{{{
imap <c-h> =><space>
"}}}
" Remap increase number (Ctrl-i)"{{{
" <c-a> is prefix for tmux
map <c-i> <c-a>
"}}}
" Quick move under insert mode (Ctrl-f, Ctrl-b)"{{{
imap <c-f> <c-o>w
imap <c-b> <c-o>b
"}}}
" Adjust window height"{{{
au FileType qf call AdjustWindowHeight(3, 10)
function! AdjustWindowHeight(minheight, maxheight)
exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _"
endfunction
"}}}
" Insert the current time (InsertTime)"{{{
command! InsertTime :normal a<c-r>=strftime('%F %H:%M:%S')<cr>
"}}}
" Highlight trailing whitespace"{{{
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
"}}}
" Remember last location when open a file"{{{
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
function! ResCur()
let filetype = &ft
if (line("'\"") <= line("$") && filetype != 'gitcommit')
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
"}}}
" Set local omnifunc"{{{
autocmd FileType ruby,eruby setlocal omnifunc=rubycomplete#Complete
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown,mkd setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
"}}}
" Only use cursorline in current window and not when being in insert mode
autocmd WinEnter * set cursorline
autocmd WinLeave * set nocursorline
autocmd InsertEnter * set nocursorline
autocmd InsertLeave * set cursorline
" Set tab to 4-space for elm files
autocmd FileType elm set ai ts=4 sw=4 sts=4 et
" Disable auto comment insertion
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
augroup END
"}}}
" Tagbar"{{{
nmap <F2> :TagbarToggle<CR>
let g:tagbar_sort = 0
let g:tagbar_iconchars = ['+', '-']
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent -R'
\ }
let g:tagbar_type_elixir = {
\ 'ctagstype': 'elixir',
\ 'kinds' : [
\ 'm:modules',
\ 'f:functions',
\ 'c:callbacks',
\ 'd:delegates',
\ 'e:exceptions',
\ 'i:implementations',
\ 'a:macros',
\ 'o:operators',
\ 'p:protocols',
\ 'r:records',
\ ]
\ }
"}}}
" Supertab"{{{
let g:SuperTabDefaultCompletionType = "<c-n>"
" <C-e>: stop completion and go back to the originally typed text
"}}}
" vim-gitgutter"{{{
" vim-gitgutter will use Sign Column to set its color, reload it.
call gitgutter#highlight#define_highlights()
let g:gitgutter_max_signs = 1024
" let g:gitgutter_override_sign_column_highlight = 0
let g:gitgutter_sign_column_always = 1
"}}}
" vim-projectionist"{{{
let g:projectionist_heuristics = {
\ "web/": {
\ "web/channels/*.ex": {
\ "type": "channel",
\ "alternate": "test/channels/{}_test.exs"
\ },
\ "web/controllers/*.ex": {
\ "type": "controller",
\ "alternate": "test/controllers/{}_test.exs"
\ },
\ "web/models/*.ex": {
\ "type": "model",
\ "alternate": "test/models/{}_test.exs"
\ },
\ "web/views/*.ex": {
\ "type": "view",
\ "alternate": "test/views/{}_test.exs"
\ },
\ "web/templates/*.html.eex": {
\ "type": "template",
\ },
\ "web/static/css/*": {
\ "type": "stylesheet",
\ },
\ "web/static/js/*": {
\ "type": "javascript",
\ },
\ },
\ "test/": {
\ "test/channels/*_test.exs": {
\ "type": "test",
\ "alternate": "web/channels/{}.ex",
\ "dispatch": "mix test --color {file}"
\ },
\ "test/controllers/*_test.exs": {
\ "type": "test",
\ "alternate": "web/controllers/{}.ex",
\ "dispatch": "mix test --color {file}"
\ },
\ "test/models/*_test.exs": {
\ "type": "test",
\ "alternate": "web/models/{}.ex",
\ "dispatch": "mix test --color {file}"
\ },
\ "test/views/*_test.exs": {
\ "type": "test",
\ "alternate": "web/views/{}.ex",
\ "dispatch": "mix test --color {file}"
\ },
\ },
\ }
"}}}
" vim-ruby"{{{
let g:ruby_path = system('echo $HOME/.rbenv/shims')
"}}}
" test.vim"{{{
nmap <silent> <leader>ts :TestFile<CR>
nmap <silent> <leader>tn :TestNearest<CR>
nmap <silent> <leader>tl :TestLast<CR>
"}}}
" vroom.vim"{{{
let g:vroom_use_vimux=1
let g:vroom_map_keys=0
" Run the current file with vroom
map <leader>vs :VroomRunTestFile<CR>
" Runs the nearest test in the current file
map <leader>vn :VroomRunNearestTest<CR>
" Prompt for a command to run map
map <leader>vp :VimuxPromptCommand<CR>
" Run last command executed by VimuxRunCommand
map <leader>vl :VroomRunLastTest<CR>
" Inspect runner pane map
map <leader>vi :VimuxInspectRunner<CR>
" Close vim tmux runner opened by VimuxRunCommand
map <leader>vc :VimuxCloseRunner<CR>
" Interrupt any command running in the runner pane map
map <leader>vx :VimuxInterruptRunner<CR>
" when run unit test, also include current directory
" for bettern compatibility
if !exists("g:vroom_test_unit_command")
let g:vroom_test_unit_command = 'ruby -Itest -I.'
endif
"}}}
" bufexplorer"{{{
let g:bufExplorerShowTabBuffer=1 " BufExplorer: show only buffers relative to this tab
let g:bufExplorerShowRelativePath=1 " BufExplorer: show relative paths
"}}}
" Gist.vim"{{{
let g:gist_post_private = 1
let g:gist_show_privates = 1
let g:gist_open_browser_after_post = 1
let g:gist_detect_filetype = 1
"}}}
" ShowMarks.vim"{{{
let showmarks_enable = 1
let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
" Ignore help, quickfix, non-modifiable buffers
let showmarks_ignore_type = "hqm"
" Hilight lower & upper marks
let showmarks_hlline_lower = 1
let showmarks_hlline_upper = 1
hi ShowMarksHLl ctermbg=Yellow ctermfg=Black guibg=#FFDB72 guifg=Black
hi ShowMarksHLu ctermbg=Magenta ctermfg=Black guibg=#FFB3FF guifg=Black
"}}}
" Syntastic.vim"{{{
set statusline+=\ %#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" let g:syntastic_debug = 1
" let g:syntastic_ruby_checkers = [ 'rubocop', 'mri' ]
let g:syntastic_ruby_checkers = [ 'mri' ]
let g:syntastic_ruby_exec = "~/.rbenv/versions/2.3.0/bin/ruby"
let g:syntastic_ruby_mri_exec = "~/.rbenv/versions/2.3.0/bin/ruby"
let g:syntastic_shell_checkers = [ 'shellcheck' ]
let g:syntastic_javascript_checkers = [ 'jshint' ]
let g:syntastic_coffee_checkers = [ 'coffeelint' ]
let g:syntastic_html_checkers = [ 'jshint' ]
let g:syntastic_haml_checkers = [ 'haml_lint' ]
let g:syntastic_css_checkers = [ 'csslint' ]
let g:syntastic_json_checkers = [ 'jsonlint' ]
let g:syntastic_elixir_checkers = [ '' ]
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_cursor_column = 0
let g:syntastic_enable_highlighting = 0
let g:syntastic_enable_signs = 1
let g:syntastic_auto_jump = 0
let g:syntastic_mode_map = { 'mode': 'active',
\ 'passive_filetypes': ['tex', 'scss', 'slim'] }
let g:syntastic_error_symbol = '✗'
let g:syntastic_style_error_symbol = '✠'
let g:syntastic_warning_symbol = '∆'
" let g:syntastic_style_warning_symbol = '≈'
let g:syntastic_style_warning_symbol = '∆'
let g:syntastic_html_tidy_ignore_errors = [
\ 'trimming empty <i>',
\ 'trimming empty <span>',
\ '<input> proprietary attribute \"autocomplete\"',
\ 'proprietary attribute \"role\"',
\ 'proprietary attribute \"hidden\"',
\ 'proprietary attribute \"ng-',
\ '<svg> is not recognized!',
\ 'discarding unexpected <svg>',
\ 'discarding unexpected </svg>',
\ '<rect> is not recognized!',
\ 'discarding unexpected <rect>'
\ ]
"}}}
" Highlight Pmenu"{{{
highlight Pmenu guifg=#000000 guibg=#F8F8F8 ctermfg=black ctermbg=Lightgray
highlight PmenuSbar guifg=#8A95A7 guibg=#F8F8F8 gui=NONE ctermfg=darkcyan ctermbg=lightgray cterm=NONE
highlight PmenuThumb guifg=#F8F8F8 guibg=#8A95A7 gui=NONE ctermfg=lightgray ctermbg=darkcyan cterm=NONE
"}}}
" UltiSnips"{{{
let g:UltiSnipsExpandTrigger="<c-l>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:UltiSnipsUsePythonVersion = 2
"}}}
" ctrlp.vim"{{{
silent! nnoremap <unique> <silent> <leader>bb :CtrlPBuffer<CR>
silent! nnoremap <unique> <silent> <leader>cl :CtrlPClearCache<CR>
silent! nnoremap <unique> <silent> <leader>dt :CtrlPTag<CR>
silent! nnoremap <unique> <silent> <leader>f :CtrlP<CR>
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_by_filename = 0
let g:ctrlp_match_window = 'bottom,order:ttb,min:1,max:20,results:20'
let g:ctrlp_map = '<\-t>'
let g:ctrlp_max_files = 0
let g:ctrlp_working_path_mode = 0
let g:ctrlp_extensions = [ 'ctrlp-filetpe' ]
let g:ctrlp_follow_symlinks = 1
let g:ctrlp_switch_buffer = 0
let g:ctrlp_mruf_max = 0
let g:ctrlp_mruf_relative = 1
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("h")': ['<c-d>', '<c-cr>', '<c-e>'],
\ 'ToggleByFname()': ['<c-f>'],
\}
nnoremap <c-]> :CtrlPtjump<cr>
vnoremap <c-]> :CtrlPtjumpVisual<cr>
let g:ctrlp_custom_ignore = {
\ 'dir': '\v(_build|build|bower_components|deps|dist|node_modules|public|tmp|vendor\/bundle|elm-stuff)$',
\ }
" let g:ctrlp_tjump_only_silent = 1
"}}}
" rainbow_parentheses.vim"{{{
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
"}}}
" nerdtree"{{{
let NERDTreeWinSize = 30
let NERDTreeAutoCenter=1
let NERDTreeChDirMode=2
let g:NERDTreeMinimalUI=1
let g:NERDTreeHijackNetrw=1
let g:NERDTreeIgnore=['\~$']
map <F1> :call NERDTreeToggleInCurDir()<CR>
function! NERDTreeToggleInCurDir()
if (exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1)
exe ":NERDTreeClose"
else
exe ":NERDTreeFind"
endif
endfunction
"}}}
" ack.vim"{{{
if executable("ag")
" ,a to Ack (search in files)
nnoremap <leader>a :Ack
let g:ackprg="ag --nocolor --nogroup --column"
let g:ackhighlight=1
elseif executable("ack")
nnoremap <leader>a :Ack
let g:ackprg="ack --nocolor --nogroup --column"
let g:ackhighlight=1
endif
"}}}
" vim-ragtag"{{{
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = "li\|p"
"}}}
" Filetype detection"{{{
autocmd BufNewFile,BufRead Thorfile set filetype=ruby syntax=ruby
autocmd BufNewFile,BufRead *.thor set filetype=ruby syntax=ruby
autocmd BufNewFile,BufRead Gemfile set filetype=ruby syntax=ruby
autocmd BufNewFile,BufRead Capfile set filetype=ruby syntax=ruby
autocmd BufNewFile,BufRead pryrc set filetype=ruby syntax=ruby
autocmd BufNewFile,BufRead *.god set filetype=ruby syntax=ruby
autocmd BufNewFile,BufRead *.less set filetype=css
autocmd BufNewFile,BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:>
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
autocmd BufNewFile,BufRead *.es6 set filetype=javascript
autocmd Filetype gitcommit setlocal textwidth=78
autocmd FileType go autocmd BufWritePre <buffer> Fmt
autocmd FileType go,c,cpp,rust set ts=4 sw=4 sts=4 et
"}}}
" lightline.vim"{{{
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'active': {
\ 'left': [
\ [ 'mode', 'paste' ],
\ [ 'filename' ],
\ ['ctrlpmark']
\ ],
\ 'right': [
\ [ 'syntastic', 'lineinfo' ], ['percent'],
\ [ 'filetype' ],
\ ]
\ },
\ 'component_function': {
\ 'fugitive': 'MyFugitive',
\ 'filename': 'MyFilename',
\ 'fileformat': 'MyFileformat',
\ 'filetype': 'MyFiletype',
\ 'fileencoding': 'MyFileencoding',
\ 'mode': 'MyMode',
\ 'ctrlpmark': 'CtrlPMark',
\ },
\ 'component_expand': {
\ 'syntastic': 'SyntasticStatuslineFlag',
\ },
\ 'component_type': {
\ 'syntastic': 'error',
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! MyModified()
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! MyReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! MyFilename()
let fname = expand('%:t')
return fname == 'ControlP' ? g:lightline.ctrlp_item :
\ fname == '__Tagbar__' ? g:lightline.fname :
\ fname =~ '__Gundo\|NERD_tree' ? '' :
\ &ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]') .
\ ('' != MyModified() ? ' ' . MyModified() : '')
endfunction
function! MyFugitive()
try
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head')
let mark = '⭠ ' " edit here for cool mark
let _ = fugitive#head()
return strlen(_) ? mark._ : ''
endif
catch
endtry
return ''
endfunction
function! MyFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! MyFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! MyFileencoding()
return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : ''
endfunction
function! MyMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ fname == 'ControlP' ? 'CtrlP' :
\ fname == '__Gundo__' ? 'Gundo' :
\ fname == '__Gundo_Preview__' ? 'Gundo Preview' :
\ fname =~ 'NERD_tree' ? 'NERDTree' :
\ winwidth(0) > 60 ? lightline#mode() : ''
endfunction
function! CtrlPMark()
if expand('%:t') =~ 'ControlP'
call lightline#link('iR'[g:lightline.ctrlp_regex])
return lightline#concatenate([g:lightline.ctrlp_prev, g:lightline.ctrlp_item
\ , g:lightline.ctrlp_next], 0)
else
return ''
endif
endfunction
let g:ctrlp_status_func = {
\ 'main': 'CtrlPStatusFunc_1',
\ 'prog': 'CtrlPStatusFunc_2',
\ }
function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked)
let g:lightline.ctrlp_regex = a:regex
let g:lightline.ctrlp_prev = a:prev
let g:lightline.ctrlp_item = a:item
let g:lightline.ctrlp_next = a:next
return lightline#statusline(0)
endfunction
function! CtrlPStatusFunc_2(str)
return lightline#statusline(0)
endfunction
let g:tagbar_status_func = 'TagbarStatusFunc'
function! TagbarStatusFunc(current, sort, fname, ...) abort
let g:lightline.fname = a:fname
return lightline#statusline(0)
endfunction
augroup AutoSyntastic
autocmd!
autocmd BufWritePost * call s:syntastic()
augroup END
function! s:syntastic()
SyntasticCheck
call lightline#update()
endfunction
" fix statusline after reloading vimrc
call lightline#update()
"}}}
" delimitMate"{{{
" remove ` and * from the quotes
let delimitMate_quotes = "\" '"
"}}}
" vim-multiple-cursors"{{{
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_next_key='<C-b>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
"}}}
" startify"{{{
let g:startify_list_order = [
\ [' MRU:'],
\ 'dir',
\ [' Bookmarks:'],
\ 'bookmarks',
\ ]
let g:startify_bookmarks = [
\ {'v': '~/.vimrc'},
\ {'b': '~/.bashrc'},
\ {'g': '~/.gitconfig'},
\ {'t': '~/.tmux.conf'}
\ ]
let g:startify_change_to_dir = 0
"}}}
" YouCompleteMe"{{{
let g:ycm_collect_identifiers_from_tags_files = 1
"}}}
" elm-vim"{{{
let g:elm_setup_keybindings = 0
let g:elm_format_autosave = 1
"}}}
" splitjoin.vim"{{{
let g:splitjoin_split_mapping = ''
let g:splitjoin_join_mapping = ''
"}}}