File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## master (unreleased)
4
4
5
+ ### New features
6
+
7
+ * Add print functions compatible with nREPL 0.5 to ` cider.nrepl.pprint ` namespace.
8
+
5
9
### Changes
6
10
7
11
* ** (Breaking)** Drop support for nREPL 0.2.x (aka ` tools.nrepl ` ). Now nREPL 0.4+ is required.
Original file line number Diff line number Diff line change
1
+ (ns cider.nrepl.pprint
2
+ " Pretty-print related utilities.
3
+ All functions here are simple wrappers that ensure a consistent API:
4
+
5
+ * two params - object to print and a map of print options
6
+ * the keys of the print options map can be strings, as bencode clients can't send keywords
7
+ * functions return the printed object as a string"
8
+ {:added " 0.20.0" }
9
+ (:require
10
+ [clojure.pprint :as pp]
11
+ [clojure.walk :as walk]))
12
+
13
+ (defn pprint
14
+ " A simple wrapper around `clojure.pprint/write`.
15
+ It provides an API compatible with what nREPL's
16
+ pr-values middleware expects for printer functions."
17
+ [object opts]
18
+ (let [opts (assoc (walk/keywordize-keys opts) :stream nil )]
19
+ (apply pp/write object (vec (flatten (vec opts))))))
20
+
21
+ (def ^:private fipp-printer
22
+ (delay
23
+ (do
24
+ (require 'fipp.edn)
25
+ (resolve 'fipp.edn/pprint))))
26
+
27
+ (defn fipp-pprint [object opts]
28
+ (with-out-str
29
+ (@fipp-printer object (walk/keywordize-keys opts))))
30
+
31
+ (def ^:private puget-printer
32
+ (delay
33
+ (do
34
+ (require 'puget.printer)
35
+ (resolve 'puget.printer/pprint-str))))
36
+
37
+ (defn puget-pprint [object opts]
38
+ (@puget-printer object (walk/keywordize-keys opts)))
You can’t perform that action at this time.
0 commit comments