-
Notifications
You must be signed in to change notification settings - Fork 120
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
Configuration option for two space list indentation #324
Configuration option for two space list indentation #324
Conversation
Thanks for the PR. Let's invert the option, I think, since it's often more intuitive to enable optional settings, rather than to disable them. So instead, Regarding |
What if we just have a single flag with 3 preset values? something like
|
referring directly to the other projects is probably not ideal as then that adds a maintenance burden to make sure we stay in sync. So maybe some more semantic names
|
That's a tough decision. I agree that descriptive names would be less confusing if zprint or cursive changed their defaults. On the other hand, the shorter names can be used more easily in arguments, and What about this: we use This also allows for potentially more complex indentation rules that cannot easily be boiled down to a short description, as in the case of the community standard. Thoughts? |
I like that plan :) I've pushed a new commit with the change (will squash later after the PR is ready to merge) |
politely bumping this @weavejester |
Thanks for the bump, I managed to miss the notification before. As part of the tests, one thing I notice as missing is: (foo bar
baz) Which in the community standards is formatted as: (foo bar
baz) How does this compare to zprint and Cursive? |
Cursive & Zprint would do the same thing in that scenario. We're only applying this new config when there are no arguments on the same line as the function name. Having a test for that would be a good idea though! I'm not completely convinced that the way I added new tests makes sense. What I actually did was changed the default setting to |
I think that's a reasonable way to add new tests. However, I'd suggest adding the case with one argument on the same line, just to ensure that the original behavior remains the same in that case, and to prevent any future regressions. Otherwise, everything else looks good. |
Done 👍 |
bump 🙂 |
Sorry for the delay. This all looks good! Can you ensure that all lines are under 80 characters in length - I think there are a couple that are a little too long and just need to be broken up onto two lines - and then if you squash your commits down we should all be ready to merge and cut a new release. Thanks for all your work on this. |
a82e1d2
to
49d63a2
Compare
done and done 👍 |
Thanks! Could you change the commit message to:
cljfmt follows the seven rules of a great git commit message for its commit messages. Once that's done, I'll merge and release. |
Add a new configuration option, :function-arguments-indentation, that can be one of: :community, :cursive or :zprint. This controls the behavior described in: https://guide.clojure.style/#one-space-indent When set to :community (the default) it follows the Clojure style guide. When set to :cursive or :zprint, it follows the conventions used by those tools. Also add a --function-arguments-indentation option to update this at the command line.
49d63a2
to
d84bd41
Compare
Sure thing, done! |
bump 😉 |
Merged! Sorry for the delay. |
Closes #323
Updated approach:
Adds a new config option
:function-arguments-indentation
with 3 possible values::community
- the default, and same as current behaviour. Follows the community style recommendation to indent function/macro arguments by a single space when there are no arguments on the same line as the function name.:cursive
copies Cursive's behaviour when it has "one space list indent" disabled (which is the default). Indents lists by 2 spaces when there is only one element on the first line, unless the first element (not counting metadata) is a data structure literal.:zprint
copies zprint's default behaviour. Uses two space indentation if a list starts with a symbol or a keyword and has no arguments on the same line as that symbol/keyword.Original approach: