Fork me on GitHub
#calva
<
2023-05-22
>
Ben Lieberman20:05:41

thanks for this little addition (`"; Waiting for Shadow CLJS runtimes, start your CLJS app..."`) to Calva, bc I do forget to do this regularly

🙏 2
pez20:05:36

Then we are two. 😃 Thanks for letting us know you appreciate this! 🙏

2
seancorfield23:05:07

How does Calva read the calva/config.edn file containing REPL snippets? I ask because mine has a bunch of #(...) function shortcuts in it but clj-kondo now flags those as illegal -- because the EDN reader won't handle them correctly (they're Clojure reader macros).

pez06:05:37

We’re using tools.reader:

(defn parse-clj-edn
  "Reads edn (with regexp tags)"
  ; 
  [s] (tr/read-string s)) 

borkdude07:05:02

This is not the tools reader EDN reader, but the Clojure reader, probably?

pez07:05:56

Yes, sorry, that was unclear:

(ns calva.parse
  (:require [cljs.reader]
            [cljs.tools.reader :as tr]
            [cljs.tools.reader.reader-types :as rt]
            [clojure.string :as str]
            [calva.js-utils :refer [jsify]]))

borkdude07:05:21

yeah so you're not reading EDN as EDN but as Clojure

pez07:05:49

Exactly. For the reasons given on that http://ask.clojure.org link.

borkdude07:05:48

but if the file is called .edn why are you not reading it as EDN?

pez07:05:49

It’s not perfect. 😃 We support Clojure code snippets there, so things went wrong if we used the edn reader.

borkdude08:05:37

@U0ETXRFEW bb.edn also has code snippets, but I've always treated it as normal .edn but maybe for Calva it's too late :)

pez08:05:32

Not sure if it’s too late. You mean that for configs that have anonymous functions and such it would break?

borkdude08:05:36

yeah, similar to what Sean reported in his OP

pez08:05:55

Maybe I could do some try/catch and warn about it? I’m not sure about the implications. Bu if edn is good enough for bb.edn, I don’t see why it shouldn’t be good enough for Calva…

borkdude08:05:21

well, I always treated bb.edn as EDN since then other tools were also able to read it. I think if I would have allowed #() etc I would have called it or so

borkdude08:05:27

Note that most things you can write in .clj you can also express in EDN, #() becomes (fn [...]) and #"" becomes re-pattern

borkdude08:05:38

I think allowing #() and #"" in config files is pretty handy though, but I think there might be reasons that this isn't supported, e.g. you can't compare regexes by value

pez08:05:08

Thanks. I’ll ponder this a bit. I wonder how it is dealt with with cljfmt’s config…