@@ -646,6 +646,20 @@ dependencies."
646
646
(unless (cider-library-present-p " boot-cljs-repl" )
647
647
(user-error " The Boot ClojureScript REPL is not available. Please check https://github.com/adzerk-oss/boot-cljs-repl/blob/master/README.md" )))
648
648
649
+ (defun cider-check-shadow-cljs-requirements ()
650
+ " Check whether we can start a shadow-cljs REPL."
651
+ (unless (cider-library-present-p " shadow-cljs" )
652
+ (user-error " The shadow-cljs ClojureScript REPL is not available" )))
653
+
654
+ (defun cider-shadow-cljs-init-form ()
655
+ " Generate the init form for a shadow-cljs REPL.
656
+
657
+ We have to prompt the user to select a build, that's why
658
+ this is a command, not just a string."
659
+ (let ((form " (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :%s) (shadow/nrepl-select :%s))" )
660
+ (build (string-remove-prefix " :" (read-from-minibuffer " Select shadow-cljs build: " ))))
661
+ (format form build build)))
662
+
649
663
(defconst cider-cljs-repl-types
650
664
'((" Rhino" " (cemerick.piggieback/cljs-repl (cljs.repl.rhino/repl-env))"
651
665
nil )
@@ -658,11 +672,14 @@ dependencies."
658
672
(" Weasel" " (do (require 'weasel.repl.websocket) (cemerick.piggieback/cljs-repl (weasel.repl.websocket/repl-env :ip \" 127.0.0.1\" :port 9001)))"
659
673
cider-check-weasel-requirements)
660
674
(" Boot" " (do (require 'adzerk.boot-cljs-repl) (adzerk.boot-cljs-repl/start-repl))"
661
- cider-check-boot-requirements))
675
+ cider-check-boot-requirements)
676
+ (" Shadow" cider-shadow-cljs-init-form cider-check-shadow-cljs-requirements))
662
677
" A list of supported ClojureScript REPLs.
663
678
664
679
For each one we have its name, the form we need to evaluate in a Clojure
665
- REPL to start the ClojureScript REPL and functions to very their requirements." )
680
+ REPL to start the ClojureScript REPL and functions to very their requirements.
681
+
682
+ The form should be either a string or a function producing a string." )
666
683
667
684
(defcustom cider-default-cljs-repl nil
668
685
" The default ClojureScript REPL to start.
@@ -692,10 +709,14 @@ you're working on."
692
709
693
710
(defun cider-cljs-repl-form (repl-type )
694
711
" Get the cljs REPL form for REPL-TYPE."
695
- (cadr (seq-find
696
- (lambda (entry )
697
- (equal (car entry) repl-type))
698
- cider-cljs-repl-types)))
712
+ (let ((repl-form (cadr (seq-find
713
+ (lambda (entry )
714
+ (equal (car entry) repl-type))
715
+ cider-cljs-repl-types))))
716
+ ; ; repl-form can be either a string or a function producing a string
717
+ (if (symbolp repl-form)
718
+ (funcall repl-form)
719
+ repl-form)))
699
720
700
721
(defun cider-verify-cljs-repl-requirements (repl-type )
701
722
" Verify that the requirements for REPL-TYPE are met."
0 commit comments