chlorine-clover

About Chlorine for Atom and Clover for VS Code: https://atom.io/packages/chlorine and https://marketplace.visualstudio.com/items?itemName=mauricioszabo.clover
seancorfield 2020-04-20T19:32:06.260300Z

@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...

seancorfield 2020-04-20T19:32:41.261200Z

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?

seancorfield 2020-04-20T19:32:57.261600Z

(not sure whether this would be in repl-tooling or chlorine itself)

mauricio.szabo 2020-04-20T19:33:22.262300Z

Okay, it's on this line: https://github.com/mauricioszabo/repl-tooling/blob/master/src/repl_tooling/editor_helpers.cljs#L176

seancorfield 2020-04-20T19:33:29.262600Z

(the specific case I'm trying to use is clj-kondo metadata which is quite complex)

seancorfield 2020-04-20T19:33:45.263Z

Ah, ok. so simple-read is where I should start looking...

mauricio.szabo 2020-04-20T19:34:06.263600Z

Yes, it just uses cljs.reader/read-string to parse the ns form

seancorfield 2020-04-20T19:34:15.263800Z

OK, so this metadata is probably not value EDN...

borkdude 2020-04-20T19:34:29.264200Z

@seancorfield Are you trying to put metadata in the ns form?

borkdude 2020-04-20T19:35:10.265100Z

(ns foo { ... } ;; <-- metadata
also works

borkdude 2020-04-20T19:35:28.265700Z

instead of (ns ^{ ... } foo)

seancorfield 2020-04-20T19:35:32.265800Z

@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.

borkdude 2020-04-20T19:35:56.266500Z

ok, yeah, because EDN cannot contain quotes. I guess this is in Chlorine then.

seancorfield 2020-04-20T19:36:09.266800Z

I think the quote is the problem here (not valid EDN) but without the quote it isn't legal Clojure 🙂

borkdude 2020-04-20T19:36:50.268100Z

@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

seancorfield 2020-04-20T19:37:23.269200Z

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

mauricio.szabo 2020-04-20T19:37:47.269700Z

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..

seancorfield 2020-04-20T19:38:29.270100Z

(I'm such an edge case, aren't I? 🙂 )

mauricio.szabo 2020-04-20T19:38:38.270200Z

Weeeellll... worth a try 👍

borkdude 2020-04-20T19:38:53.270400Z

I'm using it in sci/babashka to parse code

mauricio.szabo 2020-04-20T19:39:02.270600Z

Do you know if it performs better, or worse, than rewrite-cljs?

borkdude 2020-04-20T19:39:27.271300Z

I think better, since it doesn't read into intermediate forms, straightly into the sexprs

mauricio.szabo 2020-04-20T19:39:28.271500Z

Yes, but these are the good cases, it battle-tests the plug-in 😄

borkdude 2020-04-20T19:39:31.271600Z

but benchmarking is knowing

borkdude 2020-04-20T19:39:57.271800Z

it's based on tools.reader, so it's not faster than tools.reader

mauricio.szabo 2020-04-20T19:41:12.272Z

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)

borkdude 2020-04-20T19:43:06.272200Z

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

borkdude 2020-04-20T19:44:39.272600Z

so it's basically this: https://github.com/borkdude/edamame/blob/master/src/edamame/impl/parser.cljc#L486-L490 + parse-next

mauricio.szabo 2020-04-20T22:14:53.273300Z

@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}})

mauricio.szabo 2020-04-20T23:05:38.274300Z

@seancorfield just published a new version that fixes this issue with namespace detection 🙂

seancorfield 2020-04-20T23:53:53.275600Z

Confirmed, yes, that works beautifully!

🎉 1
seancorfield 2020-04-20T23:54:01.275900Z

Thank you for such a quick fix!