Skip to content

Commit fdc8d69

Browse files
committed
Added the Krell REPL support
This change adds the support for Krell REPL. Instead of having to pick a custom REPL and specifying a cider-custom-cljs-repl-init-form, this is all now included. All the user has to do is pick the REPL type, which in this case is krell.
1 parent 60c7d26 commit fdc8d69

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

cider.el

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ Sub-match 1 must be the project path.")
330330
('clojure-cli cider-clojure-cli-command)
331331
('shadow-cljs cider-shadow-cljs-command)
332332
('gradle cider-gradle-command)
333+
('krell cider-clojure-cli-command)
333334
(_ (user-error "Unsupported project type `%S'" project-type))))
334335

335336
(defun cider-jack-in-resolve-command (project-type)
@@ -345,6 +346,7 @@ Throws an error if PROJECT-TYPE is unknown."
345346
(when-let* ((command (cider--resolve-command (car parts))))
346347
(mapconcat #'identity (cons command (cdr parts)) " "))))
347348
('gradle (cider--resolve-command cider-gradle-command))
349+
('krell (cider--resolve-command cider-clojure-cli-command))
348350
(_ (user-error "Unsupported project type `%S'" project-type))))
349351

350352
(defun cider-jack-in-global-options (project-type)
@@ -355,23 +357,28 @@ Throws an error if PROJECT-TYPE is unknown."
355357
('clojure-cli cider-clojure-cli-global-options)
356358
('shadow-cljs cider-shadow-cljs-global-options)
357359
('gradle cider-gradle-global-options)
360+
('krell cider-clojure-cli-global-options)
358361
(_ (user-error "Unsupported project type `%S'" project-type))))
359362

363+
(defun cider--clojure-cli-parameters ()
364+
(format cider-clojure-cli-parameters
365+
(concat
366+
"["
367+
(mapconcat
368+
(apply-partially #'format "\"%s\"")
369+
(cider-jack-in-normalized-nrepl-middlewares)
370+
", ")
371+
"]")))
372+
360373
(defun cider-jack-in-params (project-type)
361374
"Determine the commands params for `cider-jack-in' for the PROJECT-TYPE."
362375
(pcase project-type
363376
('lein cider-lein-parameters)
364377
('boot cider-boot-parameters)
365-
('clojure-cli (format cider-clojure-cli-parameters
366-
(concat
367-
"["
368-
(mapconcat
369-
(apply-partially #'format "\"%s\"")
370-
(cider-jack-in-normalized-nrepl-middlewares)
371-
", ")
372-
"]")))
378+
('clojure-cli (cider--clojure-cli-parameters))
373379
('shadow-cljs cider-shadow-cljs-parameters)
374380
('gradle cider-gradle-parameters)
381+
('krell (cider--clojure-cli-parameters))
375382
(_ (user-error "Unsupported project type `%S'" project-type))))
376383

377384

@@ -689,6 +696,12 @@ Generally you should not disable this unless you run into some faulty check."
689696
(unless (cider-library-present-p "adzerk.boot-cljs-repl")
690697
(user-error "The Boot ClojureScript REPL is not available. Please check https://github.com/adzerk-oss/boot-cljs-repl/blob/master/README.md for details")))
691698

699+
(defun cider-check-krell-requirements ()
700+
"Check whether we can start a Krell ClojureScript REPL."
701+
(cider-verify-piggieback-is-present)
702+
(unless (cider-library-present-p "krell.repl")
703+
(user-error "The Krell ClojureScript REPL is not available. Please check https://github.com/vouch-opensource/krell for details")))
704+
692705
(defun cider-check-shadow-cljs-requirements ()
693706
"Check whether we can start a shadow-cljs REPL."
694707
(unless (cider-library-present-p "shadow.cljs.devtools.api")
@@ -825,6 +838,15 @@ The supplied string will be wrapped in a do form if needed."
825838
cider-check-boot-requirements)
826839
(shadow cider-shadow-cljs-init-form cider-check-shadow-cljs-requirements)
827840
(shadow-select cider-shadow-select-cljs-init-form cider-check-shadow-cljs-requirements)
841+
(krell "(require '[clojure.edn :as edn]
842+
'[clojure.java.io :as io]
843+
'[cider.piggieback]
844+
'[krell.api :as krell]
845+
'[krell.repl])
846+
(def config (edn/read-string (slurp (io/file \"build.edn\"))))
847+
(krell/build config)
848+
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))"
849+
cider-check-krell-requirements)
828850
(custom cider-custom-cljs-repl-init-form nil))
829851
"A list of supported ClojureScript REPLs.
830852
@@ -867,6 +889,7 @@ you're working on."
867889
(const :tag "Boot" boot)
868890
(const :tag "Shadow" shadow)
869891
(const :tag "Shadow w/o Server" shadow-select)
892+
(const :tag "Krell" krell)
870893
(const :tag "Custom" custom))
871894
:group 'cider
872895
:safe #'symbolp

0 commit comments

Comments
 (0)