Fork me on GitHub
#calva
<
2023-09-06
>
sergey.shvets18:09:33

Is there a way to make sure that calva read the .cljfmt.edn file? I have a very simple macro that should be indented the same way as let but it seems that calva ignores that line from config.

pez18:09:51

What does the config look like?

pez18:09:13

Also check that you haven’t configured calva.fmt.configPath to point to some other file.

sergey.shvets18:09:12

it's trivial {:extra-indents {appspark.core/stream-loop [[:block 1]]}} But I see that I have "new structural engine" enabled. Can this be the cause?

pez21:09:31

Depends on what it is that is not working. The indenter is responsible for placing the cursor at the right column when you press enter. The formatter, formats code. (Like when you press tab to format the enclosing form.) They sometimes disagree, because the indenter is not as smart with the cljfmt config as the real cljfmt. You could try with just stream-loop, there and see if that changes anything, or just add an extra rule with that.

sergey.shvets23:09:52

It looks like whatever I put doesn't affect formatting. Right now it aligns the "body" with bindings

(stream-loop [a b]
             (body-code))  
And I'd like it to be similar to let
(stream-loop [a b]
  (body-code))  
According to the https://github.com/weavejester/cljfmt/blob/master/docs/INDENTS.md#macro-with-bindings-and-body it should work, but it doesn't. So my assumption that for whatever reason calva doesn't see my config.

sergey.shvets00:09:25

It formats like in the first example on tab and newline puts cursor under first square bracket too.

sergey.shvets00:09:23

Hm, turning off new indent engine and removing fqn for the symbol did the trick.

{:extra-indents {stream-loop [[:block 1]]}
 :test-code
 (stream-loop [a b]
   asdad)}

sergey.shvets00:09:33

ok, it works now. I put explicit path to cljfmt and removed fully qualified name and it worked. Structural editing checkbox seems to not make a difference.

sergey.shvets00:09:07

Thank you for the help!!

pez06:09:50

It can be a pit finicky. Though I wonder why the default path setting didn’t work. Where was the file located? What’s your setting now?

sergey.shvets15:09:25

it's in the root .cljfmt.edn . I just typed that string in the settings.

pez15:09:43

And you don’t have it in your user settings as something else? What OS are you on?

sergey.shvets17:09:35

OS X 12.6.2 Intel Mac. I think the issue was that I had fully qualified name in config and it just needed a symbol. I now removed the string .cljfmt.edn from Fmt: Config Path and it still works. Probably, I haven't reloaded it properly between some tries.

pez19:09:57

Ah, thanks. I think we might need some way to validate the config. This is too finicky to get working.