Closed pedroadame closed 7 years ago
Wouldn't this be possible by providing a custom g:rspec_command
?
Hi @gylaz, that's exactly what I tried at first, and could'nt get more than a blank screen that behaves strangely (it display rows of text as I navigate through them) with specs running in background. The other possibility was a "Press Enter to continue" blank screen with specs running in background. With redraw! this screen is in fact redrawn so the blank screen becomes the editor again correctly working and you don't need more than your specified keystroke to launch tests in background.
Hi @pedroadame, could you instead wrap the vim-rspec
functions in a function of your own, which does the normal vim-rspec call, and then does redraw!
? This should give you the control you want, without needing to add any code to vim-rspec
. Example:
function! RunAllSpecsAndRedraw()
call RunAllSpecs()
redraw!
end
nnoremap <leader>a :call RunAllSpecsAndRedraw()<CR>
If you wanted to map all of them, you could make it slightly cleaner by adding a generic CallAndRedraw
function, and then only needing to update the mappings:
" Looks up the function with the given name and calls it
function! CallAndRedraw(function_name)
call function(a:function_name)()
redraw!
endfunction
nnoremap <leader>a :call CallAndRedraw('RunAllSpecs')<CR>
nnoremap <leader>l :call CallAndRedraw('RunLastSpec')<CR>
nnoremap <leader>; :call CallAndRedraw('RunNearestSpec')<CR>
nnoremap <leader>' :call CallAndRedraw('RunCurrentSpecFile')<CR>
Would that work for you?
Hi @christoomey Yes, it seems it would work nicely. Thanks!
Very useful to integrate this plugin with vim-plumber. In that plugin, you can send commands to a pipe that will execute them, useful for sending
bundle exec rspec
to it and execute tests in background in another terminal (or tmux pane ;) ).Without my modifications, user can specify
as their
read_pipe.sh
andlet g:rspec_command = "silent ! echo \"rspec {spec}\" > .plumber &"
in their vimrc to execute commands to pipe. The problem with this is that user needs to pressEnter
after doing this. If he specifieslet g:redraw_after_specs = 1
in vimrc, vim-rspec will redraw so user will keep focused in writing code and running specs in background.Practical example:
Then use
<leader>;
to executevim-rspec
function that will be read byvim-plumber
and executed in background.I know it's a very specific purpose but with allowing user to specify it he wants this behaviour I find it very useful.