Skip to content

Improve semantic indentation rules to be more consistent with cljfmt #67

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged

Conversation

rrudakov
Copy link
Contributor

Example:

image

Before submitting a PR mark the checkboxes for the items you've done (if you
think a checkbox does not apply, then leave it unchecked):

  • The commits are consistent with our contribution guidelines.
  • You've added tests (if possible) to cover your change(s). Bugfix, indentation, and font-lock tests are extremely important!
  • You've run M-x checkdoc and fixed any warnings in the code you've written.
  • You've updated the changelog (if adding/changing user-visible functionality).
  • You've updated the readme (if adding/changing user-visible functionality).

Thanks!

@bbatsov
Copy link
Member

bbatsov commented Mar 26, 2025

The proposal seems reasonable to me - from what I gather the essence here is that we want to treat differently forms depending on the position of their body/forms param.

Might be a good idea to mention this somewhere in the README, and I'm also wondering if we should make this configurable like in clojure-mode (there you can add extra forms to the various indentation categories, so you'd get consistent indentation for your macros as well).

Making this configurable is also need for CIDER to be able to insert indentation rules itself, based on forms indentation specs.

@rrudakov rrudakov force-pushed the feature/improved-indentation-rules branch from a4b20f6 to eb6841e Compare March 26, 2025 13:41
@rrudakov
Copy link
Contributor Author

Thanks you for the review @bbatsov. I've refactored the code. It's less repetitive now and rules are customizable via clojure-ts-semantic-indent-rules variable. I also updated README. Please let me know what do you think.

README.md Outdated
custom rules as:

```emacs-lisp
(setopt clojure-ts-semantic-indent-rules '(("are" . (:block 1))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to have several forms here, so it's clearer what the format is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be good to explain also the various block and inner values here, similar to how it's done in clojure-mode's docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've adapted some examples from clojure-mode documentation and added some explanation about the rules.

@rrudakov rrudakov force-pushed the feature/improved-indentation-rules branch from eb6841e to 5f4a4e1 Compare March 26, 2025 14:21
@rrudakov rrudakov force-pushed the feature/improved-indentation-rules branch from 5f4a4e1 to 874ff54 Compare March 26, 2025 15:30
@rrudakov rrudakov requested a review from bbatsov March 26, 2025 15:35
Copy link
Member

@bbatsov bbatsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@bbatsov bbatsov merged commit 4cf4bd1 into clojure-emacs:main Mar 26, 2025
2 of 3 checks passed
@rrudakov rrudakov deleted the feature/improved-indentation-rules branch March 26, 2025 19:25
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants