Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MacVim Command Window text coloring help (Rspec output)

I'm trying to transition to MacVim for ruby dev. One of the hangups I have is running specs quickly and getting results (passes/failures) easily.

When I run :Rake (or :!rspec %) it runs the specs in the current file. The output is shown in the command window.

If I run this in regular Terminal, I get colored output. That is, the dots are green and the failures are red.

In MacVim, I get these weird [32m and [0m tokens. Here's an example: enter image description here

Any ideas on how to fix this?

like image 878
Ben Scheirman Avatar asked Feb 02 '11 23:02

Ben Scheirman


2 Answers

Gvim (and I assume Macvim is just that with a brand-name :) ) doesn't have a real terminal behind it, so that's why you're getting these 'weird' tokens - they are the escape codes a real terminal would interpret as colors.

As michaelmichael points out, getting vim to like ANSI escape codes is bothersome. Also, I like his suggestion of vim-rspec. I cobbled this (https://github.com/dahu/VimTestRunner) together as a lightweight rspec test runner. It shows a red/green bar in your Vim status line when you run the tests. You can run just the rspec associated with the current file using <leader>y or all rspecs in the current directory with <leader>a. Feedback and suggestions for improvement welcome. Oh, and it's quite alpha at this stage. Be gentle. :-)

like image 75
dahu Avatar answered Oct 18 '22 18:10

dahu


Use vim-rspec. It'll give you the clean, nicely colored rspec output you're after:

rspec output in MacVim

BTW, those are ANSI escape sequences messing up the output. See here for a question I asked a few weeks ago about getting rid of them while viewing ri documentation in (Mac|g)vim. Bottom line: it's easier to try to get plain text output than to try and shoehorn support for ANSI escape sequences into Vim.

like image 22
michaelmichael Avatar answered Oct 18 '22 16:10

michaelmichael