Skip to content

Commit

Permalink
Add mapping for \T to focus within specs, features
Browse files Browse the repository at this point in the history
- <leader>t runs the whole spec or feature
- <leader>T runs the spec, with cursor's line number appended
  • Loading branch information
Joshua Davey and Matt Polito authored and hashrocketeer committed Nov 29, 2011
1 parent 122a5c6 commit 027a603
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions plugin/tslime.vim
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,13 @@ function! s:prefix_for_test(file)
return ''
endfunction

function! s:cucumber_command()
return "cucumber " . expand("%") . ":" . line('.')
endfunction

function! s:SendAlternateToTmux() abort
function! s:SendAlternateToTmux(suffix) abort
let current_file = expand("%")
let executable = ""
if s:prefix_for_test(current_file) != ''
let executable = s:prefix_for_test(current_file) . current_file
let executable = s:prefix_for_test(current_file) . current_file . a:suffix
elseif current_file =~# '.feature$'
let executable = s:cucumber_command()
let executable = "cucumber " . current_file . a:suffix
elseif exists('g:autoloaded_rails')
let related_file = s:first_readable_file(rails#buffer().related())
if related_file =~# '.rb$'
Expand All @@ -105,4 +101,5 @@ function! s:SendAlternateToTmux() abort
return SendToTmux(" ".executable."\n")
endfunction

map <leader>t :w \| :call <SID>SendAlternateToTmux()<CR>
map <leader>t :w \| :call <SID>SendAlternateToTmux("")<CR>
map <leader>T :w \| :call <SID>SendAlternateToTmux(":".line('.'))<CR>

0 comments on commit 027a603

Please sign in to comment.