specky/plugin/specky.vim
author Mahlon E. Smith <mahlon@martini.nu>
Fri, 24 Dec 2010 20:01:10 -0800
branchvim-stuff
changeset 21 cd1f3381c1ed
parent 19 763cef799c74
permissions -rw-r--r--
Emit file and line for failure source (use gF to jump straight to it!). Show context lines for exception source. Put spec summary run at the top of the screen. Small documentation fixes.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
     1
" vim: set noet nosta sw=4 ts=4 fdm=marker :
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
     2
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
     3
" Specky!
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
     4
" Mahlon E. Smith <mahlon@martini.nu>
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
     5
" $Id$
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
     6
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
     7
8
2e76f5b2a40f Hmm, not sure why I thought this worked. It doesn't.
mahlon
parents: 7
diff changeset
     8
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
     9
" Hook up the functions to the user supplied key bindings. {{{
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    10
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    11
if exists( 'g:speckySpecSwitcherKey' )
8
2e76f5b2a40f Hmm, not sure why I thought this worked. It doesn't.
mahlon
parents: 7
diff changeset
    12
	execute 'map ' . g:speckySpecSwitcherKey . ' :call <SID>SpecSwitcher()<CR>'
2e76f5b2a40f Hmm, not sure why I thought this worked. It doesn't.
mahlon
parents: 7
diff changeset
    13
"	map &g:speckySpecSwitcherKey <SID>SpecSwitcher()
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    14
endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    15
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    16
if exists( 'g:speckyQuoteSwitcherKey' )
8
2e76f5b2a40f Hmm, not sure why I thought this worked. It doesn't.
mahlon
parents: 7
diff changeset
    17
	execute 'map ' . g:speckyQuoteSwitcherKey . ' :call <SID>QuoteSwitcher()<CR>'
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    18
endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    19
3
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
    20
if exists( 'g:speckyBannerKey' )
8
2e76f5b2a40f Hmm, not sure why I thought this worked. It doesn't.
mahlon
parents: 7
diff changeset
    21
	execute 'map ' . g:speckyBannerKey . ' :call <SID>MakeBanner()<CR>'
3
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
    22
endif
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
    23
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    24
if exists( 'g:speckyRunSpecKey' )
8
2e76f5b2a40f Hmm, not sure why I thought this worked. It doesn't.
mahlon
parents: 7
diff changeset
    25
	execute 'map ' . g:speckyRunSpecKey . ' :call <SID>RunSpec()<CR>'
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    26
endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    27
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    28
if exists( 'g:speckyRunRdocKey' )
8
2e76f5b2a40f Hmm, not sure why I thought this worked. It doesn't.
mahlon
parents: 7
diff changeset
    29
	execute 'map ' . g:speckyRunRdocKey . ' :call <SID>RunRdoc()<CR>'
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    30
endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    31
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    32
if exists( 'specky_loaded' )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    33
	finish
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    34
endif
11
a9ebb6c22d14 Alter the build Makefiles to implement a suggestion from Antoine Mechelynck.
Mahlon E. Smith <mahlon@martini.nu>
parents: 8
diff changeset
    35
let specky_loaded = '$Rev$'
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    36
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    37
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    38
"}}}
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    39
" Menu configuration {{{
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    40
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    41
let s:menuloc = '&Plugin.&specky'
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    42
execute 'menu ' . s:menuloc . '.&Jump\ to\ code/spec :call <SID>SpecSwitcher()<CR>'
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    43
execute 'menu ' . s:menuloc . '.Run\ &spec :call <SID>RunSpec()<CR>'
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    44
execute 'menu ' . s:menuloc . '.&RDoc\ lookup :call <SID>RunRdoc()<CR>'
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    45
execute 'menu ' . s:menuloc . '.Rotate\ &quote\ style :call <SID>QuoteSwitcher()<CR>'
3
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
    46
execute 'menu ' . s:menuloc . '.Make\ a\ &banner :call <SID>MakeBanner()<CR>'
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    47
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    48
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    49
" }}}
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    50
" SpecSwitcher() {{{
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    51
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    52
" When in ruby code or an rspec BDD file, try and search recursively through
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    53
" the filesystem (within the current working directory) to find the
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    54
" respectively matching file.  (code to spec, spec to code.)
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    55
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    56
" This operates under the assumption that you've used chdir() to put vim into
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    57
" the top level directory of your project.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    58
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    59
function! <SID>SpecSwitcher()
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    60
5
3346aa8d5364 Add snippets and rspec syntax highlights.
mahlon
parents: 3
diff changeset
    61
	" If we aren't in a ruby or rspec file then we probably don't care
3346aa8d5364 Add snippets and rspec syntax highlights.
mahlon
parents: 3
diff changeset
    62
	" too much about this function.
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    63
	"
5
3346aa8d5364 Add snippets and rspec syntax highlights.
mahlon
parents: 3
diff changeset
    64
	if &ft != 'ruby' && &ft != 'rspec'
3346aa8d5364 Add snippets and rspec syntax highlights.
mahlon
parents: 3
diff changeset
    65
		call s:err( "Not currently in ruby or rspec mode." )
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    66
		return
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    67
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    68
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    69
	" Ensure that we can always search recursively for files to open.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    70
	"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    71
	let l:orig_path = &path
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    72
	set path=**
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    73
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    74
	" Get the current buffer name, and determine if it is a spec file.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    75
	"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    76
	" /tmp/something/whatever/rubycode.rb ---> rubycode.rb
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    77
	" A requisite of the specfiles is that they match to the class/code file,
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    78
	" this emulates the eigenclass stuff, but doesn't require the same
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    79
	" directory structures.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    80
	"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    81
	" rubycode.rb ---> rubycode_spec.rb
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    82
	" 
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    83
	let l:filename     = matchstr( bufname('%'), '[0-9A-Za-z_.-]*$' )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    84
	let l:is_spec_file = match( l:filename, '_spec.rb$' ) == -1 ? 0 : 1
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    85
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    86
	if l:is_spec_file
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    87
		let l:other_file = substitute( l:filename, '_spec\.rb$', '\.rb', '' )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    88
	else
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    89
		let l:other_file = substitute( l:filename, '\.rb$', '_spec\.rb', '' )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    90
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    91
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    92
	let l:bufnum = bufnr( l:other_file )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    93
	if l:bufnum == -1
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    94
		" The file isn't currently open, so let's search for it.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    95
		execute 'find ' . l:other_file
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    96
	else
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    97
		" We've already got an open buffer with this file, just go to it.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    98
		execute 'buffer' . l:bufnum
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
    99
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   100
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   101
	" Restore the original path.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   102
	execute 'set path=' . l:orig_path
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   103
endfunction
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   104
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   105
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   106
" }}}
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   107
" QuoteSwitcher() {{{
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   108
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   109
" Wrap the word under the cursor in quotes.  If in ruby mode,
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   110
" cycle between quoting styles and symbols.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   111
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   112
" variable -> "variable" -> 'variable' -> :variable
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   113
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   114
function! <SID>QuoteSwitcher()
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   115
	let l:type = strpart( expand("<cWORD>"), 0, 1 )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   116
	let l:word = expand("<cword>")
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   117
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   118
	if l:type == '"'
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   119
		" Double quote to single
3
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   120
		execute ":normal viWc'" . l:word . "'"
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   121
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   122
	elseif l:type == "'"
5
3346aa8d5364 Add snippets and rspec syntax highlights.
mahlon
parents: 3
diff changeset
   123
		if &ft == 'ruby' || &ft == 'rspec'
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   124
			" Single quote to symbol
3
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   125
			execute ':normal viWc:' . l:word
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   126
		else
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   127
			" Single quote to double
3
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   128
			execute ':normal viWc"' . l:word . '"'
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   129
		end
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   130
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   131
	else
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   132
		" Whatever to double quote
3
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   133
		execute ':normal viWc"' . l:word . '"'
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   134
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   135
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   136
	" Move the cursor back into the cl:word
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   137
	call cursor( 0, getpos('.')[2] - 1 )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   138
endfunction
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   139
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   140
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   141
" }}}
3
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   142
" MakeBanner() {{{
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   143
"
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   144
" Create a quick banner from the current line's text.
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   145
"
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   146
function! <SID>MakeBanner()
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   147
	let l:banner_text = toupper(join( split( getline('.'), '\zs' ), ' ' ))
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   148
	let l:banner_text = substitute( l:banner_text, '^\s\+', '', '' )
6
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   149
	let l:sep = repeat( '#', &textwidth == 0 ? 72 : &textwidth )
3
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   150
	let l:line = line('.')
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   151
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   152
	call setline( l:line, l:sep )
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   153
 	call append( l:line, [ '### ' . l:banner_text, l:sep ] )
6
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   154
	execute 'normal 3=='
3
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   155
	call cursor( l:line + 3, 0 )
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   156
endfunction
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   157
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   158
db3e3abfc647 * Add colorschemes directory.
mahlon
parents: 2
diff changeset
   159
" }}}
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   160
" RunSpec() {{{
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   161
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   162
" Run this function while in a spec file to run the specs within vim.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   163
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   164
function! <SID>RunSpec()
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   165
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   166
	" If we're in the code instead of the spec, try and switch
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   167
	" before running tests.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   168
	"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   169
	let l:filename     = matchstr( bufname('%'), '[0-9A-Za-z_.-]*$' )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   170
	let l:is_spec_file = match( l:filename, '_spec.rb$' ) == -1 ? 0 : 1
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   171
	if ( ! l:is_spec_file )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   172
		silent call <SID>SpecSwitcher()
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   173
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   174
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   175
	let l:spec    = bufname('%')
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   176
	let l:buf     = 'specky:specrun'
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   177
	let l:bufnum  = bufnr( l:buf )
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   178
	let l:specver = (exists( 'g:speckySpecVersion') && g:speckySpecVersion == 1) ? 1 : 2
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   179
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   180
	" Squash the old buffer, if it exists.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   181
	"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   182
	if buflisted( l:buf )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   183
		execute 'bd! ' . l:buf
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   184
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   185
6
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   186
	execute <SID>NewWindowCmd() . l:buf
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   187
	setlocal buftype=nofile bufhidden=delete noswapfile
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   188
	if ( l:specver == 1 )
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   189
		setlocal filetype=specrun1
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   190
		set foldtext='--'.getline(v:foldstart).v:folddashes
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   191
	else
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   192
		setlocal filetype=specrun
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   193
		set foldtext=_formatFoldText()
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   194
	endif
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   195
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   196
	" Set up some convenient keybindings.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   197
	"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   198
	nnoremap <silent> <buffer> q :close<CR>
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   199
	nnoremap <silent> <buffer> e :call <SID>FindSpecError(1)<CR>
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   200
	nnoremap <silent> <buffer> r :call <SID>FindSpecError(-1)<CR>
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   201
	nnoremap <silent> <buffer> E :call <SID>FindSpecError(0)<CR>
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   202
	nnoremap <silent> <buffer> <C-e> :let b:err_line=1<CR>
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   203
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   204
	" Default cmd for spec
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   205
	"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   206
	if !exists( 'g:speckyRunSpecCmd' )
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   207
		let g:speckyRunSpecCmd = l:specver == 1 ? 'spec -fs' : 'rspec'
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   208
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   209
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   210
	" Call spec and gather up the output
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   211
	"
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   212
	let l:cmd =  g:speckyRunSpecCmd . ' ' . l:spec
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   213
	call append( line('$'), 'Output of: ' . l:cmd  )
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   214
	call append( line('$'), '' )
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   215
	let l:output = system( l:cmd )
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   216
	call append( line('$'), split( l:output, "\n" ) )
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   217
	normal gg
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   218
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   219
	" Lockdown the buffer
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   220
	setlocal nomodifiable
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   221
endfunction
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   222
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   223
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   224
" }}}
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   225
" RunRdoc() {{{
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   226
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   227
" Get documentation for the word under the cursor.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   228
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   229
function! <SID>RunRdoc()
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   230
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   231
	" If we aren't in a ruby file (specs are ruby-mode too) then we probably
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   232
	" don't care too much about this function.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   233
	"
6
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   234
	if ( &ft != 'ruby' && &ft != 'rdoc' && &ft != 'rspec' )
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   235
		call s:err( "Not currently in a rubyish-mode." )
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   236
		return
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   237
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   238
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   239
	" Set defaults
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   240
	"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   241
	if !exists( 'g:speckyRunRdocCmd' )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   242
		let g:speckyRunRdocCmd = 'ri'
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   243
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   244
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   245
	let l:buf     = 'specky:rdoc'
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   246
	let l:bufname = bufname('%')
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   247
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   248
	if ( match( l:bufname, l:buf ) != -1 )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   249
		" Already in the rdoc buffer.  This allows us to lookup
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   250
		" something like Kernel#require.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   251
		"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   252
		let l:word = expand('<cWORD>')
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   253
	else
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   254
		" Not in the rdoc buffer.  This allows us to lookup
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   255
		" something like 'each' in some_hash.each { ... }
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   256
		"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   257
		let l:word = expand('<cword>')
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   258
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   259
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   260
	" Squash the old buffer, if it exists.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   261
	"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   262
	if buflisted( l:buf )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   263
		execute 'bd! ' . l:buf
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   264
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   265
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   266
	" With multiple matches, strip the commas from the cWORD.
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   267
	let l:word = substitute( l:word, ',', '', 'eg' )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   268
6
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   269
	execute <SID>NewWindowCmd() . l:buf
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   270
	setlocal buftype=nofile bufhidden=delete noswapfile filetype=rdoc
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   271
	nnoremap <silent> <buffer> q :close<CR>
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   272
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   273
	" Call the documentation and gather up the output
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   274
	"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   275
	let l:cmd    = g:speckyRunRdocCmd . ' ' . l:word
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   276
	let l:output = system( l:cmd )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   277
	call append( 0, split( l:output, "\n" ) )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   278
	execute 'normal gg'
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   279
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   280
	" Lockdown the buffer
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   281
	setlocal nomodifiable
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   282
endfunction
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   283
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   284
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   285
" }}}
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   286
" FindSpecError( detail ) {{{
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   287
"
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   288
" detail:
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   289
" 	1  -- find the next failure
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   290
" 	-1 -- find the previous failure
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   291
" 	0  -- expand the current failure's detail
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   292
"
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   293
" Convenience searches for jumping to spec failures.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   294
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   295
function! <SID>FindSpecError( detail )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   296
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   297
	let l:specver = (exists( 'g:speckySpecVersion') && g:speckySpecVersion == 1) ? 1 : 2
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   298
	let l:err_str = l:specver == 1 ? '(FAILED\|ERROR - \d\+)$' : 'FAILED - #\d\+)$'
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   299
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   300
	if ( a:detail == 0 )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   301
		" Find the detailed failure text for the current failure line,
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   302
		" and unfold it.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   303
		"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   304
		let l:orig_so = &so
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   305
		set so=100
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   306
		if l:specver == 1
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   307
			call search('^' . matchstr(getline('.'),'\d\+)$') )
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   308
		else
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   309
			call search('^FAILURE - #' . matchstr(getline('.'),'\d\+)$') )
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   310
		endif
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   311
		if has('folding')
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   312
			silent! normal za
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   313
		endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   314
		execute 'set so=' . l:orig_so
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   315
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   316
	else
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   317
		" Find the 'regular' failure line
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   318
		"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   319
		if exists( 'b:err_line' )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   320
			call cursor( b:err_line, a:detail == -1 ? 1 : strlen(getline(b:err_line)) )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   321
		endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   322
		call search( l:err_str, a:detail == -1 ? 'b' : '' )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   323
		let b:err_line = line('.')
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   324
		nohl
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   325
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   326
	endif
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   327
endfunction
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   328
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   329
6
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   330
" }}}
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   331
" NewWindowCmd() {{{
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   332
"
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   333
" Return the stringified command for a new window, based on user preferences.
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   334
"
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   335
function! <SID>NewWindowCmd()
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   336
	if ( ! exists('g:speckyWindowType' ) )
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   337
		return 'tabnew '
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   338
	endif
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   339
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   340
	if ( g:speckyWindowType == 1 )
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   341
		return 'new '
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   342
	elseif ( g:speckyWindowType == 2 )
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   343
		return 'vert new '
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   344
	else
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   345
		return 'tabnew '
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   346
	endif
31d00503e038 * Small documentation updates
mahlon
parents: 5
diff changeset
   347
endfunction
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   348
19
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   349
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   350
" }}}
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   351
" _formatFoldText() {{{
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   352
"
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   353
" Make folded failure detail visually appealing when folded.
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   354
"
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   355
function! _formatFoldText()
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   356
	let l:fold = tolower( getline(v:foldstart) )
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   357
	let l:fold = substitute( l:fold, '-', 'detail', 'e' )
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   358
	let l:fold = '--[ ' . substitute( l:fold, ')', ' ]', 'e' )
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   359
	return l:fold
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   360
endfunction
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   361
763cef799c74 Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   362
2
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   363
" }}}
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   364
" s:err( msg ) "{{{
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   365
" Notify of problems in a consistent fashion.
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   366
"
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   367
function! s:err( msg )
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   368
	echohl WarningMsg|echomsg 'specky: ' . a:msg|echohl None
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   369
endfunction " }}}
6b33188f1694 Moving Specky into a Vim subfolder.
mahlon
parents:
diff changeset
   370