Skip to content

Commit

Permalink
Add support for cljfmt (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalugm authored Dec 15, 2023
1 parent efb9992 commit a382795
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ The format is based on [Keep a Changelog].
([#263]).
* [denofmt](https://docs.deno.com/runtime/manual/tools/formatter) for
js, jsx, ts, tsx, json, jsonc, md files. ([#264])
* [cljfmt](https://github.com/weavejester/cljfmt) for clojure,
clojurescript, edn files. ([#271])

[#229]: https://github.com/radian-software/apheleia/pull/229
[#260]: https://github.com/radian-software/apheleia/pull/260
[#261]: https://github.com/radian-software/apheleia/pull/261
[#263]: https://github.com/radian-software/apheleia/pull/263
[#264]: https://github.com/radian-software/apheleia/pull/264
[#271]: https://github.com/radian-software/apheleia/pull/271

## 4.0 (released 2023-11-23)
### Breaking changes
Expand Down
9 changes: 9 additions & 0 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
(or (apheleia-formatters-local-buffer-file-name)
(apheleia-formatters-mode-extension)
".c")))
(cljfmt . ("cljfmt" "fix" "-"))
(cmake-format . ("cmake-format" "-"))
(crystal-tool-format . ("crystal" "tool" "format" "-"))
(css-beautify "css-beautify" "--file" "-" "--end-with-newline"
Expand Down Expand Up @@ -276,6 +277,14 @@ rather than using this system."
(c-ts-mode . clang-format)
(c++-mode . clang-format)
(caml-mode . ocamlformat)
(clojure-dart-ts-mode . cljfmt)
(clojure-jank-ts-mode . cljfmt)
(clojure-mode . cljfmt)
(clojure-ts-mode . cljfmt)
(clojurec-mode . cljfmt)
(clojurec-ts-mode . cljfmt)
(clojurescript-mode . cljfmt)
(clojurescript-ts-mode . cljfmt)
(cmake-mode . cmake-format)
(cmake-ts-mode . cmake-format)
(common-lisp-mode . lisp-indent)
Expand Down
1 change: 1 addition & 0 deletions test/formatters/installers/cljfmt.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/weavejester/cljfmt/HEAD/install.sh)"
12 changes: 12 additions & 0 deletions test/formatters/samplecode/cljfmt/in.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns hello
(:require [java-time.api :as t]))

(defn time-str
"Returns a string representation of a datetime in the local time zone."
[instant]
(t/format
(t/with-zone (t/formatter "hh:mm a") (t/zone-id))
instant))

(defn run [opts]
(println "Hello world, the time is" (time-str (t/instant))))
6 changes: 6 additions & 0 deletions test/formatters/samplecode/cljfmt/in.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(ns hello-world.core
(:require react-dom))

(.render js/ReactDOM
(.createElement js/React "h2" nil "Hello, React!")
(.getElementById js/document "app"))
4 changes: 4 additions & 0 deletions test/formatters/samplecode/cljfmt/in.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{:deps {clojure.java-time/clojure.java-time
{:mvn/version "1.1.0"}
}
}
12 changes: 12 additions & 0 deletions test/formatters/samplecode/cljfmt/out.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns hello
(:require [java-time.api :as t]))

(defn time-str
"Returns a string representation of a datetime in the local time zone."
[instant]
(t/format
(t/with-zone (t/formatter "hh:mm a") (t/zone-id))
instant))

(defn run [opts]
(println "Hello world, the time is" (time-str (t/instant))))
6 changes: 6 additions & 0 deletions test/formatters/samplecode/cljfmt/out.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(ns hello-world.core
(:require react-dom))

(.render js/ReactDOM
(.createElement js/React "h2" nil "Hello, React!")
(.getElementById js/document "app"))
2 changes: 2 additions & 0 deletions test/formatters/samplecode/cljfmt/out.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:deps {clojure.java-time/clojure.java-time
{:mvn/version "1.1.0"}}}

0 comments on commit a382795

Please sign in to comment.