-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
Inconsistent indentation for macros #3490
Comments
Thanks for the detailed report! Checking out https://github.com/alexanderjamesking/spy/blob/e27887b3a0a9c9e5078e773b92b84c7571ce59a5/src/clj/spy/assert.clj, I'd say that the issue is that There was a similar case asked about here: https://clojurians.slack.com/archives/C0617A8PQ/p1695695401220199?thread_ts=1695694483.271689&cid=C0617A8PQ The solution is to add So I'd recommend a PR against that repo. You can iteratively try out indentation styles using Cheers - V |
Thank you for quick response @vemv! Maybe it would be a good idea to introduce some |
I had a similar problems a few times already (e.g. promesa threading macros). |
Without inference, a lot of other macros will look non-idiomatic. CIDER has always fostered I believe inference forces users to be more aware of https://docs.cider.mx/cider/indent_spec.html and to add it from time to time. That's a good thing. CIDER's job is not only to be compatible with cljfmt "no matter how", but for your Clojure code to look actually more accurate/informative. The best we could do, probably, is to add a whiltelist for macros that shouldn't be infered. But then again, if you are configuring that, you could as well be configuring |
Another approach that could alleviate this as a "side-effect" is supporting .cljfmt.edn files (clojure-emacs/cider-nrepl#754) I intend to get back at that PR after we release CIDER 1.8.0. |
@vemv Perhaps short-term you can just expand the docs to feature something in "Troubleshooting" or the indentation section, so it's easier for to find the information they are looking for. |
I guess this is a different issue but reading https://docs.cider.mx/cider/indent_spec.html#indentation-inference I can create a new issue for it if you think this is a bug. Otherwise I'll make a PR to promesa adding :style/indent. |
Thanks! I'll check it out today |
I've fixed that (if you are curious: clojure-emacs/orchard@13c3ea7) and will let you know when cider-nrepl is bumped - should happen during this weekend. |
🎉 Awesome, thanks. |
cider-nrepl 0.39.0 has been released with those changes. It's injected by CIDER latest (Git master, or the MELPA snapshot that will be visible within a couple hours) |
I've released cider-nrepl 0.40.0 / cider 1.18.2 with a further fix. It's not directly related to indentation inference, however it fixes certain indentation cases for clojurescript. |
I am (still?) seeing unexpected indentation with Promesa's threading macros here (i.e. the first form is treated as a "head") using ClojureScript. You mention CIDER 1.18.2 which I assume is a typo - judging from the date you posted the comment, you probably meant 1.8.2. In any case, there appears to be a regression... |
Please create a separate issue in detail Thanks - V |
Expected behavior
cljfmt
M-x cider-format-buffer
is called.Actual behavior
Indentation is inconsistent (see screenshots)
Steps to reproduce the problem
deps.edn
content:src/com/example/app.clj
content:M-x cider-jack-in
123
) and pressTAB
(indent-for-tab-command
).123
will be indented as "body" (with 2 spaces indentation relative to the previous line)M-x cider-format-buffer
.123
will be aligned vertically withfoo
(as function arguments)If I place
foo
to the new line the indentation is even more weird:I assume it's related to indentation inference? In stable CIDER 1.8 the indentation is correct:
Environment & Version information
CIDER version information
Lein / Clojure CLI version
Clojure CLI 1.11.1
Emacs version
GNU Emacs 29.1.50 (build 1, aarch64-apple-darwin23.0.0, NS appkit-2487.00 Version 14.0 (Build 23A344)) of 2023-09-28
Operating system
MacOS 14
JDK distribution
The text was updated successfully, but these errors were encountered: