clojure-emacs / clojure-ts-mode

The next generation Clojure major mode for Emacs, powered by TreeSitter
GNU General Public License v3.0
129 stars 11 forks source link

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

Open jasonjckn opened 1 year ago

jasonjckn commented 1 year ago

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

'indents'

{:a 1
 :bbbb  2} 

to

{:a    1
 :bbbb 2}
dannyfreeman commented 1 year ago

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 commented 10 months ago

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

kommen commented 7 months ago

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

jasonjckn commented 6 months ago

@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 commented 6 months ago

@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 commented 6 months ago

@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 commented 6 months ago

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.