Fork me on GitHub
#calva
<
2023-06-23
>
seancorfield02:06:33

If I'm using the new formatting engine (instead of cljfmt), how can I teach it that I want expecting to be indented the same way as testing (and other, similar "with"-style indent words)?

pez08:06:35

Is it indented as you want when formatting it?

seancorfield17:06:19

No. I get this:

(testing "foo"
  (is (= 1 1)))

(expecting "foo"
           (expect 1 1))

seancorfield17:06:44

(both when typing code and pressing return and also when formatting the code separately)

pez18:06:07

I see. You need to provide indentation rules for those symbols. See https://calva.io/formatting/#configuration

seancorfield19:06:58

Since I'm using the "new formatting engine (instead of cljfmt)" -- is it still driven by the cljfmt configuration? That was certainly not clear to me...

seancorfield20:06:53

It's also not obvious where to put global formatting configuration? The weavejester repo talks about per-project config but this config would need to be in any project that uses Expectations...

seancorfield20:06:57

(The weavejester repo says I could put .cljfmt.edn in a parent folder but that doesn't seem to be picked up by Calva?)

pez20:06:05

You need to tell Calva where you have your cljfmt config file. Calva is using cljfmt as a library. If you keep the config outside the workspace Calva will not hot reload changes. But you can open the folder with where the config lives to tinker with it and have ht reload.

pez20:06:41

Yes, Calva’s indent engine reads the same cljfmt config as the formatter does.

seancorfield20:06:48

Even with .cljfmt.edn in the top folder of the workspace, it doesn't seem to work...

pez20:06:33

Have you told Calva where the file is?

pez20:06:12

iirc there is no default. Let me check…

pez20:06:50

Yep, no default for calva.fmt.configPath.

seancorfield20:06:27

OK, so if I put .cljfmt.edn in .calva and configure Calva with .calva/.cljfmt.edn as the path, it should pick it up?

pez20:06:43

It should.

seancorfield20:06:53

Ah, finally got it working...

seancorfield20:06:29

Does calva.fmt.configPath allow for ~ or env vars? Just wondering how to get global configuration on every project on every machine...

pez20:06:32

I don’t know why it’s so finicky. Happens to me too that it seems to not work and then I get it working…

pez20:06:34

No, it is pretty raw.

seancorfield20:06:51

It would be nice if the cljfmt config could be embedded in settings directly -- or perhaps read from ~/.config/calva/ like the custom REPL stuff...

pez20:06:34

You mean if the cljfmt config path is embedded?

seancorfield20:06:35

No, I meant the actual EDN.

seancorfield20:06:55

I'm going to try via clojure-lsp since that has a global config...

seancorfield20:06:06

Yeah, that's probably going to be my best compromise. Then I can add it to my vscode-calva-setup repo and just symlink it into ~/.config on each machine, like I already have to do for some other things (Calva itself, Joyride).

pez20:06:28

The actual EDN for the default indent config lives in cljfmt, so can’t really be placed on file.

pez20:06:54

Going to try with setting the config path to CLOJURE-LSP?

seancorfield20:06:24

Yeah, CLOJURE-LSP at least lets me put the :cljfmt config in ~/.config/clojure-lsp/config.edn which means I can treat it like other "global" config in my vscode-calva-setup repo. It's some symlinks but it's a one-off.

seancorfield20:06:50

Thank you once again for your patience walking me through a config/customization issue!

pez10:06:49

Dear Calva friends: https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.372 • Fix: https://github.com/BetterThanTomorrow/calva/issues/2229 Thanks for reporting, @alexander.minolta. The fix isn’t as clean as I would want it to be, but at least we don’t break the code now.

gratitude-thank-you 2