forked from ryanb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vimrc
97 lines (86 loc) · 2.67 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
color desert256
set guifont=Menlo\ Regular:h12
nmap <space> <c-w><c-w>
au FocusLost * silent! wa
set foldlevelstart=99
set foldmethod=syntax
" Fuzzy finder: ignore stuff that can't be opened, and generated files
let g:fuzzy_ignore = "*.png;*.PNG;*.JPG;*.jpg;*.GIF;*.gif;vendor/**;coverage/**;tmp/**;rdoc/**"
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Test-running stuff
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RunCurrentTest()
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\)$') != -1
if in_test_file
call SetTestFile()
if match(expand('%'), '\.feature$') != -1
exec CorrectTestRunner() g:bjo_test_file
elseif match(expand('%'), '_spec\.rb$') != -1
exec CorrectTestRunner() g:bjo_test_file
else
exec CorrectTestRunner() g:bjo_test_file
endif
else
exec CorrectTestRunner() g:bjo_test_file
endif
endfunction
function! SetTestRunner(runner)
let g:bjo_test_runner=a:runner
endfunction
function! RunCurrentLineInTest()
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\)$') != -1
if in_test_file
call SetTestFileWithLine()
end
exec CorrectTestRunner() g:bjo_test_file . ":" . g:bjo_test_file_line
endfunction
function! SetTestFile()
let g:bjo_test_file=@%
endfunction
function! SetTestFileWithLine()
let g:bjo_test_file=@%
let g:bjo_test_file_line=line(".")
endfunction
function! CorrectTestRunner()
if match(expand('%'), '\.feature$') != -1
return "!cucumber"
elseif match(expand('%'), '_spec\.rb$') != -1
return "!bundle exec rspec --drb --format Fuubar"
else
return "!ruby"
endif
endfunction
map <Leader>cs :RScontroller<CR>
map <Leader>cv :RVcontroller<CR>
map <Leader>ms :RSmodel<CR>
map <Leader>mv :RVmodel<CR>
map <Leader>ss :AS<CR>
map <Leader>sv :AV<CR>
map <Leader>t :call RunCurrentTest()<CR>
map <Leader>vs :RVview<CR>
map <Leader>vv :RSview<CR>
map <Leader>y :call RunCurrentLineInTest()<CR>
map '' cs"'
map "" cs'"
map '; wF's:f'x
map "; wF"s:f"x
map ;" F:xcsw"
map ;' F:xcsw'
map [] F[xs.wwxx
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Macros
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let @l = 'ilet(:ea)f=xxys${'