thoughtbot / vim-rspec

Run Rspec specs from Vim
https://robots.thoughtbot.com
MIT License
656 stars 108 forks source link

Error in gui MacVim: "no previous command" #89

Closed githorse closed 9 years ago

githorse commented 9 years ago

I get the following error in gui MacVim when I try to RunNearestSpec(), RunLastSpec(), or RunNearestSpecFile():

screen shot 2015-05-09 at 2 06 21 pm

Everything works fine in terminal MacVim (mvim -v). Ideas?

shamanime commented 9 years ago

I am experiencing the same issue, it happens when I try to set a custom rspec command on .vimrc.

chalmagean commented 9 years ago

same here

gylaz commented 9 years ago

What is your g:rspec_command set to? If you are running from gui, then it should not contain the !.

JamesLavin commented 9 years ago

Thanks, @gylaz, for sharing your expertise!

I'm having the same problem. Spring works fine under ITerm but not under MacVim. Your comment got me one step closer. After I removed the "!", instead of throwing a E34 error, it's now opening a new Bash session in my root directory instead of the directory where I'm running Vim. Because of that, it can't find spring ("/Users/jlavin/.rvm/gems/ruby-1.9.3-p551/gems/spring-1.3.6/lib/spring/configuration.rb:46:in `find_project_root': Spring was unable to locate the root of your project. There was no Gemfile present in the current directory (/Users/jlavin) or any of the parent directories. (Spring::UnknownProject)").

Here's the relevant section of my .vimrc:

if has("gui_macvim")
  let g:rspec_command = "spring rspec {spec}"
else
  let g:rspec_runner = "os_x_iterm"
  let g:rspec_command = "!spring rspec {spec}"
endif

Thanks!

--James

JamesLavin commented 9 years ago

I fixed it. The following works for me under both ITerm and MacVim. I hope it works for others too:

if has("gui_macvim")
  let g:rspec_runner = "os_x_iterm"
  let g:rspec_command = "spring rspec {spec}"
else
  let g:rspec_runner = "os_x_iterm"
  let g:rspec_command = "!spring rspec {spec}"
endif

MacVim was defaulting to Terminal rather than ITerm.

Thanks again, @gylaz!

shamanime commented 9 years ago

Thank you @gylaz and @JamesLavin!

It was !'s fault. I totally missed it.

Much love guys!

gylaz commented 9 years ago

@JamesLavin Glad it worked out for you. You don't need to specify g:rspec_runner in the non-GUI case, since that variable is only used for GUI vim.