guns / vim-clojure-static

Meikel Brandmeyer's excellent Clojure runtime files
Other
420 stars 50 forks source link

Add indent special case for Reader Conditionals #69

Closed Deraen closed 8 years ago

Deraen commented 9 years ago

Currently reader conditionals are indented like function calls, but instead I think they should be intended like vectors and maps:

;; Current
(def DateTime #?(:clj org.joda.time.DateTime,
                      :cljs goog.date.UtcDateTime))

;; Correct
(def DateTime #?(:clj org.joda.time.DateTime,
                 :cljs goog.date.UtcDateTime))

;; Current
#?(:cljs
    (extend-protocol ToDateTime
      goog.date.Date
      (-to-date-time [x]
        (goog.date.UtcDateTime. (.getYear x) (.getMonth x) (.getDate x)))))

;; Correct
#?(:cljs
   (extend-protocol ToDateTime
     goog.date.Date
     (-to-date-time [x]
       (goog.date.UtcDateTime. (.getYear x) (.getMonth x) (.getDate x)))))

Implemented by just looking at previous two chars before parentheses. This wont support cases where reader conditional is not on the same line as parentheses, but I don't think that is a problem.

uwo commented 8 years ago

+1

guns commented 8 years ago

Great commit. Thanks for using the existing test setup!