calva

pez 2025-03-08T11:36:36.530019Z

Thanks, @phill! ❤️

1
🎉 1
Kari Marttila 2025-03-08T17:53:32.247089Z

I would like the Calva formatter to be used also with VSCode Format Document command. I.e., when running Calva Format: Format Current Form and trim space... , it preserves the comment 's closing parenthesis in its own line, like this:

(comment
  "testing"
  )
(def testing "testing"
  )
;; After running Calva Format: Format Current Form and trim space... inside both forms I get:
;; Good
(comment
  "testing"
  )
;; Good
(def testing "testing")
But when running Format Document I get:
;; NOT GOOD
(comment
  "testing")
;; Good
(def testing "testing")
... which is not what I want (the closing parenthesis is moved to the last form line also with the comment form). I tried to read the documentation, how to configure VSCode Format Document command to use the same formatter as Calva Format: Format Current Form and trim space... uses, but somehow I fail to understand how to configure this.

Kari Marttila 2025-03-08T18:23:31.141079Z

I have in my VSCode settings:

"files.associations": {
        "*.clj": "clojure",
        "*.cljs": "clojure",
        "*.cljc": "clojure"
    },

    "[clojure]": {
        "editor.defaultFormatter": "betterthantomorrow.calva"
    },   

Kari Marttila 2025-03-08T18:51:40.076709Z

I don't believe this. I somehow managed to break my Calva setup. Even though I have my VSCode settings in a git repo, and resetted every configurations I did. Now when starting new line, the new line is not indented. 😞

Kari Marttila 2025-03-08T18:55:51.008839Z

Weird. I turned on the Calva > Fmt: New Indent Engine. When I do git diff in my VSCode settings.json I see this change: "calva.fmt.newIndentEngine": false, => line removed.

Kari Marttila 2025-03-08T18:55:57.912069Z

But the indentation works again.

pez 2025-03-08T20:01:38.462489Z

I’m not following around what happened and the diff. Is it working now?

pez 2025-03-08T20:05:49.120199Z

You don’t need any special setting to use Calva as the document formatter. That’s the default. It is also expected behaviour that the trailing rich comment paren is not folded when formatting from inside the form, but it is folded when formatting from outside the rich comment form. https://calva.io/rich-comments/#special-formatting

Kari Marttila 2025-03-09T06:40:44.299649Z

Ah, ok. So, I am using Calva document formatter, but it just behaves a bit differently when formatting from outside the rich comment form. Is it possible to configure that formatter so that it behaves the same way when formatting outside the rich comment form as inside the form?

Kari Marttila 2025-03-09T06:41:24.234089Z

Indentation works again. 😃

Kari Marttila 2025-03-09T06:42:05.766229Z

And thanks for your answer, that explained the behaviour. ❤️