This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-14
Channels
- # announcements (31)
- # babashka (9)
- # beginners (4)
- # calva (67)
- # cider (6)
- # clj-yaml (10)
- # clojure (105)
- # clojure-austin (8)
- # clojure-bay-area (1)
- # clojure-europe (12)
- # clojure-germany (3)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-uk (2)
- # clojurescript (5)
- # core-logic (4)
- # data-science (29)
- # datomic (6)
- # dev-tooling (5)
- # emacs (3)
- # hyperfiddle (22)
- # introduce-yourself (4)
- # lsp (8)
- # malli (10)
- # off-topic (8)
- # pathom (74)
- # polylith (39)
- # practicalli (1)
- # reitit (3)
- # shadow-cljs (2)
- # spacemacs (3)
- # squint (4)
- # tools-deps (4)
Not a big deal but getting red squigglies here because the symbols aren't real, they get transformed in the macro. Is there a way to tell calva not to resolve symbols for a macro call?
It’s #clj-kondo doing the linting and it’s quite configurable: https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md Since you are in control of the macro definition you might want to try Inline macro configuration there.
Thanks @pez 🙂
Something like this will do the trick. Replace yournamespace with a proper one.
:linters {:unresolved-symbol {:exclude [(yournamespace/mark-get [Start Line Column End Index])]}
@U4EFBUCUE thanks, I'll try it out soon
Since Calva updated cljfmt's version, a coworker of mine and myself noticed a change in indentation, which we've seemed to have fixed by changing :indents
in our cljfmt config file to :extra-indents
. CC @pez
I went back to the previous Calva version to verify that the issue didn't occur there.
Seems related to this change in 0.11.1 of cljfmt:
> • Breaking change: split :indents
into :indents
and :extra-indents
@pez We might need to update Calva's docs here: https://calva.io/formatting/#indentation-rules.
I couldn’t help myself either https://github.com/BetterThanTomorrow/calva/pull/2275 (Though that was completely unindentional.)
But maybe that usage of :indents
in our docs is still valid. In our work project we have custom macro indent rules in :extra-indents
.
I think a note in the docs (and here) about what to do in a situation like you encountered would be good, @U9A1RLFNV. It’s not clear to me from the changelog entry there…
This explains it more: https://github.com/weavejester/cljfmt/tree/master#breaking-changes-in-011x
Well, when we still used :indents
how it used to be used, formatting a file would cause the indentation to look pretty off, I think because we were blowing away the default indent rules provided by cljfmt (with the new version).
> The :indents
key has been split into :indents
and :extra-indents
. The :indents
key replaces all default indents, while the :extra-indents
key will append to the default indents.
Thanks for the link to the info. It seems it is the ^:replace
metadata that is replaced with this notation.
To be clear about “the indenter”. It’s separate from the formatter, but reads the same configuration. It doesn’t know about this :extra-indents
thing, and will not replace all default indents for the :indents
key. Basically it will behave as if :legacy/merge-indents? true
is used…
I’ll have a look at this tonight. I think I understand the issue now. (Even if I am a bit worried that I haven’t since the ^:replace
metadata thing is not mentioned in that update.) Quite unusual with breaking changes like this in Clojure land! It’s no excuse, of course, completely my fault that I overlooked this… But I think it shouldn’t be too hard to fix. This new config makes sense.
I made a .cljfmt.edn
file with
{:extra-indents #{:closure-fn :closure-params}
}
in it. but I'm not sure how to check in calva for its effectscan someone give me a simple thing to try?
also the file it in the project root dir, but that's not the git repo root dir
Looks like my :test-code
is here https://calva.io/formatting/#indentation-rules
Yeah you can try out the indentation rules in the cljfmt file since Calva will format it. Make sure you tell Calva to use your file if you haven't yet with this VS Code setting:
"calva.fmt.configPath": ".cljfmt.edn",
got a minute?
Mind looking at a repo to see what I'm doing wrong? It's driving me nuts :)
I added https://github.com/yaml/yamlscript/blob/clojure/.vscode/settings.json which points to https://github.com/yaml/yamlscript/blob/clojure/clojure/.cljfmt.edn I think
When I hit tab here https://github.com/yaml/yamlscript/blob/clojure/clojure/.cljfmt.edn#L6 I expect the reformatting like in https://calva.io/formatting/#indentation-rules but it stays the same
I'm using the repo top level dir as my workspace in vscode (that's the folder I'm opening at least so I assume vscode thinks it's the workspace)
Mind if I take a look tomorrow, if someone else doesn’t get to it by then? I’ll set a reminder. Thanks for the repo too. That helps.
Yeah, its not very important.
@U05H8N9V0HZ I can’t reproduce the problem with reformatting. The :test-code
does not use your rules, though… If I use test code that does, it is reformatted as I expect:
{:extra-indents
{use-subscribe [[:inner 0]]
use-event-listener [[:inner 0]]
$ [[:inner 0]]}
:test-code
[(use-subscribe foo
x)
(concat [2]
(map #(inc (* % 2))
(filter #(aget sieved %)
(range 1 hn))))]}
However, you are also running into this issue: https://github.com/BetterThanTomorrow/calva/issues/2280 That is, the indenter is not reading :extra-indents
, even if the formatter is. Which adds to the confusion.I was just using rules from https://clojurians.slack.com/archives/CBE668G4R/p1692053535155249?thread_ts=1692052810.294799&cid=CBE668G4R with the test code from your docs. I got it working (afaict) with:
{:extra-indents {#"" [[:inner 0]]}}
in clojure/.cljfmt.edn https://github.com/yaml/yamlscript/blob/34fea1245faf1b8dda31bbed427d7caf28185cc4/clojure/.cljfmt.edn
with .vscode/settings.json
point to that file https://github.com/yaml/yamlscript/blob/34fea1245faf1b8dda31bbed427d7caf28185cc4/.vscode/settings.jsonDear Calva friends: https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.384 • https://github.com/BetterThanTomorrow/calva/issues/2278 This makes Calva more resilient (and less confusing) to when there are problems with clojure-lsp binary downloads.
not sure if this is universal to other users, but I found my default indentation was incorrect until I swapped :indents
for :extra-indents
I rolled back to an earlier Calva version while I figured that out so thank you for the hint!
I have LSP provide the config and it doesn't have :indents
or :extra-indents
in config.edn
so... not quite sure what I need to do to fix this?
What is the problem you are experiencing @U04V70XH6?
@U0FHWANJK I think it’s universal. See: https://clojurians.slack.com/archives/CBE668G4R/p1692028185570809
@pez Exactly that problem: indents are broken. But I don't have a cljfmt config file -- I have it configured to pull from LSP -- and the LSP config.edn doesn't have any :cljfmt
overrides in it.
Oh wait... I do have a .cljfmt.edn
file in my home folder... Let's see.
It's because any local customization replaces all the defaults in cljfmt
if you have :indents
so every form indents like a function:
(defn foo
"docstring"
[args]
(body))
I had a single rule for expecting
(from Expectations) and now I've changed it from :indents
to :extra-indents
everything works on the latest Calva/cljfmt.
Thanks for confirming that. Can you also try to instead set :legacy/merge-indents? true
in the config and keep :indents
?
Like this? Doesn't seem to work:
{:legacy/merge-indents? true
:indents {expecting [[:inner 0]]}}
Indentation:
(defn subject
"Given start time, end time, and alert subjects,
return subject of email."
[start-time end-time alert-subjects]
(str "[Alerts] " alert-subjects " from " start-time " to " end-time))
I'll try that again later to be sure (I have to restart Calva each time to be sure). Lunch here.
I have LSP provide the config and it doesn't have :indents
or :extra-indents
in config.edn
so... not quite sure what I need to do to fix this?
Dear Calva friends: With v2.0.382
of Calva comes a https://github.com/weavejester/cljfmt/blob/master/README.md. If you have been adding indentation rules to the defaults using :indents
, you now should be using :extra-indents
instead. Please see the note about this in the docs: https://calva.io/formatting/#indentation-rules
I'm getting no joy with :indents
or :extra-indents
I'm not sure I have things configged right.
Can someone point me at an example .cljfmt.edn
file using :extra-indents
?
Also I can't figure out how to press tab to reformat an entire form as suggested here: https://calva.io/formatting/#indentation-rules
Do I need to highlight the form?
Help!
Heres my own .cljfmt.edn
with the recently updated name
{:extra-indents
{use-subscribe [[:inner 0]]
use-event-listener [[:inner 0]]
$ [[:inner 0]]}}
With the new name the formatting works properly again
( for me )
@U02FVPF04A1 thanks.
I'm new to Calva and I'm not sure how to go about reformatting (indentation) a set of lines.
The code section a bit down from https://calva.io/formatting/#indentation-rules says
"Save, then hit tab
, and the code should get formatted like so:"
but hitting the tab key does nothing for me.
Where should my cursor be or what should be highlighted when I hit tab?
ok, I get it. when i made the indent wacky on all the indented lines, hitting tab anywhere in the form reformatted things.
I think it's just my .cljfmt.edn file is in the wrong place, because it's using the old style