Skip to content

Instantly share code, notes, and snippets.

@mrnugget
Last active April 24, 2017 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrnugget/872fa345aa9e950e30be1cb9ac2d6b29 to your computer and use it in GitHub Desktop.
Save mrnugget/872fa345aa9e950e30be1cb9ac2d6b29 to your computer and use it in GitHub Desktop.
I wrote this down so people in the future know how to answer "do you know what happened to him?"

RSpec output in Vim broken

Tests are run with vim-dispatch and this command:

:Dispatch bundle exec rspec spec/path/to/file_spec.rb

vim-dispatch creates a new tmux pane where it runs the command. The output of the command is fed to Vim.

Problem

Sometimes the STDOUT output produced by bundle exec rspec is malformed. Lines are missing, or merged together.

First idea was that it's a problem with Vim's :compiler setting and the way the vim-ruby RSpec compiler parses output. It turns out, that's not the case. That's been fixed (thoughtbot/vim-rspec#105). The problem also isn't with vim-dispatch and which :compiler it sets:

tpope/vim-dispatch#41

The rspec compiler is never used, since I use bundle exec rspec. But with this in the .vimrc it's possible to configure vim-dispatch to ignore bundle exec when determining the compiler:

let g:dispatch_compilers = { 'bundle exec': ''}

Cause of the Problem

Between 2.2 and 2.3 there have been changes in tmux that broke the tmux pipe-pane command, which vim-dispatch uses to capture the output of commands:

tpope/vim-dispatch#192

The author of the change in tmux speculates, that he "must have been on crack when [he] did this" (tmux/tmux#594)

The change has been reverted on the tmux master branch.

Possible Solutions

In any case: add the dispatch_compilers config to vimrc.

For the missing output:

  1. Upgrade to tmux master (2.4 is unreleased as of writing). That fixes the vim-dispatch problems. But it also has backwards-incompatible changes in the .tmux.conf format, breaking key bindings in the (yeah, you guessed it) vi-copy-mode of tmux. The syntax changed:

     bind-key -t vi-copy ...        # before
     bind-key -T copy-mode-vi ...   # after
            
     # See: https://github.com/tmux/tmux/issues/754
    

This solution means upgrading tmux on every computer to master and changing the config to the still unstable, new format.

  1. Use the shellpipe config-hack discussed in tpope/vim-dispatch#192 -- this sometimes works and sometimes doesn't.
@mrnugget
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment