Skip to content
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

Unexpected result: Comments moved outside of form #180

Closed
jeaye opened this issue Feb 1, 2025 · 2 comments
Closed

Unexpected result: Comments moved outside of form #180

jeaye opened this issue Feb 1, 2025 · 2 comments

Comments

@jeaye
Copy link
Contributor

jeaye commented Feb 1, 2025

Input source

(def default-data-readers
  (merge
    ; {'uuid #'clojure.uuid/default-uuid-reader}
    ; (when-class "java.sql.Timestamp"
    ;   {'inst #'clojure.instant/read-instant-date})
    ))

Command

❯ standard-clj --version
v0.20.0

❯ standard-clj fix tmp.clj

Output

(def default-data-readers
  (merge))
    ; {'uuid #'clojure.uuid/default-uuid-reader}
    ; (when-class "java.sql.Timestamp"
    ;   {'inst #'clojure.instant/read-instant-date})

Thoughts

This really intrudes with interactive development, especially if we're formatting on save. If I temporarily want to comment out the args to a fn (forget merge and imagine it's anything), standard-clj is going to put the comment after the fn call instead.

If this is what you want to happen here, fair enough. I think it'll be a hassle, though. Perhaps that comes from me being ok with ) on its own line.

Use case

This came straight outta formatting jank's clojure.core. After running fix on it, I've been scanning the diff to see what standard-clj has changed.

@jeaye jeaye changed the title Unexpected result: Comments ignored within form Unexpected result: Comments moved outside of form Feb 1, 2025
@oakmac
Copy link
Owner

oakmac commented Feb 1, 2025

See Issue #60 and Issue #155 for a pretty thorough discussion of this behavior.

The tldr from this comment:

Standard Clojure Style will always gather trailing parens to a single line (as recommended by the Clojure Style Guide and enforced by Parinfer). If you want a ; comment line to 'hold' some parens on the next line, place a comma before them to explicitly show that intent.

@jeaye
Copy link
Contributor Author

jeaye commented Feb 1, 2025

Gah, I should've looked. Thanks, Chris! I'll close this one for ya.

@jeaye jeaye closed this as completed Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants