Fork me on GitHub

I’m trying to cleanly integrate Tutkain (Clojure plugin for Sublime Text) with reveal. Tutkain only works with plain socket repls so I’ve been trying the following (shamelessly copied from inspired by @seancorfield): I have the following mini-library:

(ns jlmr.socket-reveal
   [clojure.core.server :as s]
   [clojure.main :as m]
   [vlaaad.reveal :as r]))

(defonce ui (atom (r/ui)))

(add-tap @ui)

(defn- submit-eval
  (let [value (eval form)]
    (@ui value)

(defn repl
  (m/repl :init s/repl-init :read s/repl-read :eval submit-eval))
And I have the following alias in my deps.edn:
{:extra-deps {vlaaad/reveal {:mvn/version "RELEASE"}
              jlmr/socket-reveal {:local/root "/Users/jelmer/Code/socket-reveal"}}
   :jvm-opts ["-Dclojure.server.repl={:address,\"\",:port,50505,:accept,jlmr.socket-reveal/repl}"]}
When I connect to the socket repl with Tutkain, as expected the Reveal ui appears. However values don’t appear in Reveal when I eval them from the editor. Anyone any idea how I can fix this?


Hey there! Glad to see a Tutkain user in the wild. 🙂 I’ll be able to help you more when I'm front of my computer, but evaluating (jlmr.socket-reveal/repl) after connecting with Tutkain might work.


I don't use Reveal a lot myself, but this is definitely a use case I want Tutkain to support, so if you encounter any issues or rough edges, I'd like to hear about them so I can fix them. Would you prefer evaluation results to only show up in Reveal and not have them show up in Tutkain at all?


Hi! Yes after years of messing with Atom and VS Code I’m trying to get back to my first editor of choice, but I’ll have to get a decent Clojure experience going there before I can really make the switch back.


I’ll try your suggestion tonight, but I’m having trouble understanding why it would help. jlmr.socket-reveal/repl is called just as Tutkain connects and all evaluations should be passed to it.


It works because Tutkain starts its own REPL immediately after connecting.


Tutkain can connect and forms evaled in the editor seem to work.


I assume that’s how Tutkain implements breaking evaluations and so on?


That's part of it, yes.


Ok good to know, will tinker on it more later today.


Sure thing. I'd be happy to help if you come across any issues or if there's some way I can improve Tutkain to make working with Reveal easier. Feel free to join #tutkain and hit me up there if necessary.

👍 1

I indeed got it working by connecting to a regular socket and binding a key to evaluate ((requiring-resolve 'jlmr.socket-reveal/repl)) . Only oddity I notice that each time I switch tabs the namespace symbol gets evaluated or something and appears in reveal.


Indeed — Tutkain auto-switches namespaces by default. You'll probably want to disable that in Tutkain's settings (Preferences » Package Settings » Tutkain on macOS), auto_switch_namespace.


A feature that lets you automatically evaluate code after connecting might be useful... will think on that.


Thanks! I think you’ve got yourself another Tutkain user 🙂


Cool! That makes you user number three, I believe. 😛

🤯 1

Oh, in case you only want your evaluation results to show up in Reveal (and not in Tutkain at all), you might want to add "output": "panel" to your tutkain_connect key binding and set auto_show_output_panel (new in 0.13.0, just released) to false.


Hmm, can't you use r/repl? It's basically the same thing, but with submitting to Reveal window built in


@U47G49KHQ I did try r/repl, but I prefer r/ui 🙂


May I ask why? It supports all m/repl options...


r/repl is basically a wrapper of m/repl with all the necessary wrappings to give the best repl experience


r/repl is very similar to jlmr.socket-reveal/repl…

vlaaad10:02:58 — here is r/repl source, it’s mostly the same, but it also wraps printing and showing thrown exceptions, adds a tap sink…


Basically I like the ui of r/ui better, the fact that you can open extra panels at the bottom etc. Or have I missed that that’s possible with r/repl as well?


It’s totally possible


r/repl is a wrapper of m/repl that forwards repl output to r/ui


I’m not sure I understand correctly: so I connect Tutkain to a socket-repl :accepting vlaaad.reveal/repl , connect Tutkain to it and then…. evaluate something to open the regular ui?


mm no, I connected to a simple clojure.core.server/repl


I took this example from tutkain readme:

clj -J-Dclojure.server.repl="{:port 5555 :accept clojure.core.server/repl}"


and then open another nested vlaaad.reveal/repl I guess. I will try that out later today


and only changed it to add reveal to its classpath, e.g. clj -A:reveal -J…


I connected to it, and then run ((requiring-resolve 'vlaaad.reveal/repl))


Yeah, so what you do now, but instead of ((requiring-resolve 'jlmr.socket-reveal/repl)), do ((requiring-resolve 'vlaaad.reveal/repl)).


Yes tried it out quickly and it works perfectly!!!

🎉 2

Thanks both!


To summarize: 1. start a normal repl with reveal on the classpath: clj -Sdeps '{:deps {vlaaad/reveal {:mvn/version "1.3.265"}}}' -J-Dclojure.server.repl="{:port 5555 :accept clojure.core.server/repl}" 2. In sublime, use tutkain to connect to localhost:5555 3. evaluate ((requiring-resolve 'vlaaad.reveal/repl))

☝️ 1
💯 1

Also has the benefit of being much simpler than what I was trying


So in this case simple was actually easy as well 😅

rich 1