venantius / vim-cljfmt

A Vim plugin for cljfmt, the Clojure formatting tool.
152 stars 22 forks source link

datomic datalog query indentation #25

Closed chadhs closed 8 years ago

chadhs commented 8 years ago

when experimenting with datomic…

this

(d/q '[:find ?owner-name
       :where [?dog :dog/name "Tiny"]
              [?owner :owner/dogs ?dog]
              [?owner :owner/name ?owner-name]]
     (d/db conn))

becomes

(d/q '[:find ?owner-name
       :where [?dog :dog/name "Tiny"]
       [?owner :owner/dogs ?dog]
       [?owner :owner/name ?owner-name]]
     (d/db conn))
venantius commented 8 years ago

The corrected indentation here is the right / expected one.

chadhs commented 8 years ago

@venantius most of the datomic datalog examples i've seen all have the :where conditions aligned, which seems more readable to me.

i can imagine accounting for every scenario is monumental task, and perhaps this is something i could be asking about at the cljfmt project level?

Btw, this plugin coupled with electric return option in paredit make my vim clojure experience near magical. thnx!

venantius commented 8 years ago

@chadhs are you sure those examples don't have the where conditions nested in their own vector?

chadhs commented 8 years ago

Tried that and seemed to cause 'splosions 😔

venantius commented 8 years ago

Gotcha. I took a look at the Datomic docs and it seems you're right, they don't belong in the vector.

That having been said, the alignment you're getting from vim-cljfmt is the expected alignment for these data structures. I'd verify that with the lein-cljfmt plugin first and raise an issue with weavejester if you want to bring it up to him. I think cljfmt might support configuration for the sort of indentation you want to do -- if that turns out to be the case, this issue would then support https://github.com/venantius/vim-cljfmt/issues/24

chadhs commented 8 years ago

:+1: thanks @venantius