This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-09
Channels
- # announcements (4)
- # babashka (25)
- # beginners (11)
- # calva (32)
- # clj-kondo (5)
- # clojure (130)
- # clojure-dev (11)
- # clojure-europe (17)
- # clojure-nl (1)
- # clojure-norway (96)
- # clojure-spec (1)
- # clojure-uk (3)
- # clojurescript (9)
- # conjure (2)
- # cursive (8)
- # datalevin (1)
- # etaoin (14)
- # ghostwheel (2)
- # hyperfiddle (13)
- # joker (2)
- # leiningen (82)
- # malli (3)
- # pathom (4)
- # polylith (12)
- # releases (3)
- # spacemacs (7)
- # sql (3)
How to make the macro to be treated like a defn and indented as such?
You need to create clj-kondo linter config, and cljfmt config. (The above link should point you to the latter.) For the former it will be something like:
{:lint-as {your.namespace/your-macro clojure.core/defn}}
Hmm, this doesn't work with: fulcrologic.guardrails:
(ns guardrails.core
(:require
[com.fulcrologic.guardrails.core :as gr]))
(gr/>defn ranged-rand
[start end]
[int? int? | #(< start end) => int? | #(>= % start) #(< % end)]
(+ start (long (rand (- end start)))))
.lsp/config.edn
{:cljfmt
{:indents {com.fulcrologic.guardrails.core/>defn [[:inner 0]]}}}
Calva version used: v2.0.410
clojure-lsp version used: 2024.02.01-11.08.46-nightly
clj-kondo version used: 2023.12.15
clojure-lsp version used: 2024.02.01-11.08.46-nightly
clj-kondo version used: 2023.12.15
clojure-lsp version used: 2024.02.01-11.08.46-nightly
clj-kondo version used: 2023.12.15
Regarding linter config for Guardrails, I think you won’t need to add. Iirc it is provided by the library.
I don't have it set.
Removing the configs doesn't help either.
I’ll make a repro
I think it will work placing the config at .cljfmt.edn
and at the root of the config map:
{:indents {com.fulcrologic.guardrails.core/>defn [[:inner 0]]}}
Unless you have reasons to host the formatter config with clojure-lsp. If so you need to set the cljfmtPath to CLOJURE-LSP
, per instruction at: https://calva.io/formatting/#providing-configuration-via-clojure-lsp
Hey @U0ETXRFEW! Thank you so much for all the support. Could you kindly check this repro: https://github.com/FieryCod/calva-repro?
Thanks! I can’t reproduce the problem. I know you say you haven’t set your calva.fmt.configPath
, but I suspect it is set to something. Maybe try resetting it?
Thanks @U0ETXRFEW. Tried doing that, but no luck. On fresh profile with just Calva >defn is not correctly formatted either.
I can confirm that using regular cljfmt the code is formatted correctly. Where does calva store cljfmt binary?
The rule needs to match the symbol fully. So if you are sometimes using it unqualified and sometimes qualified, you may be better suited with a regex:
:extra-indents {#re "/?>defn" [[:inner 0]]}
:test (comment
(com.fulcrologic.guardrails.core/>defn hello []
{:a a
:aa a
:bbb bbb})
(>defn hello-again []
{:a a
:aa a
:bbb bbb}))
Calva only formats the current parent form, so cljfmt does not get to do its magic with figuring things out from the ns
form.
Calva doesn’t use a separate binary. We’re using cljfmt as a library.It will of course first take that we get any rule to work. I don’t understand what goes wrong for you. Maybe it’s more effective we share screens and investigate together. Let me know if that works for you.
silly question but is it possible to move and use the repl down from the terminal tab section?
Can you explain what you mean? The Calva REPL is a "file" editor. Terminals are separate things.
Yes, that's what I mean. In vscode, I want to access the repl from the section where the terminal tab resides.
Not currently possible, though there were some discussions around a change to the way the REPL outputs: <https://github.com/BetterThanTomorrow/calva/discussions/2238>. At the moment, the arrangement you have there is probably the closest it'll get (not sure if it's possible to split a file and the terminal window on the bottom "row")
You can move Terminal tabs and other windows around
Here I have the Calva says terminal window and the REPL in the bottom chunk of the screen:
(I usually have them both on the right hand side, but moved them down to show you it is possible)
This is my usual setup:
Well, my usual setup has two Portal windows on the right. Top-right is tap>
output and usually the REPL tab. Bottom-right is the middleware/logging Portal window and at least one Terminal for running builds etc.