4

I'm currently using vim-dispatch to run tests on my code which outputs the test results to the quickfix panel via tmux. However, all colors seem to be disabled in the output.

There's this two year old issue where tpope talks about it a bit, but that's all i've managed to find.

Is there any way to colorize the quickfix output to improve legibility?

9

If you want your tests to embed colour codes (presumably ANSI) in their output and then have the colours show in the quickfix window, you're out of luck.

However the quickfix buffer is just a buffer, you can add highlighting patterns to it. For example to highlight Ok: and Err: you could create a file ~/.vim/after/syntax/qf.vim, with contents something like this:

highlight TestOk    ctermbg=green
highlight TestError ctermbg=red

syn match TestOk    "\<Ok:"
syn match TestError "\<Err:"

Just make sure to write the regexps in the syn clauses so that they don't match the filename or the error column.

3

Color is represented using ansi escape sequences. On my computer ^[[0m^[[01;34mWord^[[0m represents a blue word. (^[ is the escape character`) Obviously this isn't useful to have in the output if you are writing to a file. So most program recognize that they are not writing to a tty and suppress the color output.

If the program you are running supports it you can force it to output the ansi escape sequences anyways and then use the plugin AnsiEsc.vim with the :AnsiEsc command to conceal the ansi escape output and colorize the output.

However this will most likely break all the parsing that the quick fix window does for you and it will still show the escape sequences if you aren't in the quick fix window since it is only concealing them.


A better options would be to write a highlight script that highlights the output in the quickfix window.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.