This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-24
Channels
- # announcements (1)
- # babashka (19)
- # beginners (10)
- # cherry (13)
- # cider (12)
- # clerk (10)
- # clj-kondo (5)
- # clojure (8)
- # clojure-europe (30)
- # clojure-norway (155)
- # clojure-uk (8)
- # clojurescript (27)
- # community-development (2)
- # conjure (8)
- # cursive (26)
- # data-science (7)
- # datalevin (58)
- # datomic (9)
- # deps-new (2)
- # hyperfiddle (19)
- # jobs-discuss (9)
- # missionary (27)
- # nbb (22)
- # off-topic (11)
- # polylith (59)
- # practicalli (10)
- # reitit (6)
- # releases (1)
- # sci (5)
- # scittle (23)
- # xtdb (37)
Some editors have built-in formatting support. There are several command-line tools as well.
cljfmt
is probably the most widely used https://github.com/weavejester/cljfmt
Calva uses this for its formatting in VS Code as well.
(require '[clojure.pprint :as pp])
(let [sexp '(let [jsons (.getBytes (str
(json/write-str {})
(json/write-str {:a 42})
(json/write-str {})))]
(with-open [rdr (-> (io/reader jsons)
(java.io.PushbackReader. 64))]
(dotimes [_ 5]
(prn (#'json/-read rdr false ::eof {})))))]
(prn sexp)
(pp/with-pprint-dispatch
pp/code-dispatch
(pp/pprint
sexp)))
cljstyle and cljfmt are common tools, also found in the setup-clojure GitHub action for use in CI workflows. cljstyle is also part of MegaLinter, along with clj-kondo Both cljstyle and cljfmt follow the fundamentals of the community Clojure style guide (although personally I found cljstyle easier to work with) zprint is a very powerful and general purpose code format and text manipulation library. There is a zprint profile that formats along the lines of the community Clojure style guide. zprint arguably has a steeper learning curve than the other tools, although can do far more.