-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Format clojure files with babashka shebang #2218
Comments
Hi! Thanks for reporting! I can't reproduce the problem. Format on save happens with or without the shebang... |
I also tried and cannot reproduce. Maybe take a look at the values you have for other settings, @jakepearson. I suppose there's also a chance another extension could be interfering. |
Thanks for trying. I'll fiddle around in vscode a bit. Is there a way to show what the formatted is doing in one of the output windows? |
There's is no diagnostics for the formatter. The combination of settings that could be involved is pretty huge. If you haven't been using VS Code Insiders, a way to approach this ”from the other end” is to install it, enable format-on-save, install Calva and see if it still happens. Then, if not, see if pasting your settings json from regular VS Code into that of Insiders provokes it. If that fails, it could be some other extension at play. VS Code has a feature Extension Bisect, that you can reach from the Extensions pane's top meatballs menu. It could potentially help. |
Thanks for the ideas. I'll try it later today. |
I did more digging and was able to figure it how to re-pro. If I start with a totally blank project and vscode with just calva installed, the formatter works. But if I add in a {:align-associative? true} and set Ideas? |
Good hunting! It's probably that the ancient version of cljfmt that is used for align-associative does not format files starting with a shebang. |
Is there anything I newcomer like myself could do to try to fix this? |
I totally appreciate that attitude, @jakepearson. First I want to say that I wish we didn't have the align-associative feature in Calva. I put it there by sheer enthusiasm way back when, and have chosen not to remove it, because I know some people like it and are OK with it not being perfect. If you didn't know, there is an on-demand way of invoking the alignment formatting. So I suggest you do not use that setting. But, if you want to use it, I am not one to stop you. 😄 If you want to fix this particular issue, I think you could maybe find the commits that fixed the issue in cljfmt and apply them in the old copy of cljfmt that Calva uses for supporting the alignment feature: https://github.com/BetterThanTomorrow/calva/blob/dev/src/cljs-lib/src/pez_cljfmt/core.cljs I'd accept a PR doing this. That said, there are more issues with the ancient cljfmt version, and we're not exactly planning on addressing them. BTW, maybe it is not fuly clear: For non-alignment formatting we are depending on a recent version of cljfmt. The ancient copy is only for supporting this alignment feature. |
FYI, I see there's been work on adding support for aligning associative forms to cljfmt as recent as 3 days ago: weavejester/cljfmt#299. 👏 👏 👏 Maybe soon we can git rid of Calva's modified old version. |
Awesome. I've been following that thread a bit. Let's hope it reaches the trunk this time! |
I love the look of align associative, but also didn't realize until this morning that it wasn't part of cljfmt's core feature set (I must have copied my cljfmt config from somewhere in calva's documentation). I'm going to drop it from my team's shared config and will hopefully get to put it back on based on the work going on in cljfmt. Thanks for the great support and for the great product! |
You're welcome, @jakepearson! Closing this, because it is a bit hard to take any action on. Let's hope cljfmt proper will add support soon. |
I noticed that if I have a
babashka
shebang
on the top of aClojure
file, it is not formatted withCalva
. I started withcljfmt
, and it turnscljfmt
is working (weavejester/cljfmt#306) and will format the file via command line so I think there is something withCalva
. To reproduce create aClojure
file with the following contents:I have format on save turned on so I expect
b
to line up witha
andc
on save. It does not, but if I comment out the shebang at top the and save, the formatting happens. Is there a setting that I need to change? If this is a bug, I would be happy to work on it if someone can point me in the right direction.Thanks for the great tool!
The text was updated successfully, but these errors were encountered: