Fork me on GitHub
#cursive
<
2019-09-28
>
dmarjenburgh10:09:15

What is the minimal setup to get a clojurescript REPL working with Cursive? I’ve tried the following: - Minimal deps: {:deps {org.clojure/clojurescript {:mvn/version "1.10.520"}}} - Start a standard nREPL through the launch configuration. - Run the following:

(require '[cljs.repl.browser :as b]
         '[cljs.repl :as r])
(r/repl (b/repl-env))
This will work, except that the REPL keeps prompting me for standard input with a modal…

potetm14:09:23

As you know, Cursive works via NRepl really well.

potetm14:09:55

This is because the IDE can basically talk RPC over a socket.

potetm14:09:44

With the built-in REPL prompt, the host process is always begging for user input.

potetm14:09:15

When you fire up a raw cljs repl, that’s exactly what you’re doing: Starting a process that continually prompts for user input.

potetm14:09:44

I think Colin has been working on a better cljs repl for some time.

potetm14:09:06

But the fix right now is to use a piggieback repl: https://github.com/nrepl/piggieback

potetm14:09:42

This creates a faux nrepl that you can talk over.

potetm14:09:42

the invocation is basically the same:

(pb/cljs-repl (b/repl-env))

onetom16:09:25

here is a full example which you can just copy-paste as is. in 1 shell run a clojure socket repl which will be handled by a clojurescript repl server:

clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.1"} org.clojure/clojurescript {:mvn/version "1.10.520"}}}' -J-Dclojure.server.repl="{:port 5555 :accept cljs.server.browser/repl}"
this also drops you into a regular clojure repl which is connected to your terminal's standard i/o. from an other shell, run a tubular socket repl client like this:
clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.1"} tubular {:mvn/version "1.3.0"}}}' -m tubular.core -p 5555
this will try to connect to the socket repl server. that incoming connection to the 1st process will trigger it start a new cljs repl environment by opening a browser tab, which tab then connects back to that 1st process websockets. that 1st process then forwards the repl chatter back and forth to the tubular socket repl client in the 2nd process, which displays in on the 2nd terminal's standard i/o

onetom16:09:47

if you start the tubular client with cursive as a clojure.main repl, then the repl discourse will be handled by the cursive repl tool window, instead of a terminal's stdio