Permalink
Browse files

Version 1.2

Add support for opening spec output and rdoc in a new tab/horz split/vert split.  Support syntax highlighting for -implemented- pending specs.  (spec code wrapped in a 'pending' block, vs an 'it' declaration that has no block.)  Allow rdoc lookup from rspec mode.  Banner creation now respects current indent level.
  • Loading branch information...
1 parent 11e8a3e commit 6c2b2219e74e85d814d082ee864e16ea78079940 @mahlonsmith mahlonsmith committed with vim-scripts Apr 20, 2009
Showing with 48 additions and 20 deletions.
  1. +19 −10 doc/specky.txt
  2. +27 −8 plugin/specky.vim
  3. +2 −2 syntax/specrun.vim
View
@@ -1,4 +1,4 @@
-*specky.txt* Last change: $Id: specky.txt 66 2009-04-03 23:34:00Z mahlon $
+*specky.txt* Last change: $Id: specky.txt 67 2009-04-20 00:57:06Z mahlon $
VIM REFERENCE MANUAL by Mahlon E. Smith
@@ -21,7 +21,7 @@ CONTENTS *SpeckyContents*
4.5) Run specs for the current buffer.......|g:speckyRunSpecKey|
4.6) Modify the default spec command........|g:speckyRunSpecCmd|
4.7) Modify the default rdoc command........|g:speckyRunRdocCmd|
- 4.8) Split windows vertically...............|g:speckyVertSplit|
+ 4.8) Alter new window behavior..............|g:speckyWindowType|
5) Author.......................................|SpeckyAuthor|
6) License......................................|SpeckyLicense|
@@ -92,7 +92,7 @@ Here's what my config looks like. >
let g:speckyRunSpecKey = "<C-S>s"
let g:speckyRunSpecCmd = "spec -fs -r loadpath.rb"
let g:speckyRunRdocCmd = "fri -L -f plain"
- let g:speckyVertSplit = 1
+ let g:speckyWindowType = 2
With these bindings, all specky commands start with <ctrl-s> ("s" for
@@ -201,16 +201,16 @@ convention.
aRubyClass.rb ---> aRubyClass_spec.rb~
- Because it leaves respective buffers open, you can essentially think of this
- as a quick toggle for code and tests.
+Because it leaves respective buffers open, you can essentially think of this
+as a quick toggle between code and tests.
------------------------------------------------------------------------------
4.5 *g:speckyRunSpecKey*
-Setting this variable allows you to run "spec" on the current buffer.
+Setting this variable runs "spec" on the current buffer.
All output is sent to a syntax highlighted scratch buffer. This new window is
re-used for each spec run. You can quickly "jump" to assertion failures and
@@ -259,20 +259,29 @@ supported too, though less useful.
If you prefer an rdoc display program other than "ri", you can set it
-with this variable.
+with this variable. "fri -L -f plain" is always a nice choice, for example.
Default: ~
ri
------------------------------------------------------------------------------
-4.8 *g:speckyVertSplit*
+4.8 *g:speckyWindowType*
-For both spec and rdoc commands, split the new window vertically instead of
-horizontally.
+For both spec and rdoc commands, this variable controls the behavior of the
+newly generated window.
+ Default: ~
+ 0
+
+ 0 ~
+ Create a new tabbed window
+ 1 ~
+ Split the current window horizontally
+ 2 ~
+ Split the current window vertically
==============================================================================
View
@@ -2,14 +2,15 @@
"
" Specky!
" Mahlon E. Smith <mahlon@martini.nu>
-" $Id: specky.vim 66 2009-04-03 23:34:00Z mahlon $
+" $Id: specky.vim 68 2009-04-20 01:24:08Z mahlon $
"
-" }}}
+
" Hook up the functions to the user supplied key bindings. {{{
"
if exists( 'g:speckySpecSwitcherKey' )
execute 'map ' . g:speckySpecSwitcherKey . ' :call <SID>SpecSwitcher()<CR>'
+" map &g:speckySpecSwitcherKey <SID>SpecSwitcher()
endif
if exists( 'g:speckyQuoteSwitcherKey' )
@@ -28,7 +29,6 @@ if exists( 'g:speckyRunRdocKey' )
execute 'map ' . g:speckyRunRdocKey . ' :call <SID>RunRdoc()<CR>'
endif
-
if exists( 'specky_loaded' )
finish
endif
@@ -152,11 +152,12 @@ endfunction
function! <SID>MakeBanner()
let l:banner_text = toupper(join( split( getline('.'), '\zs' ), ' ' ))
let l:banner_text = substitute( l:banner_text, '^\s\+', '', '' )
- let l:sep = repeat( '#', 72 )
+ let l:sep = repeat( '#', &textwidth == 0 ? 72 : &textwidth )
let l:line = line('.')
call setline( l:line, l:sep )
call append( l:line, [ '### ' . l:banner_text, l:sep ] )
+ execute 'normal 3=='
call cursor( l:line + 3, 0 )
endfunction
@@ -187,7 +188,7 @@ function! <SID>RunSpec()
execute 'bd! ' . l:buf
endif
- execute ( exists('g:speckyVertSplit') ? 'vert new ' : 'new ') . l:buf
+ execute <SID>NewWindowCmd() . l:buf
setlocal buftype=nofile bufhidden=delete noswapfile filetype=specrun
set foldtext='--'.getline(v:foldstart).v:folddashes
@@ -230,8 +231,8 @@ function! <SID>RunRdoc()
" If we aren't in a ruby file (specs are ruby-mode too) then we probably
" don't care too much about this function.
"
- if ( &ft != 'ruby' && &ft != 'rdoc' )
- call s:err( "Not currently in ruby-mode." )
+ if ( &ft != 'ruby' && &ft != 'rdoc' && &ft != 'rspec' )
+ call s:err( "Not currently in a rubyish-mode." )
return
endif
@@ -266,7 +267,7 @@ function! <SID>RunRdoc()
"
let l:word = substitute( l:word, ',', '', 'eg' )
- execute ( exists('g:speckyVertSplit') ? 'vert new ' : 'new ') . l:buf
+ execute <SID>NewWindowCmd() . l:buf
setlocal buftype=nofile bufhidden=delete noswapfile filetype=rdoc
nnoremap <silent> <buffer> q :close<CR>
@@ -317,6 +318,24 @@ function! <SID>FindSpecError( detail )
endif
endfunction
+" }}}
+" NewWindowCmd() {{{
+"
+" Return the stringified command for a new window, based on user preferences.
+"
+function! <SID>NewWindowCmd()
+ if ( ! exists('g:speckyWindowType' ) )
+ return 'tabnew '
+ endif
+
+ if ( g:speckyWindowType == 1 )
+ return 'new '
+ elseif ( g:speckyWindowType == 2 )
+ return 'vert new '
+ else
+ return 'tabnew '
+ endif
+endfunction
" }}}
" s:err( msg ) "{{{
View
@@ -1,6 +1,6 @@
"
" specky: syntax highlighting for the 'spec' script output
-" $Id: specrun.vim 46 2008-08-12 16:24:10Z mahlon $
+" $Id: specrun.vim 67 2009-04-20 00:57:06Z mahlon $
"
if has("folding")
@@ -25,7 +25,7 @@ highlight link specPassed MoreMsg
" Pending specs (specdoc output)
"
-syntax match specPending /.*PENDING: Not Yet Implemented)/ contained
+syntax match specPending /.*PENDING: .*)$/ contained
highlight link specPending Function
"
" (Plain output)

0 comments on commit 6c2b221

Please sign in to comment.