New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config of list indent size #21
Add config of list indent size #21
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21 +/- ##
==========================================
+ Coverage 73.97% 73.99% +0.02%
==========================================
Files 10 10
Lines 1145 1146 +1
Branches 27 27
==========================================
+ Hits 847 848 +1
Misses 271 271
Partials 27 27
Continue to review full report at Codecov.
|
clojure-style-guide suggested one space indent. This PR enable its style. |
This is great, thanks for tackling this! Based on the number of
(Thanks for your patience on the review, I've been AFK travelling for a few weeks.)
README.md
Outdated
@@ -217,6 +217,17 @@ disabled: | |||
Require all files to end with a newline character. One will be added if it is | |||
not present. | |||
|
|||
* `:list-indent-size` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a significant enough setting that it probably belongs higher up, directly under :indentation?
.
@@ -77,6 +78,7 @@ | |||
::single-import-break-width | |||
::require-eof-newline? | |||
::indents | |||
::list-indent-size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistently placing this key after :indentation?
would be helpful too.
core/src/cljstyle/format/core.clj
Outdated
@@ -271,23 +271,23 @@ | |||
|
|||
(defn- indent-line | |||
"Apply indentation to the line beginning at this location." | |||
[zloc indents] | |||
(let [width (indent/indent-amount zloc indents)] | |||
[zloc indents list-indent-size] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just note here that there's some inconsistency in how this argument is ordered throughout the rest of the changes here. Some places have it as a new final argument like this, others take it as a new second argument. Since this is the more basic of the two configuration arguments here, I think you should consistently place list-indent-size
before indents
and (later) the indenter rule arguments. That will also let you keep some partial
forms intact later on.
core/src/cljstyle/format/indent.clj
Outdated
[[rule-key opts]] | ||
(apply some-fn (map (partial indenter-fn rule-key) opts))) | ||
[list-indent-size [rule-key opts]] | ||
(apply some-fn (map #(indenter-fn rule-key % list-indent-size) opts))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of the ordering inconsistency I mentioned above.
([form-string] | ||
(reindent-string form-string config/default-indents)) | ||
([form-string indents] | ||
(reindent-string form-string 2 config/default-indents)) | ||
([form-string list-indent-size] | ||
(reindent-string form-string list-indent-size config/default-indents)) | ||
([form-string list-indent-size indents] | ||
(reformat-string form-string {:indentation? true | ||
:indents indents}))) | ||
:indents indents | ||
:list-indent-size list-indent-size}))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding some new tests! The rest of the test code would have many fewer changes if you kept the two-argument version as-is accepting indents
and used the three-argument version for the list-indent-size
when you needed it. Seems like a lot of the existing tests just got a 2
inserted.
Thanks for reviewing. I fixed them. Please re-review. |
This PR is related to #8.
Add config of list indent size.
If this config is set to 1. Codes is formatted as below.
(foo bar baz)