diff --git a/CHANGELOG.md b/CHANGELOG.md index cb03f72..9f6db45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog]. +## Unreleased +### Formatters +* [cljstyle](https://github.com/greglook/cljstyle) + for clojure, clojurescript, edn files. + ## 4.3 (released 2024-11-12) ### Features * New user option `apheleia-skip-functions`, like diff --git a/apheleia-formatters.el b/apheleia-formatters.el index bef7aa0..af572a6 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -42,6 +42,7 @@ (apheleia-formatters-mode-extension) ".c"))) (cljfmt . ("cljfmt" "fix" "-")) + (cljstyle . ("cljstyle" "pipe")) (cmake-format . ("cmake-format" "-")) (crystal-tool-format . ("crystal" "tool" "format" "-")) (css-beautify "css-beautify" "--file" "-" "--end-with-newline" diff --git a/test/formatters/installers/cljstyle.bash b/test/formatters/installers/cljstyle.bash new file mode 100644 index 0000000..bffdfcf --- /dev/null +++ b/test/formatters/installers/cljstyle.bash @@ -0,0 +1 @@ +curl -sLO "https://raw.githubusercontent.com/greglook/cljstyle/main/util/install-cljstyle" && chmod +x install-cljstyle && ./install-cljstyle diff --git a/test/formatters/samplecode/cljstyle/in.clj b/test/formatters/samplecode/cljstyle/in.clj new file mode 100644 index 0000000..c783b0f --- /dev/null +++ b/test/formatters/samplecode/cljstyle/in.clj @@ -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)))) diff --git a/test/formatters/samplecode/cljstyle/in.cljs b/test/formatters/samplecode/cljstyle/in.cljs new file mode 100644 index 0000000..1649480 --- /dev/null +++ b/test/formatters/samplecode/cljstyle/in.cljs @@ -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")) diff --git a/test/formatters/samplecode/cljstyle/in.edn b/test/formatters/samplecode/cljstyle/in.edn new file mode 100644 index 0000000..88af84a --- /dev/null +++ b/test/formatters/samplecode/cljstyle/in.edn @@ -0,0 +1,4 @@ +{:deps {clojure.java-time/clojure.java-time +{:mvn/version "1.1.0"} + } + } diff --git a/test/formatters/samplecode/cljstyle/out.clj b/test/formatters/samplecode/cljstyle/out.clj new file mode 100644 index 0000000..69c2dbb --- /dev/null +++ b/test/formatters/samplecode/cljstyle/out.clj @@ -0,0 +1,16 @@ +(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)))) diff --git a/test/formatters/samplecode/cljstyle/out.cljs b/test/formatters/samplecode/cljstyle/out.cljs new file mode 100644 index 0000000..a2f1106 --- /dev/null +++ b/test/formatters/samplecode/cljstyle/out.cljs @@ -0,0 +1,8 @@ +(ns hello-world.core + (:require + [react-dom])) + + +(.render js/ReactDOM + (.createElement js/React "h2" nil "Hello, React!") + (.getElementById js/document "app")) diff --git a/test/formatters/samplecode/cljstyle/out.edn b/test/formatters/samplecode/cljstyle/out.edn new file mode 100644 index 0000000..9c0ad45 --- /dev/null +++ b/test/formatters/samplecode/cljstyle/out.edn @@ -0,0 +1,2 @@ +{:deps {clojure.java-time/clojure.java-time + {:mvn/version "1.1.0"}}}