nubank / matcher-combinators

Library for creating matcher combinator to compare nested data structures
Other
467 stars 23 forks source link

How to disable colors without binding matcher-combinators.ansi-color/*use-color* #195

Closed SevereOverfl0w closed 1 year ago

SevereOverfl0w commented 1 year ago

The coloured output has a slight issue: My editor can't display it! Unfortunately there's no way to wrap a binding around my editor's commands for running tests, nor do I want to change the output for everyone else.

Ideally ansi output would be detected somehow. But lacking that, something mutable would be more useful than a dynamic binding.

philomates commented 1 year ago

good point; can imagine that is annoying! What would fit best for you:

you use vim, not neovim, right? For neovim I'm a fan of baleia to address this issue when used with conjure

SevereOverfl0w commented 1 year ago

I use neovim with fireplace, but baleia has bugs meaning it didn't work in that context.

I think a java system property would be very pragmatic, but it would be a shame because if I simultaneously used the CLI and my editor I'd have to give up colours in the CLI. But I also can't think of any way to inject a function as a preamble into the testing in order to change this.

philomates commented 1 year ago

With "a clojure function to call via your editor's repl integration as a sort of preamble?", I was thinking of specifying matcher-combinators.ansi-color/disable! and then calling it one's REPL startup. Something like putting (matcher-combinators.ansi-color/disable!) in a dev/user.clj and ensuring that namespace isn't loaded via your CLI test runner startup.

You can also hack it into the form being sent from your editor to the REPL but it probably won't be pretty. I've done this before back when I used iron.nvim. Not sure how fireplace works in this regard. conjure seems to sort of have ways to do this by, for example, defining a new test-runner, which you can point to a small lib that that wraps clojure.test/{run-all|run} and binds *use-color*

philomates commented 1 year ago

This was deployed in 3.8.0. @SevereOverfl0w can you test it out and let us know if it works for your setup?

SevereOverfl0w commented 1 year ago

That should work a treat! In addition, I've created https://github.com/severeOverfl0w/nrepl-bind which lets me call set! from any nREPL client to disable it for just that nREPL client.