This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-20
Channels
- # announcements (10)
- # architecture (7)
- # babashka (49)
- # beginners (125)
- # calva (2)
- # chlorine-clover (33)
- # clj-kondo (15)
- # cljs-dev (18)
- # cljsrn (28)
- # clojure (91)
- # clojure-argentina (37)
- # clojure-austin (4)
- # clojure-dusseldorf (1)
- # clojure-europe (3)
- # clojure-france (2)
- # clojure-germany (2)
- # clojure-nl (4)
- # clojure-portugal (4)
- # clojure-spec (26)
- # clojure-uk (19)
- # clojuredesign-podcast (5)
- # clojurescript (19)
- # conjure (20)
- # core-async (4)
- # cursive (60)
- # data-science (4)
- # datomic (1)
- # duct (9)
- # emacs (11)
- # events (1)
- # fulcro (9)
- # graalvm (17)
- # jobs-discuss (7)
- # luminus (19)
- # malli (36)
- # meander (2)
- # off-topic (23)
- # pathom (2)
- # quil (1)
- # rdf (4)
- # re-frame (16)
- # reitit (10)
- # ring (21)
- # ring-swagger (1)
- # shadow-cljs (137)
- # spacemacs (10)
- # sql (27)
@mauricio.szabo It looks like the code that identifies the namespace for the current file gets confused if there's explicit metadata on the namespace but I'm having a hard time isolating a repro case...
Some metadata seems OK, some doesn't. Can you point me to where that is parsed in the code so I can try to create a repro?
(not sure whether this would be in repl-tooling or chlorine itself)
Okay, it's on this line: https://github.com/mauricioszabo/repl-tooling/blob/master/src/repl_tooling/editor_helpers.cljs#L176
(the specific case I'm trying to use is clj-kondo
metadata which is quite complex)
Ah, ok. so simple-read
is where I should start looking...
Yes, it just uses cljs.reader/read-string
to parse the ns form
OK, so this metadata is probably not value EDN...
@seancorfield Are you trying to put metadata in the ns form?
@borkdude yes, I have tried both this:
(ns
^{:clj-kondo/config
'{:lint-as
{worldsingles.expectations.mobile.user/patch-notifications
clj-kondo.lint-as/def-catch-all}}}
worldsingles.expectations.mobile.user
and this
(ns worldsingles.expectations.mobile.user
{:clj-kondo/config
'{:lint-as
{worldsingles.expectations.mobile.user/patch-notifications
clj-kondo.lint-as/def-catch-all}}}
and Chlorine chokes on both.I think the quote is the problem here (not valid EDN) but without the quote it isn't legal Clojure 🙂
@mauricio.szabo if you're looking for a parser that extends EDN with normal code features (while not evaluating code): https://github.com/borkdude/edamame
Weeeellll... worth a try 👍
Do you know if it performs better, or worse, than rewrite-cljs?
I think better, since it doesn't read into intermediate forms, straightly into the sexprs
Maybe it'll be a good fit for Chlorine to parse the ns forms, but I can see it being useful to detect blocks too (the current code is quite slow to be honest)
yeah. I want to add a public api to use a reader and read expression by expression using a reader, so far I've been plugging into the .impl namespaces from babashka and sci to do that: https://github.com/borkdude/babashka/blob/master/src/babashka/impl/repl.clj#L29
so it's basically this:
https://github.com/borkdude/edamame/blob/master/src/edamame/impl/parser.cljc#L486-L490
+ parse-next
@borkdude Is it possible to dispatch all tag literals to a specific reader, for example as it is possible with:
(clojure.reader/read-string "#foo 10" {:readers {:default tagged-literal}})
OK, this works for both
(ns
^{:clj-kondo/config
(quote {:lint-as
{worldsingles.expectations.mobile.user/patch-notifications
clj-kondo.lint-as/def-catch-all}})}
worldsingles.expectations.mobile.user
Well, maybe we can change to tools.reader/read-string
? I don't know if this could be a problem or not, to be honest..
(I'm such an edge case, aren't I? 🙂 )
Yes, but these are the good cases, it battle-tests the plug-in 😄
@seancorfield just published a new version that fixes this issue with namespace detection 🙂
Thank you for such a quick fix!