Is there a recommended way to get the project's REPLs and find one for babashka and one for Clojure? I've been writing a function for it, but had to dig quite a bit. The cider-connection functions (except cider-sessions) always returned one connection, but maybe I'm mistaken?
Making progress on this, maybe I can post it once it works well enough for some feedback.
So, is this roughly the right approach to call clojure tooling with the connection string of a babashka-nrepl:
(require 'cider)
(require 'cider-client)
(require 'cider-eval)
(require 'nrepl-client)
(defun clay2-find-repl (type repls)
(seq-find (apply-partially #'cider-connection-has-capability-p type)
repls))
(defun clay2-eval-with-bb ()
(interactive)
(let* ((cider-merge-sessions 'project)
(cider-repls (cider-repls))
(clojure-repl (clay2-find-repl 'clojure cider-repls))
(babashka-repl (clay2-find-repl 'babashka cider-repls))
(babashka-conn (with-current-buffer babashka-repl
(format "%s:%s"
(plist-get nrepl-endpoint :host)
(plist-get nrepl-endpoint :port)))))
(cider-tooling-eval
(concat "(require '[scicloj.clay.v2.api])"
"(println \"ready to call babashka: scicloj.clay.v2.api/make! "
babashka-conn
"\" (str "
(cider-last-sexp)
"))")
(nrepl-make-response-handler clojure-repl nil
#'cider-repl-emit-stdout
#'cider-repl-emit-stderr
nil)
(cider-get-ns-name)
clojure-repl)))i think you are crossing some streams here. Your nrepl response handler goes into the clojure repl but your tooling eval using the babashka connection
but this seems strange to me using a single repl buffer for output and two different nrepl connections
Thank you for the response. Well, I'm not there yet, this is the first step. It is one part of a prototype to use different clojure dialects in a notebook. Clay renders notebooks by evaluating our code in the context of our clojure repl. That is so we can just write clojure code as we usually do, with a repl, but then can also render expressions or the file as a notebook. While clay evaluates something to render it, the output of that is captured and can be rendered as well. Clay logs its own messages during rendering to the clojure repl already, that's why i forward to the clojure repl here too. Changing this to go to a clay buffer instead of a repl might be more idiomatic, but is a separate issue.
Sorry for posting to the channel again, but https://github.com/scicloj/clay.el/blob/18df2ee0511118cd23bd1623b04bb48dc8bb5130/clay.el#L86 is the function in context, if someone wants to give more feedback. Please note it is just hacked together and I appreciate any tips in improving its ergonomics and integration with the Clojure workflow/cider. The question raised by @dpsutton remains open as well, maybe part of it is something I'll raise in #nrepl if need be.