Skip to content

Support nested indentation rules #70

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

Merged

Conversation

rrudakov
Copy link
Contributor

@rrudakov rrudakov commented Apr 4, 2025

Hopefully the final piece that concerns semantic indentation.

This change generalize the way we detect indentation for macros and special forms and adds support for nested indentation rules (so, for example, separate function clojure-ts--match-method-body is not needed anymore).

I changed to format of clojure-ts-semantic-indent-rules (hopefully it's OK for the version that has not been yet officially released) from (:block n) to ((:block n)) or optionally ((:block n) (:inner n)), which is more consistent with cljfmt format.
New format allows defining rules like ("letfn" . ((:block 1) (:inner 2 0)))).

clojure-ts--dynamic-indent-for-symbol now converts not only top level rule, but the entire spec.


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!

@rrudakov rrudakov force-pushed the feature/nested-indentation-rules branch from 44af05e to a0aca89 Compare April 4, 2025 17:21
@bbatsov
Copy link
Member

bbatsov commented Apr 4, 2025

I changed to format of clojure-ts-semantic-indent-rules (hopefully it's OK for the version that has not been yet officially released) from (:block n) to ((:block n)) or optionally ((:block n) (:inner n)), which is more consistent with cljfmt format.

Yeah, that's fine. Perhaps we can eventually teach CIDER (and maybe clojure-mode as well) to support this format as well, to get closer to the dream of having uniform indentation metadata with cljfmt.

Great change overall!

@rrudakov rrudakov force-pushed the feature/nested-indentation-rules branch from a0aca89 to ec50b30 Compare April 4, 2025 20:22
@rrudakov rrudakov requested a review from bbatsov April 4, 2025 20:24
@bbatsov bbatsov merged commit c8286e2 into clojure-emacs:main Apr 4, 2025
2 of 3 checks passed
@rrudakov rrudakov deleted the feature/nested-indentation-rules branch April 7, 2025 07:47
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

Successfully merging this pull request may close these issues.

2 participants