-
Notifications
You must be signed in to change notification settings - Fork 31
/
makegreen.txt
219 lines (150 loc) · 7.49 KB
/
makegreen.txt
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
*makegreen.txt* Strong Visual Indicator for Your TDD Cycle
CONTENTS
===========================================================================
1. Introduction |makegreen|
2. Requirements |makegreen-requirements|
3. Installation |makegreen-installation|
4. Usage |makegreen-usage|
5. Mappings |makegreen-mappings|
6. Configuration |makegreen-configuration|
7. Feedback |makegreen-feedback|
8. Credits |makegreen-credits|
9. Contributors |makegreen-contributors|
10. License |makegreen-license|
Introduction *:MakeGreen* *makegreen*
===========================================================================
MakeGreen runs |:make|. Then it shows a red/green bar in Vim's
'statusline' indicating the result.
Or put simply: "Strong Visual Indicator for Your TDD Cycle".
Requirements *makegreen-requirements*
===========================================================================
This plugin requires that:
- 'compatible' isn't set.
- Your Vim is compiled with |+quickfix| and |+eval| features. You can use
|:version| to find it out.
- One or more |:compiler| for the filetype you're working on. Vim 7.3 now
officially ships with 51 compilers. You can search the Internet for more
or just write your own. See |write-compiler-plugin|.
Installation *makegreen-installation*
===========================================================================
Copy all files to your ~/.vim directory or use one of the following Vim
plugin managers like a decent modern Vimmist:
- pathongen: https://github.com/tpope/vim-pathogen
- Vundle: https://github.com/gmarik/vundle
- NeoBundle: https://github.com/Shougo/neobundle.vim
- VAM: https://github.com/MarcWeber/vim-addon-manager
Usage *makegreen-usage*
===========================================================================
Run Tests in a Single File~
Here's a quick example:
$ cd <your rails project>
$ vim test/unit/user_test.rb
:compiler rubyunit
:MakeGreen %
Expect to see a red/green bar in your 'statusline'. If the test fails,
you'll see the failure message in the red bar and the cursor would jump to
the position of the first failure.
A little explanation: the `%` character will expand to the current file
name (see |c_%|) and will be passed to the rubyunit compiler. Eventually
rubyunit just executes `testrb test/unit/user_test.rb`.
Run All Tests~
Some compiler (like rspec) runs the entire test suite if no arguments are
provided. To do that, you can just execute
:MakeGreen
Run Any Command~
At this moment Vim doesn't propagate exit status of 'makeprg' back.
MakeGreen can't figure out if failure happens without a proper
'errorformat' being set. So if you only set 'makeprg' you'll always get
a green bar. If you have both 'makeprg' and 'errorformat' set to make it
work, you should consider distributing these two settings as a standalone
compiler :)
Selecting Compiler~
You can set compiler automatically with the following methods:
- The easiest way is set compiler per filetype. Put the following code in
your ~/.vim/ftplugin/ruby.vim:
>
compiler rubyunit
<
will use rubyunit compiler for all your ruby files.
If you prefer to have all your vim settings in a single ~/.vimrc file, just
hook the the |FileType| autocommand event instead:
>
autocmd FileType ruby compiler rubyunit
<
- If your test files conform to a strict naming convention, make use of it:
>
" In ~/.vimrc
autocmd BufNewFile,BufRead *_spec.rb compiler rspec
<
Note: the rspec compiler shipped with Vim is only works with RSpec 1.x.
For a modern version working with RSpec 2.x, see:
https://github.com/vim-ruby/vim-ruby/blob/master/compiler/rspec.vim
- Enable Vim's 'exrc' option to set compiler project-wise. Notice that this
introduces potential security leaks. Use with care.
Mapping *makegreen-mapping*
===========================================================================
There is no default key mapping at the moment. You can define your own
mapping easily anyway:
>
nmap <leader>t :MakeGreen %<CR>
<
Or more conservatively:
>
nnoremap <unique> <leader>t :MakeGreen %<CR>
<
Configuration *makegreen-configuration*
===========================================================================
Options~
Set the following variable in ~/.vimrc to control the behaviour of
MakeGreen.
*g:makegreen_stay_on_file*
g:makegreen_stay_on_file booleen (default 0)
If set to 1, cursor won't jump to the first
error when test failed.
Style~
You can configure how the red/green bar looks like with Vim's |:highlight|
command. But at this moment you have to configure it after the
plugin/makegreen.vim is loaded. You can make use of vim's |after-directory|
functionality to achieve this.
An example of ~/.vim/after/plugin/makegreen.vim looks like this:
>
" The green bar looks pretty bright on my terminal.
" So I have to set foreground color as black.
hi GreenBar term=reverse ctermfg=black ctermbg=green guifg=white guibg=green
<
*hl-GreenBar*
GreenBar default:
term=reverse
ctermfg=white ctermbg=green
guifg=white guibg=green
Style used for the green bar.
*hl-RedBar*
RedBar default:
term=reverse
ctermfg=white ctermbg=red
guifg=white guibg=red
Style used for the red bar.
Feedback *makegreen-feedback*
===========================================================================
Feel free to create an issue at
https://github.com/reinh/vim-makegreen/issues
Credits *makegreen-credits*
===========================================================================
- Based on code from the rubytest.vim plugin
(http://github.com/reinh/vim-rubytest) but considerably refactored and
modified for this more specific purpose.
- Red/Green bar code borrowed from Gary Bernhardt
(http://bitbucket.org/garybernhardt/dotfiles/src/tip/.vimrc) and slightly
modified for my use. Please do check out Gary's coding videos on his blog
for more awesome vim usage (http://blog.extracheese.org/).
- elik and godlygeek in #vim on irc.freenode.net for vim help
- Jim Remsik (@jremsikjr on twitter) for debugging and typo fixing.
Contributors *makegreen-contributors*
===========================================================================
Rein Henrichs
Gary Bernhardt
License *makegreen-license*
===========================================================================
MIT license: http://opensource.org/licenses/MIT
---------------------------------------------------------------------------
vim:tw=75:sts:ts=2:ft=help: