-
Notifications
You must be signed in to change notification settings - Fork 3
/
vimrc
392 lines (286 loc) · 11.4 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
"==========================================================
"
" Psyho's .vimrc
"
" heavily inspired by Peepcode screencast, Sickill
" and Derek Wyatt
"
"==========================================================
"----------------------------------------------------------
" VUNDLE
"----------------------------------------------------------
set nocompatible " Must come first because it changes other options.
filetype off " required by Vundle
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
Plugin 'VundleVim/Vundle.vim'
"----------------------------------------------------------
" PLUGINS
"----------------------------------------------------------
" LaTeX support
Plugin 'AutomaticTexPlugin'
" javascript indentation in vim sucks
Plugin 'Better-Javascript-Indentation'
" javascript syntax plugin
Plugin 'othree/yajs'
" CSS
Plugin 'JulesWang/css.vim'
" Fuzzy file searching
Plugin 'wincent/Command-T'
" NerdCommenter - comment blocks of code
Plugin 'The-NERD-Commenter'
" csapprox - make gvim colorschemes work in console
Plugin 'CSApprox'
" Cofeescript support
Plugin 'vim-coffee-script'
" cucumber support
Plugin 'tpope/vim-cucumber'
" d.vim - syntax highliting for D programming language
Plugin 'd.vim'
" greplace.vim - plugin that allows search and replace across all of the project files
Plugin 'greplace.vim'
" jslint .js files automatically
"Plugin 'jslint.vim'
" syntastic - plugin for displaying syntax errors
Plugin 'scrooloose/syntastic'
" vim-endwise - wisely add 'end' in ruby
Plugin 'endwise.vim'
" vim-fugitive - vim-git integration
Plugin 'tpope/vim-fugitive'
" vim-bundler to include gems from Gemfile.lock in ctags
Plugin 'tpope/vim-bundler'
" vim-markdown - syntax highlighting for markdown
Plugin 'Markdown'
" vim-matchit - better pair matching for the % command
Plugin 'matchit.zip'
" for vim-rake
Plugin 'tpope/vim-projectionist'
" vim-rake - :Rake, :A, :R like in rails.vim, but without rails
Plugin 'tpope/vim-rake'
" vim-rails - awesome vim-rails integration
Plugin 'tpope/vim-rails'
" vim-repeat - repeat stuff done in vim-surround
Plugin 'tpope/vim-repeat'
" vim-ruby - ruby integration
Plugin 'ruby.vim'
" vim-ruby-refactoring - automatic refactorings for ruby
Plugin 'ecomba/vim-ruby-refactoring'
" A nice color scheme
Plugin 'Solarized'
" cuztomizable tab completion, continued is the newer version
Plugin 'SuperTab--Van-Dewoestine'
" vim-surround - surrounding text with braces, quotes, html tags...
Plugin 'surround.vim'
" Snipmate - the new version
Plugin 'MarcWeber/vim-addon-mw-utils.git'
Plugin 'tomtom/tlib_vim.git'
Plugin 'scrooloose/snipmate-snippets.git'
Plugin 'garbas/vim-snipmate.git'
" vim-textobj - dependency of rubyblock
Plugin 'textobj-user'
" vim-textobj-rubyblock - allow selecting blocks in ruby as text objects
Plugin 'textobj-rubyblock'
" Emmet/zencoding - plugin for expanding css-like syntax to html
Plugin 'mattn/emmet-vim'
" LESS CSS syntax support
Plugin 'groenewege/vim-less'
" Slim templates
Plugin 'slim-template/vim-slim.git'
" Jade templates
Plugin 'digitaltoad/vim-jade'
" Clojure development plugins
Plugin 'tpope/vim-fireplace'
Plugin 'guns/vim-clojure-static'
" rainbow parentheses, mostly for clojure
Plugin 'kien/rainbow_parentheses.vim'
call vundle#end()
filetype plugin indent on
"----------------------------------------------------------
syntax enable " Turn on syntax highlighting.
runtime macros/matchit.vim " Load the matchit plugin.
set encoding=utf-8 " Default encoding
set showcmd " Display incomplete commands.
set showmode " Display the mode you're in.
set backspace=indent,eol,start " Intuitive backspacing.
set hidden " Handle multiple buffers better.
set wildmenu " Enhanced command line completion.
set wildmode=list:longest " Complete files like a shell.
set ignorecase " Case-insensitive searching.
set smartcase " But case-sensitive if expression contains a capital letter.
set number " Show line numbers.
set ruler " Show cursor position.
set cursorline " Highlight the current line
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
set virtualedit=block " allow the cursor to go into invalid places only in visual block mode
" Display tabs and trailing spaces
set list
set listchars=tab:»\ ,trail:·,nbsp:·
set incsearch " Highlight matches as you type.
set hlsearch " Highlight matches.
set wrap " Turn on line wrapping.
set scrolloff=3 " Show 3 lines of context around the cursor.
set title " Set the terminal's title
set visualbell " No beeping.
set splitbelow splitright " Splitting behavior
set nobackup " Don't make a backup before overwriting a file.
set nowritebackup " And again.
set directory=/tmp " Keep swap files in one location
set tabstop=2 " Global tab width.
set shiftwidth=2 " And again, related.
set expandtab " Use spaces instead of tabs
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set laststatus=2 " Show the status line all the time
set confirm " confirm on quit, etc.
set autoread " automatically read changes from disk
set diffopt+=iwhite " ignore whitespace in vimdiff
" Folding settings
set foldmethod=indent " indent based on syntax
set foldnestmax=3 " deepest fold is 3 levels
set foldlevel=3
set nofoldenable " don't fold by default
set matchpairs+=<:> " add < and > to the chars that can be navigated with %
set spell " enable spell check
set spelllang=en_us " default spell check language
set shell=/bin/zsh
" Useful status information at bottom of screen
set statusline=[%n]\ %<%.99f\ %h%w%m%r%y\ %{exists('*CapsLockStatusline')?CapsLockStatusline():''}%=%-16(\ %l,%c-%v\ %)%P
" change the mapleader from \ to ,
let mapleader=","
" j and k will navigate correctly in the wrapped lines
nnoremap j gj
nnoremap k gk
" map .md files fo markdown
au BufNewFile,BufRead *.md set filetype=markdown
" map .sjs files to javascript
au BufNewFile,BufRead *.sjs set filetype=javascript
" map .es6 files to javascript
au BufNewFile,BufRead *.es6 set filetype=javascript
" automatically strip trailing whitespace for some file types
autocmd FileType c,cpp,java,php,javascript,html,ruby autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
" Easy window navigation
map <C-h> <C-w>h:wa<cr>
map <C-j> <C-w>j:wa<cr>
map <C-k> <C-w>k:wa<cr>
map <C-l> <C-w>l:wa<cr>
" syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_enable_signs=1
let g:syntastic_disabled_filetypes = ['eruby']
" Emmet
let g:user_emmet_leader_key='<C-E>'
" command-t
let g:CommandTMaxFiles = 100000
" spell-checking related shortcuts
nmap <silent> <leader>lp :set spelllang=pl_pl<CR>
nmap <silent> <leader>le :set spelllang=en_us<CR>
" ignore gems bundled in the project directory
set wildignore+=vendor/gems,vendor/bundle,node_modules,public/bower,dev,resources/public/js/out,tmp/specs
" ignore target directory in clojure projects
set wildignore+=target
" ignore _deploy and output in nanoc sites
set wildignore+=_deploy,output
" some Git mappings
nmap <silent> <leader>gt :Gstatus<cr>
nmap <silent> <leader>gl :Git pull --rebase<cr>
nmap <silent> <leader>gp :Git push<cr>
nmap <silent> <leader>gs :Git stash<cr>
nmap <silent> <leader>gsp :Git stash pop<cr>
" rainbow parentheses always on
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
" Don't indent midje facts
let g:clojure_fuzzy_indent_patterns = ['^with', '^def', '^let', 'fact']
map <leader>tsj :CommandTFlush<cr>\|:CommandT spec/javascripts<cr>
map <leader>tj :CommandTFlush<cr>\|:CommandT app/assets/javascripts<cr>
map <leader>tg :topleft 100 :split Gemfile<cr>
map <leader>tt :CommandTFlush<cr>\|:CommandTTag<cr>
map <leader>f :CommandTFlush<cr>\|:CommandT<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RUNNING TESTS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>s :call RunTestFile()<cr>
map <leader>S :call RunNearestTest()<cr>
map <leader>A :call RunTests('')<cr>
" map <leader>c :w\|:!script/features<cr>
" map <leader>w :w\|:!script/features --profile wip<cr>
function! RunTestFile(...)
if a:0
let command_suffix = a:1
else
let command_suffix = ""
endif
" Run the tests for the previously-marked file.
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\)$') != -1
if in_test_file
call SetTestFile()
elseif !exists("t:grb_test_file")
return
end
call RunTests(t:grb_test_file . command_suffix)
endfunction
function! RunNearestTest()
let spec_line_number = line('.')
call RunTestFile(":" . spec_line_number . " -b")
endfunction
function! SetTestFile()
" Set the spec file that tests will be run for.
let t:grb_test_file=@%
endfunction
function! RunTests(filename)
" Write the file and run tests for the given filename
:w
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
if match(a:filename, '\.feature$') != -1
exec ":!script/features " . a:filename
else
if filereadable("script/test")
exec ":!script/test " . a:filename
elseif filereadable("Gemfile")
exec ":!bundle exec rspec --color " . a:filename
else
exec ":!rspec --color " . a:filename
end
end
endfunction
" Make the 'cw' and like commands put a $ at the end instead of just deleting
" the text and replacing it
set cpoptions=ces$
" switch between two last open files faster
nmap <silent> <leader><leader> <c-^>
" create directory for current file
nmap <silent> <leader>d :!mkdir -p %:h<cr>:w<cr>
nmap <silent> <LocalLeader>f :Ggrep <c-r><c-w> **/*<cr>
nmap <silent> <LocalLeader>F :Ggrep <c-r><c-a> **/*<cr>
nmap <silent> <C-R> :redo<cr>
" solarized settings
set background=light
let g:solarized_termtrans=1
let g:solarized_termcolors=256
let g:solarized_contrast="high"
let g:solarized_visibility="high"
" Colors for console
if !has("gui_running")
set t_Co=256
endif
" Scheme
colorscheme solarized
" don't search coverage reports and vcr cassettes
set wildignore+=spec/reports
set wildignore+=test/reports
set wildignore+=spec/cassettes
" Use Node.js for JavaScript interpretation
let $JS_CMD='node'
" Look for tags in gems.tags
set tags+=gems.tags