Skip to content

Add suport for clojure-align-forms-automatically #16

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

Open
jasonjckn opened this issue Aug 13, 2023 · 10 comments
Open

Add suport for clojure-align-forms-automatically #16

jasonjckn opened this issue Aug 13, 2023 · 10 comments
Labels
enhancement Enhancement to existing functionality
Milestone

Comments

@jasonjckn
Copy link
Contributor

jasonjckn commented Aug 13, 2023

(setq clojure-align-forms-automatically t) in clojure-mode.el

'indents'

{:a 1
 :bbbb  2} 

to

{:a    1
 :bbbb 2}
@dannyfreeman dannyfreeman added the enhancement Enhancement to existing functionality label Aug 17, 2023
@dannyfreeman
Copy link
Contributor

This will depend on semantic indentation being done (at least the first pass). Once that is in place I plan to look into this.

@dannyfreeman
Copy link
Contributor

Dev Note: check out builtin align.el and see if that can be used to implement this.

@kommen
Copy link
Contributor

kommen commented Feb 11, 2024

Related: Since clojure-emacs/clojure-mode#673 clojure-align works from clojure-ts-mode buffers, which is implemented based on the builtin align.el

@jasonjckn
Copy link
Contributor Author

jasonjckn commented Feb 16, 2024

@kommen
I've been using clojure-ts-mode with clojure-align-forms-automatically like this

      (setq-local indent-line-function #'clojure-indent-line)
      (setq-local indent-region-function #'clojure-indent-region)
      (setq-local aggressive-indent-region-function #'clojure-indent-region)
      (setq-local lisp-indent-function #'clojure-indent-function)

never hit that bug you fixed, are you just keybinding clojure-align, or how do you use this with clojure-ts-mode

@kommen
Copy link
Contributor

kommen commented Feb 16, 2024

@jasonjckn I'm not using clojure-align-forms-automatically and I don't have any of the setq-local you use. I was calling it wit hM-x clojure-align, as I only use it occasionally.

Also, because I ran into performance problems with aggressive-indent-mode and clojure-mode's indent functions, I do want to use the treesit-indent-* functions come as default for clojure-ts-mode , as they don't have these performance problems.

@jasonjckn
Copy link
Contributor Author

@jasonjckn I'm not using clojure-align-forms-automatically and I don't have any of the setq-local you use. I was calling it wit hM-x clojure-align, as I only use it occasionally.

Also, because I ran into performance problems with aggressive-indent-mode and clojure-mode's indent functions, I do want to use the treesit-indent-* functions come as default for clojure-ts-mode , as they don't have these performance problems.

i'm also a big aggressive indent user, one cool way to get aligned forms without ever relying on clojure-mode in-process, is have https://github.com/radian-software/apheleia invoke a separate process every time you save the buffer, and run clojure-mode across your whole buffer, it works great. https://gist.github.com/jasonjckn/750e01086b24bcaacef3946c698943c2

@bbatsov
Copy link
Member

bbatsov commented Feb 18, 2024

I liked the concept of aggressive-indent-mode, but for me the simple electric-indent-mode (enabled by default in recent Emacsen) and indent-buffer yield almost the same result with much less overhead on the recalculating indentation.

@bbatsov
Copy link
Member

bbatsov commented Apr 15, 2025

@rrudakov Perhaps you can look into this?

@rrudakov
Copy link
Contributor

@rrudakov Perhaps you can look into this?

I think the first step would be to port clojure-align function to clojure-ts-mode, which probably can be just copied. It uses built-in align commands, which will work the same way for TreeSitter based mode.

I'll take a look how clojure-align-forms-automatically works in clojure-mode.

@bbatsov bbatsov modified the milestones: Version 1, 1.0 Apr 15, 2025
@bbatsov
Copy link
Member

bbatsov commented Apr 16, 2025

I think the first step would be to port clojure-align function to clojure-ts-mode, which probably can be just copied. It uses built-in align commands, which will work the same way for TreeSitter based mode.

Yeah, probably that will be simpler than expected at this point.

rrudakov added a commit to rrudakov/clojure-ts-mode that referenced this issue Apr 18, 2025
rrudakov added a commit to rrudakov/clojure-ts-mode that referenced this issue Apr 18, 2025
rrudakov added a commit to rrudakov/clojure-ts-mode that referenced this issue Apr 18, 2025
rrudakov added a commit to rrudakov/clojure-ts-mode that referenced this issue Apr 18, 2025
rrudakov added a commit to rrudakov/clojure-ts-mode that referenced this issue Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to existing functionality
Projects
None yet
Development

No branches or pull requests

5 participants