Function: cider-shadow-cljs-init-form

cider-shadow-cljs-init-form is a byte-compiled function defined in cider.el.

Signature

(cider-shadow-cljs-init-form)

Documentation

Generate the init form for a shadow-cljs REPL.

We have to prompt the user to select a build, that's why this is a command, not just a string.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider.el
(defun cider-shadow-cljs-init-form ()
  "Generate the init form for a shadow-cljs REPL.
We have to prompt the user to select a build, that's why
this is a command, not just a string."
  (let* ((shadow-require "(require '[shadow.cljs.devtools.api :as shadow])")

         (default-build (cider-normalize-cljs-init-options
                         (or cider-shadow-default-options
                             (car cider-shadow-watched-builds)
                             (completing-read "Select shadow-cljs build: "
                                              (cider--shadow-get-builds)))))

         (watched-builds (or (mapcar #'cider-normalize-cljs-init-options cider-shadow-watched-builds)
                             (list default-build)))

         (watched-builds-form (mapconcat (lambda (build) (format "(shadow/watch %s)" build))
                                         watched-builds
                                         " "))
         ;; form used for user-defined builds
         (user-build-form "(do %s %s (shadow/nrepl-select %s))")
         ;; form used for built-in builds like :browser-repl and :node-repl
         (default-build-form "(do %s (shadow/%s))"))
    (if (member default-build '(":browser-repl" ":node-repl"))
        (format default-build-form shadow-require (string-remove-prefix ":" default-build))
      (format user-build-form shadow-require watched-builds-form default-build))))