-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Calva doesn't respect .cljfmt.edn
indent rules with namespaced function names
#2772
Comments
Hello, thanks for reporting! I think part of the problem here is that Calva only formats the form enclosing the cursor. So only the macro invocation in the above example. That means that the cljfmt in Calva never sees the I'm not sure what the fix would be, or even if this is the whole story, but anyway. |
Thanks for the prompt reply, Pez! Even though Calva doesn't read the Would it be possible to parse the I see |
Let's calibrate a bit:
pez-cljfmt is a decoy. 😄 It's an old fork of cljfmt that is only used when you use the Format and Align command. |
Thanks for the details. It seems we have a few different sub-issues which can be worked on. From least to most effort I am thinking:
I haven't been able to get Also, regarding cljfmt as a cljs library, this issue from cljfmt might be relevant: weavejester/cljfmt#200 |
Makes sense. I now checked what happens with That + your research indicate that this may just be untapped potential in cljfmt as a ClojureScript library, as @lread has since quite a while fixed the underlying reasons.
This could also be solved by including the ns-form when handing over the text to cljfmt and then stripping it away again when handling the results of the formatting. I think that is easier than parsing out the aliases. And it would also centralize this parsing to cljfmt, avoiding confusion in bug incompatibilities and such. (I'm not saying I have thought this through and know which way is best, just thinking out loud.) Wanna have a go at |
So after WeaveJester pointed me in the right direction for using
Yes, I was also thinking about a solution like this. I guess the trade-off is between the complexity of stripping away the
Yes, I think it would be fun to have a go at this. Since I'm completely new to the Calva codebase I would love some pointers for where and how to start implementing this. @pbwolf could you chime in with how your PR would affect this? |
Cool! It starts on the wiki under https://github.com/BetterThanTomorrow/calva/wiki/How-to-Hack-on-Calva
I don't right now recall if we always get If you are on Clojurians Slack, you can always say hello in the Very surprising that |
I've been having some issues with custom cljfmt indent rules in Calva. It seems that Calva doesn't resolve namespaces on the indent rules, so the it isn't picked up when formatting the relevant forms.
I've made a reproduction repo which reproduces the issue for me in a fresh vscode profile with just Calva installed.
Calva and
cljfmt
from commandline agrees when I spell out the full namespace of the macro, as demonstrated in the.cljfmt.edn
file:But when the macro is used with a
:require [... :as ...]
, Calva andcljfmt
gives different results, as shown in therepro
namespace:Adding
:alias-map {macro repro.macro}
to.cljfmt.edn
doesn't help, neither does disabling the new indent engine in Calva or manually specifying the path to the cljfmt config.If I change the rule to just
:extra-indents {example-macro [[:block 2]]}
, it works.The text was updated successfully, but these errors were encountered: