weavejester / cljfmt

A tool for formatting Clojure code
Eclipse Public License 1.0
1.11k stars 120 forks source link

Feature request: indent rule for all unspecified functions #266

Closed sirmspencer closed 1 year ago

sirmspencer commented 2 years ago

Allow an indent rule to be created for all functions / macros that are not defined here or in the :indents map.

Half of our team is using Cursive, which favors this form for multi line function calls. Note the two space indent.

(some-fn
  (another -fn)
  arg2

The indent rule to replace all doesnt work for two reasons. 1) regex is invalid when using a .cljfmt.edn file, and 2) Cursive follows the same indent rules for almost every rule that is a default for cljfmt. because Cursive only uses the default 2 space indent for unknown functions. Globally changing all forms to [:block 0] changes more code than not. Something like this maybe

{:indents {defstate [[:block 2]]}
  :list-indent 2}
leafgarland commented 2 years ago

I'm using cljfmt via clojure-lsp, and I can set regex rules using #re ".*" note the #re tag. Not sure if this is done by clojure-lsp or cljfmt.

sirmspencer commented 1 year ago

@leafgarland Where you able to set that regex rule, but then also other rules that supersede the regex?

weavejester commented 1 year ago

You should be able to add it to your configuration, so in cljfmt.edn or cljfmt.clj, or in your Leiningen project.clj file. See the README for an explanation of how to configure.

sirmspencer commented 1 year ago

This does work. Its been a while so I don't remember why it didn't work before.