greglook / cljstyle

A tool for formatting Clojure code
Eclipse Public License 1.0
293 stars 39 forks source link

formatting for `:require` and `:import` #26

Closed dharrigan closed 4 years ago

dharrigan commented 4 years ago

Hi,

Thanks for the utility. I was wondering if there was a way to consider adding the ability to apply the styling as discussed here:

Clojure Style

(ns foo.bar
  (:require
   [honeysql.core :as sql]
   [clojure.string :as str]))

Applying cljstyle at the moment displays this:

--- a/src/foo/bar.clj
+++ b/src/foo/bar.clj
@@ -1,8 +1,8 @@
 (ns foo.bar
   (:require
-   [honeysql.core :as sql]
-   [clojure.string :as str]))
+    [clojure.string :as str]
+    [honeysql.core :as sql]))

You'll notice that the require is 2 spaces in, but then the statements after are only 1 space in (this is also the same for imports).

I do understand that the Clojure Style guide is one person's work, but it does have traction within the community and whilst not everyone agrees 100% of what it says, there are parts that are nice - and this particular formatting of the imports/requires is nice :-)

Thank you for your time and consideration.

-=david=-

greglook commented 4 years ago

Glad you're finding the tool useful! I think what you want is covered by setting :list-indent-size 1 in your configuration, but this wasn't applied to namespaces until #25. The next release of cljstyle will contain that fix.

dharrigan commented 4 years ago

Hi!

That's great news! :-) Thank you kindly!

-=david=-

greglook commented 4 years ago

This is fixed in version 0.11.1 now.