This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-20
Channels
- # announcements (1)
- # architecture (14)
- # asami (21)
- # babashka (1)
- # beginners (44)
- # biff (6)
- # calva (24)
- # clojure (16)
- # clojure-europe (12)
- # clojurescript (32)
- # cursive (23)
- # datascript (5)
- # honeysql (8)
- # hyperfiddle (1)
- # malli (1)
- # nextjournal (34)
- # nrepl (4)
- # off-topic (64)
- # re-frame (12)
- # reagent (1)
- # releases (2)
- # reveal (41)
- # shadow-cljs (137)
- # spacemacs (4)
- # xtdb (5)
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
(:require
[clojure.core.server :as s]
[clojure.main :as m]
[vlaaad.reveal :as r]))
(defonce ui (atom (r/ui)))
(add-tap @ui)
(defn- submit-eval
[form]
(let [value (eval form)]
(@ui value)
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,\"0.0.0.0\",: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.
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.
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.
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 🙂
r/repl is basically a wrapper of m/repl with all the necessary wrappings to give the best repl experience
https://github.com/vlaaad/reveal/blob/master/src/vlaaad/reveal/repl.clj — 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?
I’m not sure I understand correctly: so I connect Tutkain to a socket-repl :accept
ing vlaaad.reveal/repl
, connect Tutkain to it and then…. evaluate something to open the regular ui?
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
Yeah, so what you do now, but instead of ((requiring-resolve 'jlmr.socket-reveal/repl))
, do ((requiring-resolve 'vlaaad.reveal/repl))
.
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))