-
-
Save mtnygard/17589d4a8569c231c8735a09a2046e5f to your computer and use it in GitHub Desktop.
Launch a plain clojure repl according to project.clj without leiningen (most of the time). This version supports CIDER and clj-refactor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# launch a clojure plain repl but with options and classpath matching project.clj | |
# Except when project.clj changes (and on first launch), lein is not called. | |
CODE=' | |
(let [p (leiningen.core.project/read) | |
args (@(var leiningen.core.eval/get-jvm-args) p) | |
cp (with-out-str (leiningen.classpath/classpath p))] | |
(print "ARGS=\"") | |
(apply print args) | |
(println "\"") | |
(print "CP=\"") | |
(print cp) | |
(println "\"")) | |
' | |
if [ ! -f "project.clj" ]; then | |
echo "No project.clj" | |
exit 1 | |
fi | |
if [ ! -f ".kein" ] || [ "project.clj" -nt ".kein" ] || [ $0 -nt ".kein" ]; then | |
lein update-in : assoc :eval-in :leiningen :pedantic? false -- run -m clojure.main -e "$CODE" > .kein | |
fi | |
source .kein | |
CIDER_REPL_CODE=" | |
(require '[clojure.tools.nrepl.server :as nrepl]) | |
(require '[refactor-nrepl.middleware]) | |
(require '[cider.nrepl :refer [cider-middleware]]) | |
(defn cider-cljr-nrepl-handler [] | |
(apply nrepl/default-handler (cons #'refactor-nrepl.middleware/wrap-refactor | |
(map resolve cider-middleware)))) | |
(defonce server (nrepl/start-server :handler (cider-cljr-nrepl-handler))) | |
(spit \".nrepl-port\" (:port server))" | |
java $ARGS -cp $CP clojure.main "$@" -e "$CIDER_REPL_CODE" -r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment