Syntax highlighting in Lein REPL?

2019-05-04 09:14发布

问题:

I want to configure Lein so that I see a colored REPL, like Emacs' nREPL. How can I do this?

I couldn't find any help on Google. Do I need to learn Bash scripting first?

回答1:

Ultra, “a Leiningen plugin for a superior development environment”, does good syntax highlighting for REPL output, amongst other useful things.


At the moment, there are no plugins or stand-alone REPLs that highlight syntax for input.



回答2:

Whidbey “pretty-prints colored REPL values by default”, using Puget to do the actual pretty-printing. Whidbey’s README seems to indicate that you can install it for all Leiningen projects simply by adding the following :plugins value to your user profile at ~/.lein/profiles.clj:

{:user {:plugins [[mvxcvi/whidbey "0.5.0"]]}}

Though I personally couldn’t get it to work, no matter what I tried.

You can also look at the Colors page on REPLy’s wiki. (REPLy is the REPL built-in to Leiningen 2, and it integrates with nREPL.) For now, all that wiki page contains is a link to Whidbey, but it might be updated in the future.



回答3:

You don't have to use Bash for this at all – the shell only starts processes on the command-line, but they can be written in any language.

I don't think nREPL or its terminal client which is integrated into Leiningen as lein repl, REPL-y, provide any support for syntax colouring themselves. So the most promising approach is probably to fork REPL-y and integrate syntax colouring into it yourself, probably based on some existing syntax colouring solution for Clojure.



回答4:

From emacs client you can try emacs-live

https://github.com/overtone/emacs-live#colour

Colour

Colour highlighting in two flavours - cyberpunk and gandalf. Use color-theme-cyberpunk and color-theme-gandalf to switch between the two themes. Currently cyberpunk has seen more love - patch requests accepted for appropriate improvements to Gandalf.