diff --git a/cljfmt/src/cljfmt/core.cljc b/cljfmt/src/cljfmt/core.cljc index 399dd1d..561a1a4 100644 --- a/cljfmt/src/cljfmt/core.cljc +++ b/cljfmt/src/cljfmt/core.cljc @@ -337,6 +337,11 @@ (defmethod indenter-fn :block [sym context [_ idx]] (fn [zloc] (block-indent zloc sym idx context))) +(defmethod indenter-fn :default [sym context [_]] + (fn [zloc] + (when (form-matches-key? zloc sym context) + (list-indent zloc context)))) + (defn- make-indenter [[key opts] context] (apply some-fn (map (partial indenter-fn key context) opts))) diff --git a/cljfmt/test/cljfmt/core_test.cljc b/cljfmt/test/cljfmt/core_test.cljc index f64b372..a4c98f7 100644 --- a/cljfmt/test/cljfmt/core_test.cljc +++ b/cljfmt/test/cljfmt/core_test.cljc @@ -1260,6 +1260,14 @@ ["{:one two #_comment" " :three four}"] {:split-keypairs-over-multiple-lines? true})) + (is (reformats-to? + ["(with-timezone (java.time.OffsetDateTime.)" + "\"US/Pacific\")"] + ["(with-timezone (java.time.OffsetDateTime.)" + " \"US/Pacific\")"] + {:indents {#"^with-" [[:inner 0]] + 'with-timezone [[:default]]}}) + "Should be able to override fuzzy indent rules for with- and explicitly specify :default indentation") #?(:clj (is (reformats-to? ["(ns foo.bar"