Thursday, January 19, 2023

Reveal / REPL / VSCode Adventures

So the latest odyssey is to get Reveal working. And I'm trying to get it to run:

  • Using VSCode & Calva
  • Using Leiningen
Needless to say, my first few attempts didn't work in my guestbook project.
So back to basics.
If I put this into ~/.lein/profiles.clj

{:user {:dependencies [[vlaaad/reveal "1.3.265"]
                       [nrepl "0.9.0"]
                       [cider/piggieback "0.5.3"]
                       [cider/cider-nrepl "0.28.0"]]
        :repl-options {:nrepl-middleware [vlaaad.reveal.nrepl/middleware]}}}


and then do:

lein new app (on the command line)

followed by

lein repl (on the command line)

I get a beautiful Reveal window that when I execute a command in the REPL, I get output in the Reveal window


But if I do this within VSCode / Calva and jack-in, the Reveal window pops up

but notice I hardly get any output (as compared to the previous screenshot).

And when I execute the same command in my REPL window in VSCode, nothing appears in Reveal.

Hmmm? Stuck!


As an aside, I ran into REBL-readline and tried it out using the instructions here: https://www.futurile.net/2020/03/01/clojure-development-2020-lein-rebel-readline/

Very nice! But not sure how I can get this to play with my IDE. The IDE uses nREPL to talk to the REPL. how does REBL readline fit in here??

The author of the above REBL post goes into detail here on how to fully blow up the REPL experience with additional plugins and such. I want to follow this at some point. 

However, I want to keep my ~/.lein/profiles.clj empty at the moment as I'm trying to get the IDE working with Reveal and don't want to add anything unnecessary.


So after more playing around, I found that this command line in the app folder:

lein with-profile reveal repl

does launch the Reveal window, although it spits out these errors:

Error loading complete.core: Could not locate complete/core__init.class, complete/core.clj or complete/core.cljc on classpath.

But nevertheless, we have a Reveal window come up which actually works! Then what I did was within VSCode, connect to a running Repl (rather than Jack-in). Lo and behold I get this error:



After reading a bit more about Calva, turns out Calva figures stuff out for you if you jack-in and even gives you the command line it uses. So I took that command line and ran it from the terminal window:

lein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '["cider.nrepl/cider-middleware"]' -- with-profile +reveal repl :headless

Same result as before:


Zilch.

BUT, if I take the same command and remove headless...


Look at that! I got something...

So I have a REPL running with an nREPL server; Then from VSCode, rather than jack-in, I connect to a running REPL as I did above. But I am not able to send anything to Reveal... see below


The left window is the terminal running the REPL (using the command line without headless). The middle window is Reveal and the right window is VSCode which just cannot talk to Reveal...



No comments:

Post a Comment

Clojurescript with Reveal & VSCode

So my next foray was into getting Reveal to work with Clojurescript ( specifically Shadow-CLJS)  and VSCode and Leiningen. After a number of...