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
mauricio.szabo 2019-10-28T03:30:56.089400Z

Well, if anyone want to check, I'm working on a "REPL Detection" feature, currently on the branch detect-repl-type. It currently detects (and connects to) Babashka, ClojureScript (Lumo, or clj pointing to a browser/node socket REPL) and ClojureCLR. There's still lots of room for improvements (for example, doc for var isn't working yet) but it's a start 🙂

👍 2
mauricio.szabo 2019-10-28T03:48:16.090400Z

Also, Joker's socket REPL is kinda supported, but there's a problem with connections so it's not there yet.

2019-10-28T20:39:26.091800Z

i've just tried with babashka. initially after "Chlorine: Connect Socket REPL" i got:

bb=> :using-unknown-repl
bb=> :using-unknown-repl
bb=> bb=> 
but after that evaluation seemed to work fine. is this expected?

mauricio.szabo 2019-10-28T20:40:26.092Z

Yes, it is expected for now. It was happening because of this issue: https://github.com/borkdude/babashka/issues/85

mauricio.szabo 2019-10-28T20:40:44.092400Z

But its already fixed on the new version.

borkdude 2019-10-28T20:40:46.092600Z

try upgrading to v0.0.23

mauricio.szabo 2019-10-28T20:41:20.092900Z

Yes, upgrading works, the code for Chlorine was written before the fix 🙂

2019-10-28T20:41:27.093100Z

thanks 🙂

2019-10-28T22:08:21.100300Z

i just tried clojure clr. below i'm using a hypothetical ns named alens.core (though note that it hasn't been created / loaded right after starting the clojure clr process). i get an error for evaluation. chlorine sends:

(in-ns 'alens.core)(try  (clojure.core/let [res (+ 1 1)  res (clojure.core/cond  #?(:cljs false :default (clojure.core/ratio? res))  (clojure.core/symbol  (clojure.core/str "#repl-tooling/literal-render \""  (clojure.core/pr-str res) "\""))  (clojure.core/symbol? res)  (clojure.core/symbol (clojure.core/str "#unrepl/bad-symbol [nil "  (clojure.core/pr-str (clojure.core/str res))  "]"))  (clojure.core/keyword? res)  (clojure.core/symbol (clojure.core/str "#unrepl/bad-keyword ["  (clojure.core/pr-str (namespace res)) " "  (clojure.core/pr-str (clojure.core/name res))  "]"))  (clojure.core/->> res type str (clojure.core/re-find #"Big(Decimal|Float)"))  (clojure.core/symbol (clojure.core/str "#unrepl/bigdec "res))  (clojure.core/->> res type str (clojure.core/re-find #"BigInt"))  (clojure.core/symbol (clojure.core/str "#unrepl/bigint "res))  :else res)]  ['tooling$eval-res 'G__2 {:result (clojure.core/pr-str res)}])  (catch System.Exception e  ['tooling$eval-res 'G__2 {:error (clojure.core/pr-str e)}]))
i get:
#object[Namespace 0x4684feed "alens.core"]
Syntax error (InvalidOperationException) compiling at (REPL:1:31).
Unable to resolve symbol: + in this context
alens.core=> 
if an appropriate ns form (e.g. (ns alens.core)) is evaluated before the let form, it works. presumably this is because using ns leads to clojure.core being made available in the corresponding ns.

mauricio.szabo 2019-10-28T22:09:44.101200Z

Yes, this is somehow expected. I'm using in-ns to enter the namespace, and if the ns doesn't exist it doesn't include any clojure.core functions

2019-10-28T22:11:38.101800Z

so i tried load file first, but i get:

#object[Namespace 0x581e8372 "user"]
Syntax error (InvalidOperationException) compiling at (REPL:4:230).
Unable to find static field: getProperty in 
user=> 
not sure why yet

mauricio.szabo 2019-10-28T22:11:40.102Z

I think in CLJ, unrepl creates the namespace for us

2019-10-28T22:12:11.102600Z

ah -- i looked into porting unrepl to clr clojure a bit back, but it looked like it would be quite a bit of work 🙂

mauricio.szabo 2019-10-28T22:13:23.103400Z

load-file is completely JVM dependent 😞

2019-10-28T22:13:27.103600Z

i wonder if there is harm in sending (ns my-ns) before the (in-ns 'my-ns)

2019-10-28T22:13:47.104200Z

a lot of clr clojure is similar to jvm clojure fwiw -- may not be hard to port that part

2019-10-28T22:14:47.105800Z

i guess if one is doing something to exclude various clojure bits, doing (ns my-ns) may not be a good idea

mauricio.szabo 2019-10-28T22:14:59.106100Z

Yes, but now we're expanding quite a bit (Babashka, Joker, ClojureCLR, Lumo, Plank to start), so probably we'll need to restrict some commands

2019-10-28T22:15:31.106400Z

it is a tricky business

mauricio.szabo 2019-10-28T22:15:54.107300Z

Yes, it is 😄. To be honest, I'm surprised it is even working!

2019-10-28T22:16:22.108100Z

i didn't want to adversely affect the existing functionality -- so when i tried to get clr stuff working before i tried to provide separate lower level networking pieces

mauricio.szabo 2019-10-28T22:16:36.108200Z

Like, I've got ClojureCLR autocomplete on one file and it was completely incidental

2019-10-28T22:17:02.108800Z

neat!

2019-10-28T22:42:46.109200Z

regarding load-file, i had something like this before:

(defn load-file! []
  (let [editor (atom/current-editor)
        file-name (.getPath editor)
        ;; canonicalize path separator for Java -- this avoids problems
        ;; with \ causing 'bad escape characters' in the strings below
        file-name (str/replace file-name "\\" "/")
        code (if (or (need-cljs? editor)
                     (need-cljr? editor))
                (str "(do "
                     "  (println \"Loading \" \"" file-name "\")"
                     "  (load-file \"" file-name "\"))")
                (str "(do"
                  " (require 'clojure.string)"
                  " (println \"Loading\" \"" file-name "\")"
                  " (try "
                  "  (let [path \"" file-name "\""
                  ;; if target REPL is running on *nix-like O/S...
                  "        nix? (clojure.string/starts-with? (System/getProperty \"user.dir\") \"/\")"
                  ;; ...and the file path looks like Windows...
                  "        win? (clojure.string/starts-with? (subs path 1) \":/\")"
                  ;; ...extract the driver letter...
                  "        drv  (clojure.string/lower-case (subs path 0 1))"
                  ;; ...and map to a Windows Subsystem for Linux mount path:
                  "        path (if (and nix? win?) (str \"/mnt/\" drv (subs path 2)) path)]"
                  "   (load-file path))"
                  "  (catch Throwable t"
                  "   (doseq [e (:via (Throwable->map t))]"
                  "    (println (:message e))))))"))]
    (evaluate-aux editor
                  (ns-for editor)
                  (.getFileName editor)
                  1
                  0
                  code
                  #(atom/info "Loaded file" file-name))))

2019-10-28T22:43:14.109500Z

and there was an appropriate need-cljr?

mauricio.szabo 2019-10-28T22:44:38.110300Z

There's none yet, but I'm currently adding it

2019-10-28T22:44:53.110500Z

sounds great 🙂