-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvimrc.old
More file actions
865 lines (788 loc) · 28 KB
/
vimrc.old
File metadata and controls
865 lines (788 loc) · 28 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
set nocompatible
filetype off
"execute pathogen#infect()
let g:alternateExtensions_cc = "inc,h,H,HPP,hpp"
" Vundle configuration
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" A bit meta..
Plugin 'gmarik/Vundle.vim'
Plugin 'sheerun/vim-polyglot.git'
"Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'scrooloose/nerdtree.git'
Plugin 'rking/ag.vim.git' " use this version due to the dependency from nerdtree-ag
Plugin 'taiansu/nerdtree-ag.git'
Plugin 'scrooloose/syntastic.git'
Plugin 'tpope/vim-repeat.git'
Plugin 'chazy/cscope_maps.git'
"Plugin 'vim-scripts/a.vim.git'
" ctrl-n seems to cause multiple issues.
"Plugin 'terryma/vim-multiple-cursors.git'
"Plugin 'maxbrunsfeld/vim-emacs-bindings.git'
"
" Switching back to ycm+ultisnips
" Neosnippet doesn't fully support vim-snippets. (select mode snippets are not
" supported.
"Plugin 'Shougo/neocomplete.git'
"Plugin 'Shougo/neosnippet.vim.git'
Plugin 'Shougo/vimproc.vim.git'
Plugin 'Shougo/neomru.vim.git'
Plugin 'Shougo/unite.vim.git'
"Plugin 'JohnMorales/neosnippet-snippets.git'
Plugin 'Valloric/YouCompleteMe'
Plugin 'SirVer/ultisnips.git'
Plugin 'JohnMorales/bootstrap-snippets'
"Plugin 'git@github.com:honza/vim-snippets.git'
"Plugin 'git@github.com:JohnMorales/vim-bootstrap3-snippets.git'
"Plugin 'bonsaiben/bootstrap-snippets'
" ruby specific plugins
Plugin 'kana/vim-textobj-user.git'
Plugin 'nelstrom/vim-textobj-rubyblock.git'
Plugin 'vim-ruby/vim-ruby'
Plugin 'tpope/vim-rake' " Project specific plugins.
Plugin 'tpope/vim-rails'
Plugin 'yaymukund/vim-rabl'
"Plugin 'ecomba/vim-ruby-refactoring'
"Plugin 'tpope/vim-bundler'
" end rb specfic
Plugin 'Raimondi/delimitMate.git'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-projectionist' " Project specific plugins.
Plugin 'dbakker/vim-projectroot'
"Plugin 'ivalkeen/vim-ctrlp-tjump'
Plugin 'milkypostman/vim-togglelist'
Plugin 'godlygeek/tabular'
Plugin 'vim-scripts/BufOnly.vim'
Plugin 'chrisbra/NrrwRgn'
Plugin 'nathanaelkane/vim-indent-guides'
"Plugin 'majutsushi/tagbar'
Plugin 'bling/vim-airline.git'
" Javascript
Plugin 'kchmck/vim-coffee-script'
Plugin 'marijnh/tern_for_vim.git'
Plugin 'elzr/vim-json.git'
Plugin 'mxw/vim-jsx'
" end js
" css specific plugins
Plugin 'hail2u/vim-css3-syntax.git'
Plugin 'cakebaker/scss-syntax.vim'
Plugin 'ap/vim-css-color'
" vim color themes
Plugin 'altercation/vim-colors-solarized.git'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'chriskempson/base16-vim'
"Plugin 'freeo/vim-kalisi'
" end themes
"Plugin 'gilligan/vim-lldb'
" Go specific
Plugin 'fatih/vim-go.git'
" end go specific
"Plugin 'editorconfig/editorconfig-vim.git'
" Plugin 'edkolev/promptline.vim'
" Plugin 'edkolev/tmuxline.vim'
call vundle#end() " required
filetype plugin indent on
" End vundle
" After installing a new plugin, reload the vimrc and run :PluginInstall
" cmatcher
"let g:ctrlp_match_func = {'match' : 'matcher#cmatch' }
" hack to support shift enter in console vim ref:http://stackoverflow.com/questions/5388562/cant-map-s-cr-in-vim
imap ✠ <S-CR>
set wrap
set linebreak
set nolist
set ai
set tabstop=2
set softtabstop=2
set shiftwidth=2
"Adds a newline after a certain amount of characters, could be useful for writing text but not all the time.
"set textwidth=79
set shiftround
set expandtab
set ruler
set cmdheight=2
set laststatus=2
"this keeps the cursor from hitting the top of the window when moving mouse up
set scrolloff=3
set virtualedit=all
" Allow backspacing
set backspace=indent,eol,start
set modeline
set modelines=5
runtime macros/matchit.vim
set backupdir=~/.backup,/tmp
set pastetoggle=<F4>
set dir=/tmp
" Status line
set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%)\ [%p%%]\ Buf:%n\ [%b][0x%B]
" Disable clearing scrollback buffer when exiting vim
set t_ti= t_te=
set incsearch
set ignorecase
" Copy to clipboard
vmap <C-c> :w !pbcopy<CR><CR>
" Don't show the startup message
set shortmess=I
" taken from https://github.com/vim-scripts/ingo-library/blob/master/autoload/ingo/str.vim
function! Trim( string )
return substitute(a:string, '^\_s*\(.\{-}\)\_s*$', '\1', '')
endfunction
" Turn on persistent undo
" Thanks, Mr Wadsten: github.com/mikewadsten/dotfiles/
if has('persistent_undo')
set undodir=~/.vim/undo/
set undofile
set undolevels=1000
set undoreload=10000
endif
" Use backups
" Source:
" http://stackoverflow.com/a/15317146
set backup
set writebackup
set backupdir=~/.vim/backup/
" Use a specified swap folder
" Source:
" http://stackoverflow.com/a/15317146
set directory=~/.vim/swap/
" Check if a colorscheme exists
" http://stackoverflow.com/a/5703164
function! HasColorScheme(scheme)
let basepath = '~/.vim/bundle/'
for plug in g:color_schemes
let path = basepath . '/' . plug . '/colors/' . a:scheme . '.vim'
if filereadable(expand(path))
return 1
endif
endfor
return 0
endfunction
" let g:solarized_termcolors=256
"set t_Co=256
"set t_Co=88
" Jellybeans colors
" let g:solarized_termcolors=16
"let g:solarized_bold = 0
"let bg_profile = Trim(substitute(system("tmux showenv ITERM_PROFILE"), ".*=", "", ""))
let bg_profile = $ITERM_PROFILE
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256
source ~/.vimrc_background
else
if !empty($BASE16_THEME)
let base16colorspace=256
exec "set background=" . $BASE16_VARIATION
"echom 'setting colorscheme to ' . $BASE16_THEME
colorscheme $BASE16_THEME
endif
endif
"colorscheme jellybeans
"Only useful if using transparent backgrounds.
"let g:solarized_termtrans=1
" Add dictionary completion
set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words
" Add dictionary to complete list
set complete-=k complete+=k
syntax on
" highlight previous search term.
"noremap <F4> :set hlsearch! <cr>
" show tagbar
noremap <F8> :TagbarToggle <CR>
map <F5> :A<CR>
"quickly get out of insert mode so that you can navigate (and practice quick keys)
inoremap jj <esc>
" Find todos
"nmap ,p :w \|!grep -r '\# TODO:' ./ \| grep ^./<cr>
"
"" Make sure ruby syntax is OK
"nmap ,c :w \|!ruby -c % <cr>
"
"" Test files using rspec
"nmap ,tr :w \|!rspec -I ./ % --format=doc --color <cr>
"
" Build tags for current directory using exuberant c-tags
set tags=./tags;
set cscopetag
nnoremap <silent> <Leader>ta :ProjectRootExe !ripper-tags -R . $(bundle show --paths) <cr>
nnoremap <silent> <Leader>u :ProjectRootExe Ag<cr>
nmap ,, <C-^>
nnoremap <silent> <Leader>hm :%!xxd<cr> " Hex mode
nnoremap <silent> <Leader>bh :%!xxd -r<cr> " Back from hex
" nnoremap th :tabfirst<CR>
" nnoremap tj :tabnext<CR>
" nnoremap tk :tabprev<CR>
" nnoremap tl :tablast<CR>
" nnoremap tt :tabedit<Space>
" nnoremap tn :tabnext<Space>
" nnoremap tm :tabm<Space>
" nnoremap td :tabclose<CR>
" Using alt keys for quick window movements Maybe for windows/linux setups...
" nmap <A-h> <C-w><Left>
" nmap <A-l> <C-w><Right>
" nmap <A-k> <C-w><Up>
" nmap <A-j> <C-w><Down>
nmap ˙ <C-w><Left>
nmap ¬ <C-w><Right>
nmap ˚ <C-w><Up>
nmap ∆ <C-w><Down>
" Control enhancements in insert mode
imap <C-F> <right>
imap <C-B> <left>
imap <M-BS> <esc>vBc
"imap <C-P> <up>
"imap <C-N> <down>
" Map Ctrl+V to paste in Insert mode
imap <C-V> <C-R>*
" contents of last global command in new window
"nmap <F3> :redir @a<CR>:g//<CR>:redir END<CR>:new<CR>:put! a<CR><CR>
" TODO
"nmap <leader>n
" select the current block
nmap <leader>v var
" toggle line numbers
" nmap <F12> :set number!<CR>
" Fat-fingering q.
nmap :Q :q
" Delete trailing whitespaces.
nmap <leader>tr :%s/\s*$//g<CR>:w<CR>:e<CR>
" TODO: figure out what PMenu and SpecialKey do.
" highlight Pmenu ctermbg=238 gui=bold
" highlight PMenu gui=bold guibg=#CECECE guifg=#444444
" highlight SpecialKey guifg=#4a4a59
map <leader>j !python -m json.tool<CR>
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_auto_colors = 0
let g:indent_guides_guide_size = 1 " By sitting the guid size to 1, since the shiftwidth is 2, it will add a white space for every ident.
let g:indent_guides_start_level = 2
" Determine good colors for IdentGuides.
" let g:cterm_colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white']
" let g:gui_colors = (&g:background == 'dark') ? ['grey15', 'grey30'] : ['grey70', 'grey85']
if &g:background == 'dark'
hi IndentGuidesEven ctermbg=19
hi IndentGuidesOdd ctermbg=18
else
hi IndentGuidesEven ctermbg='lightgrey'
hi IndentGuidesOdd ctermbg='lightgrey'
endif
" autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=234
" autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=235
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" unite
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call unite#filters#matcher_default#use(['matcher_fuzzy'])
call unite#filters#sorter_default#use(['sorter_rank'])
"call unite#custom#source('file_rec/async','sorters','sorter_rank', )
" replacing unite with ctrl-p
let g:unite_data_directory='~/.vim/.cache/unite'
let g:unite_enable_start_insert=1
let g:unite_source_history_yank_enable=1
let g:unite_prompt='» '
let g:unite_split_rule = 'botright'
if executable('ag')
let g:unite_source_grep_command='ag'
let g:unite_source_grep_default_opts='--nocolor --nogroup -S -C4'
let g:unite_source_grep_recursive_opt=''
endif
nnoremap <silent> <c-p> :Unite -auto-resize file file_mru file_rec/async bookmark file_list<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ctrlp
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Project level tags (alt-p)
" nnoremap π :CtrlPTag<cr>
" " File level tags (alt-f)
" nnoremap ƒ :CtrlPBufTag<cr>
" " Jump to tags (alt-])
" nnoremap ‘ :CtrlPtjump<cr>
" vnoremap ‘ :CtrlPtjumpVisual<cr>
" " Show buffer (Alt-t)
" nmap † :CtrlPBuffer<CR>
" " Show recent files (Alt-r)
" nmap ® :CtrlPMRU<CR>
" let g:ctrlp_working_path_mode = 'ra'
" let g:ctrlp_user_command = {
" \ 'types': {
" \ 1: ['.git', 'cd %s && git ls-files -oc --exclude-standard'],
" \ 2: ['.hg', 'hg --cwd %s locate -I .'],
" \ },
" \ 'fallback': 'find %s -maxdepth 10 \( -type d -name ".*" -prune \) -o -type f -print'
" \ }
" let g:ctrlp_tjump_shortener= ['/Users/jmorales/.rbenv/.*/gems/', 'gems/' ]
" let g:ctrlp_custom_ignore = {
" \ 'dir': '\bower_components\|node_modules\|\v[\/]\.(git)$',
" \ 'file': '\v\.(exe|so|dll)$',
" \ }
" let g:ctrlp_show_hidden = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" end ctrlp
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <silent> ,n :NERDTreeFind<CR>
nmap <silent> ,m :NERDTreeToggle<CR>
function! AppendModeline()
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :",
\ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no')
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>
nnoremap <leader>ev :ed $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
"
" Duplicate line
map <C-d> YP
nmap cp cw<C-r>0<esc>b
" unmapping Ex mode
:map Q <Nop>
" quote single
map <leader>' ysiw'
map <leader>" ysiw"
nnoremap <leader>cs cs"'
nnoremap <leader>cd cs'"
set foldmethod=marker
" make last typed word uppercase.
":imap <c-u> <esc>viwUA
":nmap <c-u> gUiw
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
set number
set relativenumber
"set number
"set verbose=9
" must be set to utf-8 in order for listchars to have unicode characters
scriptencoding utf-8
set encoding=utf-8
set list
set listchars=tab:\ \ ,trail:•,nbsp:⋅
"let g:html_indent_tags = 'html\|div\|table\|p'
"let g:html_indent_tags .= '\|p\|nav\|head'
"Still figuring this one out.
nmap <leader>O :BufOnly<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" airline
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"let g:airline_theme='kalisi'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#syntastic#enabled = 1
" enable tabs for buffers at the top
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
let g:airline_powerline_fonts = 1
let g:airline_symbols = {}
" unicode symbols
" let g:airline_left_sep = '»'
" let g:airline_left_sep = '▶'
" let g:airline_right_sep = '«'
" let g:airline_right_sep = '◀'
" let g:airline_symbols.linenr = '␊'
" let g:airline_symbols.linenr = ''
" let g:airline_symbols.linenr = '¶'
" let g:airline_symbols.branch = '⎇'
" let g:airline_symbols.paste = 'ρ'
" let g:airline_symbols.paste = 'Þ'
" let g:airline_symbols.paste = '∥'
" let g:airline_symbols.whitespace = 'Ξ'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" end airline
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" YouCompleteMe
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ycm_key_list_select_completion = [ '<Down>'] " Need to remember that YCM expects you to accept the text by just space
let g:ycm_key_list_previous_completion = [ '<Up>']
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_complete_in_comments = 1
let g:ycm_confirm_extra_conf= 0
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_seed_identifiers_with_syntax = 1
"imap <expr> <CR> pumvisible() ? \"\<c-y>\" : \"<Plug>delimitMateCR\"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" end YouCompleteMe
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" delimitMate
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"inoremap <S-Tab> <Plug>delimitMateS-Tab
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" enddelimitMate
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ultisnips
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:UltiSnipsExpandTrigger="<S-F12>" " mapped to shift-f10 or F21 is mapped to '\033 [24;2~' in iterm
let g:UltiSnipsListSnippets="<c-l>" " cannot be c-n and c-p because you could get a prompt while you are entering values of a snippet.
let g:UltiSnipsJumpForwardTrigger="<c-j>" " cannot be c-n and c-p because you could get a prompt while you are entering values of a snippet.
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
"
"default mapping interferes with vim see *UltiSnips-triggers*
inoremap <c-x><c-k> <c-x><c-k>
function! ExpandPossibleShorterSnippet()
if len(UltiSnips#SnippetsInCurrentScope()) == 1 "only one candidate...
let curr_key = keys(UltiSnips#SnippetsInCurrentScope())[0]
normal diw
exe "normal a" . curr_key
exe "normal a "
return 1
endif
return 0
endfunction
inoremap <silent> <C-L> <C-R>=(ExpandPossibleShorterSnippet() == 0? '': UltiSnips#ExpandSnippet())<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" end ultisnips
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"http://learnvimscriptthehardway.stevelosh.com/chapters/10.html
inoremap jk <Esc>
nmap ,t :TagbarToggle<CR>
set shell=/bin/sh
let g:rootmarkers = ['.projectroot','.git','.hg','.svn','.bzr','_darcs','build.xml', 'Gemfile' ]
"let g:ctrlp_tjump_only_silent = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" auto commands
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"let g:rubycomplete_buffer_loading = 1
"this is too slow
"let g:rubycomplete_classes_in_global = 1
"let g:rubycomplete_rails = 1
"let g:rubycomplete_use_bundler = 1
" there are more in the neocomplete section
" Custom extenstions
if !exists("autocommands_loaded")
let autocommands_loaded = 1
au BufReadPost *.hbs set ft=html
au BufReadPost *.bats set ft=sh
au BufReadPost *.md set ft=markdown
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" neocomplete
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Disable AutoComplPop.
"let g:acp_enableAtStartup = 0
"" Use neocomplete.
"let g:neocomplete#enable_at_startup = 1
"" Use smartcase.
"let g:neocomplete#enable_smart_case = 1
"" Set minimum syntax keyword length.
"let g:neocomplete#sources#syntax#min_keyword_length = 3
"let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
"
"" Define dictionary.
"let g:neocomplete#sources#dictionary#dictionaries = {
" \ 'default' : '/usr/share/dict/words',
" \ 'vimshell' : $HOME.'/.vimshell_hist',
" \ 'scheme' : $HOME.'/.gosh_completions'
" \ }
"
"" Define keyword.
"if !exists('g:neocomplete#keyword_patterns')
" let g:neocomplete#keyword_patterns = {}
"endif
"let g:neocomplete#keyword_patterns['default'] = '\h\w*'
"
"" Plugin key-mappings.
"inoremap <expr><C-g> neocomplete#undo_completion()
"inoremap <expr><C-l> neocomplete#complete_common_string()
"
" Recommended key-mappings.
" <CR>: close popup and save indent.
"inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
"
"function! s:Ulti_ExpandOrJump_and_getRes()
" call UltiSnips#ExpandSnippetOrJump()
" return g:ulti_expand_or_jump_res
"endfunction
"
"function! s:handle_cr_with_popup()
" return <SID>Ulti_ExpandOrJump_and_getRes() > 0 ? "" : neocomplete#close_popup()
"endfunction
"
"function! s:my_cr_function()
" "return neocomplete#close_popup() . "\<CR>"
" " For no inserting <CR> key.
" return pumvisible() ? <SID>handle_cr_with_popup() : "\<CR>"
"endfunction
" <TAB>: completion.
"imap <expr><tab> pumvisible() ? "\<C-n>" : "\<Tab>"
" <C-h>, <BS>: close popup and delete backword char.
" inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
" inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
" inoremap <expr><C-y> neocomplete#close_popup()
" inoremap <expr><C-e> neocomplete#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>"
" For cursor moving in insert mode(Not recommended)
"inoremap <expr><Left> neocomplete#close_popup() . "\<Left>"
"inoremap <expr><Right> neocomplete#close_popup() . "\<Right>"
"inoremap <expr><Up> neocomplete#close_popup() . "\<Up>"
"inoremap <expr><Down> neocomplete#close_popup() . "\<Down>"
" Or set this.
"let g:neocomplete#enable_cursor_hold_i = 1
" Or set this.
"let g:neocomplete#enable_insert_char_pre = 1
" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"
" Enable omni completion.
" autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
" autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
" autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
" autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
" autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
"
" " Enable heavy omni completion.
" if !exists('g:neocomplete#sources#omni#input_patterns')
" let g:neocomplete#sources#omni#input_patterns = {}
" endif
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" end neocomplete
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sass/Scss
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd FileType scss set iskeyword+=-
"au BufRead,BufNewFile *.scss set filetype=scss.css
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Go
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <Leader>s <Plug>(go-implements)
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>i <Plug>(go-install)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>c <Plug>(go-coverage)
au FileType go nmap <Leader>ds <Plug>(go-def-split)
au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
au FileType go nmap <Leader>dt <Plug>(go-def-tab)
au FileType go nmap <Leader>e <Plug>(go-rename)
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Neosnippet
"
"
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
"
" imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)"
" \: pumvisible() ? "\<C-n>" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)"
" \: "\<TAB>"
" Using vim-snippets instead
"let g:neosnippet#disable_runtime_snippets = { '_': 1 }
" Enable snipmate style snippets
"let g:neosnippet#enable_snipmate_compatibility = 1
" Tell Neosnippet about the other snippets
" let g:neosnippet#snippets_directory= [ '~/.vim/bundle/neosnippet-snippets/neosnippets', '~/.vim/bundle/vim-bootstrap3-snippets/neosnippets' ]
"
" " For snippet_complete marker.
" if has('conceal')
" set conceallevel=2 concealcursor=i
" endif
"
" nnoremap <leader>se :<C-U>NeoSnippetEdit -split<cr>
" let g:neosnippet#scope_aliases = {}
" let g:neosnippet#scope_aliases['ruby'] = 'eruby,ruby,ruby-rails'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" end neosnippet
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Projectionist
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:projectionist_heuristics = {
\ "recipes/&attributes/": {
\ "recipes/*.rb": {"type": "chef.ruby"},
\ "templates/*/*.erb": {"type": "erb.chef.ruby"}
\ },
\ "config/application.rb&bin/rails": {
\ "app/*.js.coffee": {"type": "coffee.javascript"},
\ "app/views/*.erb": {"type": "erb.html.ruby"},
\ "spec/*.rb": {"type": "rails.rspec"},
\ "spec/features/*_spec.rb": {"type": "capy.rspec.rails.ruby"},
\ "spec/*/*_spec.rb": {"type": "rspec.rails.ruby"}
\ },
\ "CMakeLists.txt" : {
\ "*.cc": {"alternate": "{}.h" },
\ "*.h": {"alternate": "{}.cc" }
\ }
\ }
autocmd User ProjectionistActivate call s:activate()
function! s:activate()
for [root, value] in projectionist#query('type')
echom "Adding snippets " . value
call UltiSnips#AddFiletypes(value)
break
endfor
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" end Projectionist
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd FileType cpp set keywordprg=cppman
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Syntastic
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"let g:syntastic_javascript_checkers = [ 'eslint', 'jscs', 'jshint' ]
let local_eslint = finddir('node_modules', '.;') . '/.bin/eslint'
if matchstr(local_eslint, "^\/\\w") == ''
let local_eslint = getcwd() . "/" . local_eslint
endif
if executable(local_eslint)
let g:syntastic_javascript_eslint_exec = local_eslint
endif
let g:syntastic_javascript_checkers = [ 'eslint' ]
let g:syntastic_always_populate_loc_list = 1 "send errors to location list.
let g:syntastic_aggregate_errors = 1 "send errors to location list.
let g:syntastic_check_on_open = 1
let g:syntastic_cursor_column = 0 " 'this speeds of navigation significantly' |syntastic_cursor_columns|
let g:syntastic_auto_jump = 0 " setting to 2 will only autojump on error, disabling this since it would sometimes jump to a separate file if the linter complains about those files.
let g:syntastic_auto_loc_list = 0 "open loc list when error
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-", " proprietary attribute \"ui-"]
let g:syntastic_javascript_jshint_quiet_messages = { "regex": "'angular' is not defined" }
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-", " proprietary attribute \"ui-"]
let g:syntastic_c_check_header = 1 " check headers
let g:syntastic_c_include_dirs = [ '/usr/local/include' ]
let g:syntastic_filetype_map = { "chef.ruby": "chef" }
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" end syntastic
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! LoadAndDisplayRSpecQuickfix()
let quickfix_filename = "./quickfix.out"
if filereadable(quickfix_filename) && getfsize(quickfix_filename) != 0
silent execute ":cfile " . quickfix_filename
botright cwindow
cc
else
redraw!
echohl WarningMsg | echo "Quickfix file " . quickfix_filename . " is missing or empty." | echohl None
endif
endfunction
noremap <silent> <Leader>q :call LoadAndDisplayRSpecQuickfix()<CR>
"""""
" yaml
"""""
function! s:fold_yaml_sections()
"set foldmethod=marker
"":w
endfunction
autocmd FileType yaml :call s:fold_yaml_sections()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ag
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ag_prg="ag --ignore tags --column --smart-case"
let g:ag_highlight=1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" End Ag
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NrrwRgn
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <Leader>sb V%\nr<c-w>_ " show block in new window
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" promptline
"
"
" add git info...
" other themes available in autoload/promptline/themes/*
" run `:PromptlineSnapshot [file] [theme]` e.g. `PromptlineSnapshot ~/.shell_prompt.sh airline` to create new theme
" powerline is customized with a hash of the following keys: a, b, c, x, y, z, warn
" let g:promptline_preset = {
" \'a' : [ promptline#slices#host() ],
" \'b' : [ promptline#slices#cwd() ],
" \'c' : [ promptline#slices#vcs_branch() ],
" \'warn' : [ promptline#slices#last_exit_code() ] }
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" tmuxline
"
"
"" other presets available in `~/.vim/bundle/tmuxline.vim/autoload/tmuxline/themes/`
" change below and run `:Tmuxline`
"
" Vim autopastemode
function! WrapForTmux(s)
if !exists('$TMUX')
return a:s
endif
let tmux_start = "\<Esc>Ptmux;"
let tmux_end = "\<Esc>\\"
return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end
endfunction
let &t_SI .= WrapForTmux("\<Esc>[?2004h")
let &t_EI .= WrapForTmux("\<Esc>[?2004l")
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()