-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
190 lines (162 loc) · 7.1 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
runtime! autoload/pathogen.vim
if exists('g:loaded_pathogen')
call pathogen#runtime_prepend_subdirectories(expand('~/.vimbundles'))
endif
command! -bar -range=% Trim :<line1>,<line2>s/\s\+$//e
command! -bar -range=% NotRocket :<line1>,<line2>s/:\(\w\+\)\s*=>/\1:/ge
function! HTry(function, ...)
if exists('*'.a:function)
return call(a:function, a:000)
else
return ''
endif
endfunction
set nocompatible
set autoindent
set autoread
set backspace=indent,eol,start
set complete-=i " Searching includes can be slow
set display=lastline " When lines are cropped at the screen bottom, show as much as possible
if &grepprg ==# 'grep -n $* /dev/null'
set grepprg=grep\ -rnH\ --exclude='.*.swp'\ --exclude='*~'\ --exclude='*.log'\ --exclude=tags\ $*\ /dev/null
endif
set incsearch
set laststatus=2 " Always show status line
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
endif
set list " show trailing whiteshace and tabs
set modelines=5
set scrolloff=1
set sidescrolloff=5
set showcmd
set showmatch
set smarttab
if &statusline == ''
set statusline=[%n]\ %<%.99f\ %h%w%m%r%{HTry('CapsLockStatusline')}%y%{HTry('rails#statusline')}%{HTry('fugitive#statusline')}%#ErrorMsg#%{HTry('SyntasticStatuslineFlag')}%*%=%-14.(%l,%c%V%)\ %P
endif
set ttimeoutlen=50 " Make Esc work faster
set wildmenu
set number
set splitbelow
if $TERM == '^\%(screen\|xterm-color\)$' && t_Co == 8
set t_Co=16
endif
let g:is_bash = 1 " Highlight all .sh files as if they were bash
let g:ruby_minlines = 500
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_rails = 1
let g:NERDCreateDefaultMappings = 0
let g:NERDSpaceDelims = 1
let g:NERDShutUp = 1
let g:VCSCommandDisableMappings = 1
let g:surround_{char2nr('s')} = " \r"
let g:surround_{char2nr(':')} = ":\r"
let g:surround_indent = 1
runtime! plugin/matchit.vim
runtime! macros/matchit.vim
map Y y$
nnoremap <silent> <C-L> :nohls<CR><C-L>
inoremap <C-C> <Esc>`^
cnoremap <C-O> <Up>
inoremap ø <C-O>o
inoremap <M-o> <C-O>o
" Emacs style mappings
inoremap <C-A> <C-O>^
inoremap <C-X><C-@> <C-A>
cnoremap <C-A> <Home>
cnoremap <C-X><C-A> <C-A>
" If at end of a line of spaces, delete back to the previous line.
" Otherwise, <Left>
inoremap <silent> <C-B> <C-R>=getline('.')=~'^\s*$'&&col('.')>strlen(getline('.'))?"0\<Lt>C-D>\<Lt>Esc>kJs":"\<Lt>Left>"<CR>
cnoremap <C-B> <Left>
" If at end of line, decrease indent, else <Del>
inoremap <silent> <C-D> <C-R>=col('.')>strlen(getline('.'))?"\<Lt>C-D>":"\<Lt>Del>"<CR>
cnoremap <C-D> <Del>
" If at end of line, fix indent, else <Right>
inoremap <silent> <C-F> <C-R>=col('.')>strlen(getline('.'))?"\<Lt>C-F>":"\<Lt>Right>"<CR>
inoremap <C-E> <End>
cnoremap <C-F> <Right>
noremap <F1> <Esc>
noremap! <F1> <Esc>
" Enable TAB indent and SHIFT-TAB unindent
vnoremap <silent> <TAB> >gv
vnoremap <silent> <S-TAB> <gv
" Open the OSX color picker and insert the hex value of the choosen color.
" Depends on: https://github.com/jnordberg/color-pick
inoremap <C-X>c #<C-R>=system('colorpick')<CR>
iabbrev Lidsa Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
iabbrev rdebug require 'ruby-debug'; Debugger.start; Debugger.settings[:autoeval] = 1; Debugger.settings[:autolist] = 1; debugger
iabbrev bpry binding.pry
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/\\\@<!|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
if !exists('g:syntax_on')
syntax on
endif
filetype plugin indent on
" Bundle Open command, from Bernerd Schaefer
" Call with :BO <gemname>
function! s:BundleOpen(Gem) abort
if exists(':Btabedit')
execute 'Btabedit '.a:Gem
redraw
let v:warningmsg = 'Use :Btabedit instead. It has tab complete!'
echomsg v:warningmsg
return
endif
let path = system('bundle show '.a:Gem)
if v:shell_error != 0
echo 'failed to run command'
else
exe 'tabedit '.substitute(path, '\v\C\n$', '', '') | :lcd %
endif
endfunction
" :BO capybara
:command! -nargs=1 BundleOpen :call s:BundleOpen(<q-args>)
augroup hashrocket
autocmd!
autocmd CursorHold,BufWritePost,BufReadPost,BufLeave *
\ if isdirectory(expand("<amatch>:h")) | let &swapfile = &modified | endif
autocmd BufRead * if ! did_filetype() && getline(1)." ".getline(2).
\ " ".getline(3) =~? '<\%(!DOCTYPE \)\=html\>' | setf html | endif
autocmd FileType javascript,coffee setlocal et sw=2 sts=2 isk+=$
autocmd FileType html,xhtml,css,scss setlocal et sw=2 sts=2
autocmd FileType eruby,yaml,ruby setlocal et sw=2 sts=2
autocmd FileType cucumber setlocal et sw=2 sts=2
autocmd FileType gitcommit setlocal spell
autocmd FileType gitconfig setlocal noet sw=8
autocmd FileType ruby setlocal comments=:#\ tw=79
autocmd FileType sh,csh,zsh setlocal et sw=2 sts=2
autocmd FileType vim setlocal et sw=2 sts=2 keywordprg=:help
autocmd Syntax css syn sync minlines=50
autocmd FileType ruby nmap <buffer> <leader>bt <Plug>BlockToggle
autocmd User Rails nnoremap <buffer> <D-r> :<C-U>Rake<CR>
autocmd User Rails nnoremap <buffer> <D-R> :<C-U>.Rake<CR>
autocmd User Rails Rnavcommand decorator app/decorators -suffix=_decorator.rb -default=model()
autocmd User Rails Rnavcommand uploader app/uploaders -suffix=_uploader.rb -default=model()
autocmd User Rails Rnavcommand steps features/step_definitions -suffix=_steps.rb -default=web
autocmd User Rails Rnavcommand blueprint spec/blueprints -suffix=_blueprint.rb -default=model()
autocmd User Rails Rnavcommand factory spec/factories -suffix=_factory.rb -default=model()
autocmd User Rails Rnavcommand fabricator spec/fabricators -suffix=_fabricator.rb -default=model()
autocmd User Rails Rnavcommand feature features -suffix=.feature -default=cucumber
autocmd User Rails Rnavcommand support spec/support features/support -default=env
autocmd User Rails Rnavcommand worker app/workers -suffix=_worker.rb -default=model()
autocmd User Fugitive command! -bang -bar -buffer -nargs=* Gpr :Git<bang> pull --rebase <args>
set guifont=Menlo:h14
set guioptions-=T guioptions-=e guioptions-=L guioptions-=r
set shell=bash
augroup vimrc
autocmd!
autocmd GuiEnter * set columns=120 lines=70 number
augroup END
colors molokai
augroup END