-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
Make it possible to get uniform indentation #607
Conversation
While Emacs and clojure-mode have good support for "lisp-style" indentation, and provided fine-grained customization via indent-specs, some prefer "dumb" indentation where every single form gets the same level of indent, regardless of whether it's a macro, whether there are arguments on the same line as the function name, etc. Currently this is not possible without redefining certain functions because of hard-coded values that handle specific cases, namely the indent-spec case, and the keyword invocation case (`(:require ...)`). This introduces two new defcustoms, one allows completely disabling the indent-spec handling, so the first hard-coded case is skipped, the second allows specifically customizing the second case. This should allow "tonsky style" formatting with ``` (setq clojure-indent-style 'always-indent clojure-indent-keyword-style 'always-indent clojure-enable-indent-specs nil) ```
Will let this sit here for a bit while I dogfood it. |
I assume the people who like fixed indentation don't care about this level of granularity, so this can be just a an extra |
FWIW, |
@plexus Should we merge the PR? I guess by now you had enough time to test it. |
Sure, if folks are happy with it. I don't generally like or use this style of indentation, except that one time a few years ago when a client project was using it. I don't remember much about this PR, but I guess it works? |
From memory, the only reason why @dannyfreeman made that style available in clojure-ts-mode is because it was simpler to implement, in the context of bootstrapping a functional solution. Maybe we can use whatever influence we have to avoid a proliferation of styles. All formatters default to something traditionally emacs-y anyway. And Cursive can be trivially configured to follow the same style. Tools have only become more handy since the infamous blog post that suggested the idea of a style that really didn't take off but still is requested from time to time. I mean, by now cljfmt can be invoked in many, instantaneous ways (via clojure-lsp, cider, a graalvm binary) - besides from the editor-native formatting that will typically match cljfmt. What problem are we solving? |
That some people like this formatting and don't care about the alternatives? 😉 To be fair some people liked this even before the famous blog post by Nikita - that's why |
While Emacs and clojure-mode have good support for "lisp-style" indentation, and
provided fine-grained customization via indent-specs, some prefer "dumb"
indentation where every single form gets the same level of indent, regardless of
whether it's a macro, whether there are arguments on the same line as the
function name, etc.
Currently this is not possible without redefining certain functions because of
hard-coded values that handle specific cases, namely the indent-spec case, and
the keyword invocation case (
(:require ...)
).This introduces two new defcustoms, one allows completely disabling the
indent-spec handling, so the first hard-coded case is skipped, the second allows
specifically customizing the second case.
This should allow "tonsky style" formatting with
Closes #526
Replace this placeholder text with a summary of the changes in your PR.
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):
M-x checkdoc
and fixed any warnings in the code you've written.Thanks!