670720d43c24495284dcce1db98cdd4269109b6e — Dominic Monroe 3 years ago c86e769
Add nREPL support
3 files changed, 52 insertions(+), 1 deletions(-)

A src/io/dominic/wedge/mise/impl/nrepl.clj
M src/io/dominic/wedge/mise/rebel.clj
M README.adoc => README.adoc +8 -0
@@ 41,6 41,14 @@ OR
# clojure -M:dev -m io.dominic.wedge.mise.rebel

You may pass the `--nrepl` flag to the main to start an nREPL server on port 5600 with common middleware loaded.
Use this is your editor asks you to connect to an nREPL server.

# clojure -M -m io.dominic.wedge.mise.rebel --nrepl

== SLF4J Warnings

This should only happen if you don't have SLF4J loaded.

A src/io/dominic/wedge/mise/impl/nrepl.clj => src/io/dominic/wedge/mise/impl/nrepl.clj +39 -0
@@ 0,0 1,39 @@
(ns io.dominic.wedge.mise.impl.nrepl
    [clojure.tools.deps.alpha.repl :as tda.repl]))

(defn add-libs
  (binding [;; Suppress missing S3Transport warning
            *err* (java.io.StringWriter.)]
        '{cider/cider-nrepl {:mvn/version "0.25.4"}
          refactor-nrepl/refactor-nrepl {:mvn/version "2.5.0"}
          nrepl/nrepl {:mvn/version "0.8.3"}}
        (try (require 'cljs.analyzer)
             (catch java.io.FileNotFoundException _
        (assoc 'cider/piggieback {:mvn/version "0.5.2"}))))

(defn start-nrepl
  ([] (start-nrepl {}))
   (let [opts (merge {:port 5600
                      :transport (requiring-resolve 'nrepl.transport/bencode)
                      :transport-fn (requiring-resolve 'nrepl.transport/bencode)
                      :handler (apply (requiring-resolve 'nrepl.server/default-handler)
                                      (:middleware opts
                                                     @(requiring-resolve 'cider.nrepl.middleware/cider-middleware)
                                                     (when-let [piggieback (try (requiring-resolve 'cider.piggieback/wrap-cljs-repl)
                                                                                (catch java.io.FileNotFoundException _
         server (apply (requiring-resolve 'nrepl.server/start-server) (apply concat opts))]
     (println ((requiring-resolve 'nrepl.cmdline/server-started-message) server opts))
     ((requiring-resolve 'nrepl.cmdline/save-port-file) server opts))))

M src/io/dominic/wedge/mise/rebel.clj => src/io/dominic/wedge/mise/rebel.clj +5 -1
@@ 1,7 1,8 @@
(ns io.dominic.wedge.mise.rebel
    [clojure.tools.deps.alpha.repl :as tda.repl]
    [io.dominic.wedge.mise :as mise]))
    [io.dominic.wedge.mise :as mise]
    [io.dominic.wedge.mise.impl.nrepl :as nrepl]))

(defn- add-libs

@@ 24,6 25,9 @@
    (.setContextClassLoader (Thread/currentThread) (clojure.lang.DynamicClassLoader. cl)))
  (when (some #{"--nrepl"} args)
  (load "io/dominic/wedge/mise/rebel/impl")
  ((resolve 'main*)))