• Stars
    star
    158
  • Rank 237,131 (Top 5 %)
  • Language
    Clojure
  • License
    The Unlicense
  • Created over 10 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

nREPL middleware to pretty-print colored values

whidbey

Build Status cljdoc

This is a plugin for Leiningen which changes the REPL to pretty-print results with Puget.

repl demo

Internally, Whidbey integrates with the nREPL pr-values middleware to provide a custom pretty-printer for the results of evaluated forms in the REPL. See the history doc for more on the motivations and implementation details behind this project.

Usage

To use Whidbey, add it to the :plugins vector in your user or system profile. Note that this requires Leiningen version 2.8.2 or higher for the necessary nREPL and plugin functionality.

Clojars Project

Since Leiningen has deprecated implicit plugin middleware, you'll need to activate it by ading the following to your profile as well:

:middleware [whidbey.plugin/repl-pprint]

Configuration

Whidbey passes rendering options into Puget from the :whidbey key in the profile map:

:whidbey {:width 180
          :map-delimiter ""
          :extend-notation true
          :print-meta true
          :color-scheme {:delimiter [:blue]
                         :tag [:bold :red]
                         ...}
          ...}

See the puget.printer namespace for the available configuration.

If you feel like adjusting Whidbey's configuration at runtime, you can use the whidbey.repl/update-options! function. This will affect all subsequent messages rendered.

If you need to further customize the responses from the REPL, Whidbey respects any :print-options set on the :op :eval message. These will be merged into the normal rendering configuration, but will not affect subsequent messages.

Tag Extensions

Whidbey adds some convenience tagged-literal extensions for binary data and URIs. The extensions update the default-data-readers var to support round-tripping the tagged representations:

=> (java.net.URI. "http://github.com/greglook")
#whidbey/uri "http://github.com/greglook"

=> (.getBytes "foo bar baz")
#whidbey/bin "Zm9vIGJhciBiYXo="

=> #whidbey/bin "b25lIG1vcmUgdGltZSwgbXVzaWNzIGdvdCBtZSBmZWVsaW5nIHNvIGZyZWU="
#whidbey/bin "b25lIG1vcmUgdGltZSwgbXVzaWNzIGdvdCBtZSBmZWVsaW5nIHNvIGZyZWU="

This is controlled by the :extend-notation option. Other type extensions can be added by providing a :tag-types map. This should map type symbols to a map with a tag symbol key pointing to a formatting function. When the type is encountered, it will be rendered as a tagged literal with a form from calling the formatter on the value.

For example, to render class values as tagged types, you can add this to your :whidbey config:

:tag-types
{java.lang.Class {'java/class #(symbol (.getName %))}}}

If the type name or the formatter function are not available at load time, you can quote them to suppress evaluation until those types are printed.

Troubleshooting

Sometimes, there are types which Puget has trouble rendering. These can be excluded from pretty-printing by adding their symbol to the :escape-types set in the options. These types will be rendered with the normal Clojure printer. If you want to use these types' print-method instead, set the :print-fallback option to :print:

:whidbey {:print-fallback :print
          :escape-types #{'datomic.db.Db 'datomic.btset.BTSet ...}
          ...}

Whidbey may also conflict with other REPL customizations. If you experience errors, you can check how the profiles are being merged using the lein-pprint or lein-cprint plugins:

$ lein with-profile +whidbey/repl cprint :repl-options

License

This is free and unencumbered software released into the public domain. See the UNLICENSE file for more information.

More Repositories

1

cljstyle

A tool for formatting Clojure code
Clojure
293
star
2

puget

Canonical Colorizing Clojure Printer
Clojure
252
star
3

blocks

Clojure content-addressable data storage.
Clojure
113
star
4

clj-pgp

Clojure wrapper for the Bouncy Castle OpenPGP library
Clojure
83
star
5

clj-cbor

Native Clojure CBOR codec implementation.
Clojure
70
star
6

clj-hiera

Generate Clojure namespace hierarchy graphs
Clojure
66
star
7

merkle-db

High-scalability analytics database built on immutable merkle-trees
Clojure
44
star
8

merkledag-core

Library to operate on a content-addressed graph of nodes with directed merkle-hash links
Clojure
25
star
9

vault

Content-addressable data storage system
Clojure
22
star
10

clj-arrangement

Micro-library to provide a total-ordering comparator for Clojure.
Clojure
20
star
11

clj-multiformats

Clojure(Script) implementations of the self-describing multiformat specs
Clojure
20
star
12

edn-tool

Pretty-print your EDN
Clojure
17
star
13

alphabase

A simple Clojure(script) library to encode binary data in different bases using alphabets.
Clojure
15
star
14

blocks-s3

Clojure content-addressable block store backed by Amazon S3.
Clojure
12
star
15

merkledag-ledger

Ledger financial translation to the Clojure merkledag data structure.
Clojure
11
star
16

test.carly

Generative test harness for stateful system behavior
Clojure
10
star
17

solanum

Lightweight monitoring daemon for Riemann metrics
Clojure
8
star
18

directive

Clojure DSL for declarative command-line interface construction.
Clojure
4
star
19

toolkit

Simple ruby tool to manage common user configuration and scripts.
Ruby
4
star
20

lein-cprint

Like lein-pprint, but with colors!
Clojure
4
star
21

merkledag-ref

Reference pointer tracking for MerkleDAG data graphs
Clojure
3
star
22

baton

Distributed lock management interface
Clojure
2
star
23

toolkit-packages

Public configuration and script toolkit packages.
Ruby
2
star
24

hoard

A command-line tool for archiving your important data
Clojure
2
star
25

ansible-pki-tls

Ansible role for installing a custom Certificate Authority and server certificate.
2
star
26

merkledag-browser

Clojurescript application to browse merkledag data structures.
Clojure
1
star
27

dynr53

Dynamic DNS updater script for AWS Route53.
Ruby
1
star
28

merkledag-server

Clojure server for block and merkledag data over an HTTP API
Clojure
1
star
29

monitoring-config

Ansible playbooks to configure a TRIG monitoring stack.
Clojure
1
star
30

body-app

Personal health and diet tracking app built on ClojureScript and IPFS
Clojure
1
star
31

ansible-bsd-nginx

Ansible role for installing nginx as a reverse proxy in FreeBSD.
1
star
32

inadynr53

Minimal backend to integrate inadyn and Route53
Clojure
1
star
33

dataphage

Scripts for collecting personal data from third party services.
Clojure
1
star