-
Notifications
You must be signed in to change notification settings - Fork 4
/
.vimrc
executable file
·269 lines (228 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
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
" Encoding (important that this is set early in .vimrc)
se enc=utf8 " use UTF-8 internally
se fencs=ucs-bom,utf-8,default,latin1 " detect detectable Unicode, but fall back
" ==== Presentation
" Info
syntax on
set colorcolumn=80
set laststatus=2
" setup relative numbering
call rnu#setup()
" Do an incremental search
set incsearch
set hlsearch
" Not sure what this does. Looks important/specific
if &term == "xterm-color"
fixdel
endif
set t_Co=256
set directory=~/.vim/swap//,/tmp/vim-swap//,/tmp//
" ==== Controls
let mapleader = ","
set mouse=a
" Find the cursor
hi CursorLine ctermbg=white ctermfg=NONE guibg=white guifg=NONE
hi CursorColumn ctermbg=white ctermfg=NONE guibg=white guifg=NONE
nnoremap <Leader>C :set cursorline! cursorcolumn!<CR>
" Escape with jk mashing
inoremap jk <Esc>
inoremap kj <Esc>
inoremap jj <Esc>
inoremap kk <Esc>
" searches are case-insensitive, unless they contain upper-case:
set ignorecase
set smartcase
" get rid of bells, hopefully
set noeb vb t_vb=
" Save on focus loss
:au FocusLost * silent! :wa
" ==== Typing
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set nowrap
set backspace=2
set autoindent
set smartindent
" Special settings for python
autocmd BufRead,BufNewFile *.py setlocal tabstop=4 expandtab
" And for ruby
autocmd BufRead,BufNewFile *.rb setlocal tabstop=2 expandtab softtabstop=2 shiftwidth=2
" Clojure
autocmd BufRead,BufNewFile *.clj,*.cljs setf clojure
" Wrap visual selectiosn with chars
vnoremap ( "zdi(<C-R>z)<ESC>
vnoremap { "zdi{<C-R>z}<ESC>
vnoremap [ "zdi[<C-R>z]<ESC>
vnoremap ' "zdi'<C-R>z'<ESC>
vnoremap " "zdi"<C-R>z"<ESC>
" ==== Meta-vim
filetype on
" reload vimrc on save
augroup vimrc
autocmd BufWritePost .vimrc source $MYVIMRC
augroup END
aug filetypedetect
au! BufNewFile,BufRead *.markdown,*.md,*.mkd se ft=markdown
au! BufNewFile,BufRead *.scala se ft=scala
au! BufNewFile,BufRead *.hbs se ft=mustache
aug END
nmap <leader>v :tabedit $MYVIMRC<CR>
if has("user_commands")
command! -bang -nargs=? -complete=file E e<bang> <args>
command! -bang -nargs=? -complete=file W w<bang> <args>
command! -bang -nargs=? -complete=file Wq wq<bang> <args>
command! -bang -nargs=? -complete=file WQ wq<bang> <args>
command! -bang Wa wa<bang>
command! -bang WA wa<bang>
command! -bang Q q<bang>
command! -bang QA qa<bang>
command! -bang Qa qa<bang>
endif
" Check for file changes
au CursorHold * checktime
" === Programming things
" Syntax checks
augroup Programming
" clear auto commands for this group
autocmd!
autocmd BufWritePost *.js !test -f ~/jslint/jsl && ~/jslint/jsl -conf ~/jslint/jsl.default.conf -nologo -nosummary -process <afile>
autocmd BufWritePost *.rb !ruby -c <afile>
autocmd BufWritePost *.rake !ruby -c <afile>
autocmd BufWritePost *.erb !erb -x -T '-' <afile> | ruby -c
autocmd BufWritePost *.py !python -c "compile(open('<afile>').read(), '<afile>', 'exec')"
autocmd BufWritePost *.php !php -d display_errors=on -l <afile>
autocmd BufWritePost *.inc !php -d display_errors=on -l <afile>
autocmd BufWritePost *httpd*.conf !/etc/rc.d/init.d/httpd configtest
autocmd BufWritePost *.bash !bash -n <afile>
autocmd BufWritePost *.sh !bash -n <afile>
autocmd BufWritePost *.pl !perl -c <afile>
autocmd BufWritePost *.perl !perl -c <afile>
autocmd BufWritePost *.xml !xmllint --noout <afile>
autocmd BufWritePost *.xsl !xmllint --noout <afile>
" get csstidy from http://csstidy.sourceforge.net/
" autocmd BufWritePost *.css !test -f ~/csstidy/csslint.php && php ~/csstidy/csslint.php <afile>
" get jslint from http://javascriptlint.com/
" autocmd BufWritePost *.pp !puppet --parseonly <afile>
augroup END
" ==== Plugins
" Airline (better Powerline)
let g:airline_left_sep = '▶'
let g:airline_right_sep = '◀'
" Rainbow-Parenthesis
" they're overriden by syntax, so run this now
runtime plugin/RainbowParentheses.vim
" Ctrlp
" Show hidden files by default
let g:ctrlp_show_hidden = 1
"Ctrl P Ignore build and git directories
let g:ctrlp_custom_ignore = '\v[\/](\.git|build)$'
" <leader>n = CtrlP from current file's directory
nm <leader>n :CtrlPCurFile<CR>
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
" ==== Vundle
set rtp+=~/.vim/vundle
call alternative#vundle#rc()
filetype plugin indent on " required!by Vundle
Bundle 'bling/vim-airline'
Bundle 'kien/ctrlp.vim'
Bundle 'tpope/vim-rails.git'
Bundle 'tpope/vim-fugitive'
Bundle 'Markdown'
Bundle 'ervandew/supertab'
Bundle 'kien/rainbow_parentheses.vim'
Bundle 'tpope/vim-endwise'
Bundle 'airblade/vim-gitgutter'
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
Bundle "honza/vim-snippets"
Bundle "garbas/vim-snipmate"
Bundle 'rcyrus/snipmate-snippets-rubymotion'
Bundle 'mhinz/vim-startify'
Bundle 'vim-scripts/bad-whitespace'
Bundle 'scrooloose/nerdcommenter'
Bundle 'derekwyatt/vim-scala'
Bundle 'Townk/vim-autoclose'
Bundle 'mustache/vim-mustache-handlebars'
"" Colors
set background=light
colorscheme Railscasts
let g:solarized_termcolors=256
"" Aliases
ia rpry require 'pry'; binding.pry
"" Reset search highlighting when refreshing the screen (Ctrl+l)
nn <silent> <C-l> :nohls<CR><C-l>
"" Testing
function! RunTests(filename)
" Write the file and run tests for the given filename
:w
exec ":!bundle exec rspec " . a:filename
endfunction
function! SetTestFile()
" Set the spec file that tests will be run for.
let t:grb_test_file=@%
endfunction
function! RunTestFile(...)
:silent !echo;echo;echo "Running test file"
if a:0
let command_suffix = a:1
else
let command_suffix = ""
endif
" Run the tests for the
" previously-marked file.
let in_spec_file = match(expand("%"), '$') != -1
if in_spec_file
call SetTestFile()
elseif
!exists("t:grb_test_file")
return
end
call RunTests(t:grb_test_file.command_suffix)
endfunction
function! RunNearestTest()
:silent !echo;echo;echo;echo;echo;echo "Running nearest test"
let spec_line_number = line('.')
call RunTestFile(":" . spec_line_number)
endfunction
function! RunWip(...)
:w
:silent !echo;echo;echo;echo;echo; echo "Running wip for the project"
exec ":!bundle exec rspec -t @wip"
endfunction
function! RunWipFile(...)
:w
:silent !echo;echo;echo;echo;echo; echo "Running wip in just one file"
exec ":!bundle exec rspec -t @wip %"
endfunction
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
function! RunCeedlingCurFile()
:w
exec ":!rake test:pattern[" . expand('%:t') .']'
endfunction
function! RunCeedlingAll()
:w
exec ":!rake test:all"
endfunction
"autocmd BufWritePre * :call TrimWhiteSpace()
autocmd InsertLeave * :call TrimWhiteSpace()
"run the wip in this file
map <leader>wf :call RunWipFile()<cr>
"run feature file
map <leader>w :call RunWip()<cr>
"run spec for current file
map <leader>f :call RunCeedlingCurFile()<cr>
"run spec for what is under cursor
map <leader>t :call RunNearestTest()<cr>
"run spec for entire app
map <leader>a :call RunCeedlingAll()<cr>
"keymaping for nerd tree
map <leader>bt :NERDTreeToggle<cr>
:set guifont=Bitstream\ Vera\ Sans\ Mono:h13
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces