-
-
Notifications
You must be signed in to change notification settings - Fork 651
Add jack-in support for ClojureCLR #3839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c8f7bc8
0e82e42
7dedcec
469d9e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,6 +225,30 @@ By default we favor the project-specific shadow-cljs over the system-wide." | |
| :safe #'stringp | ||
| :package-version '(cider . "1.14.0")) | ||
|
|
||
| (defcustom cider-clojure-clr-cli-command | ||
| "cljr" | ||
| "The command used to execute ClojureCLR." | ||
| :type 'string | ||
| :group 'cider | ||
| :safe #'stringp | ||
| :package-version '(cider . "2.0.1")) | ||
|
|
||
| (defcustom cider-clojure-clr-cli-parameters | ||
| "-X clojure.tools.nrepl/start-server!" | ||
| "Params passed to ClojureCLR to start an nREPL server via `cider-jack-in'." | ||
| :type 'string | ||
| :group 'cider | ||
| :safe #'stringp | ||
| :package-version '(cider . "2.0.1")) | ||
|
|
||
| ;; Clojure git deps require :git/sha even when :git/tag is set, just do full SHA | ||
| (defcustom cider-clojure-clr-cli-nrepl-sha "a6bf822a5f72ec613f703eaf95420758591f2437" | ||
| "The version of clr.tools.nrepl injected on jack-in with ClojureCLR." | ||
| :type 'string | ||
| :group 'cider | ||
| :safe #'stringp | ||
| :package-version '(cider . "2.0.1")) | ||
|
|
||
|
|
||
| ;;; Jack-in defaults and toggles | ||
|
|
||
|
|
@@ -668,6 +692,30 @@ Does so by concatenating PARAMS and DEPENDENCIES." | |
| " " | ||
| params))) | ||
|
|
||
| (defun cider-clojure-clr-cli-jack-in-dependencies (params dependencies &optional command) | ||
| "Create ClojureCLR clr.core.cli jack-in dependencies. | ||
| Does so by concatenating DEPENDENCIES, and PARAMS into a | ||
| suitable `cljr` invocation and quoting, also accounting for COMMAND if | ||
| provided." | ||
| (let* ((all-deps (thread-last dependencies | ||
| (cider--dedupe-deps) | ||
| (seq-map (lambda (dep) | ||
| (if (listp (cadr dep)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only caller passes a (let* ((deps (format "{:deps {%s}}"
(mapconcat (lambda (dep)
(format "%s {:git/sha \"%s\"}" (car dep) (cadr dep)))
(cider--dedupe-deps dependencies)
" ")))
(deps-quoted (cider--shell-quote-argument deps command)))
(if params
(format "-Sdeps %s %s" deps-quoted params)
(format "-Sdeps %s" deps-quoted))) |
||
| (format "%s {%s}" | ||
| (car dep) | ||
| (seq-reduce | ||
| (lambda (acc v) | ||
| (concat acc (format " :%s \"%s\" " (car v) (cdr v)))) | ||
| (cadr dep) | ||
| "")) | ||
| (format "%s {:git/sha \"%s\"}" (car dep) (cadr dep))))))) | ||
| (deps (format "{:deps {%s}}" | ||
| (string-join all-deps " "))) | ||
| (deps-quoted (cider--shell-quote-argument deps command))) | ||
| (format "-Sdeps %s %s" | ||
| deps-quoted | ||
| (if params (format " %s" params) "")))) | ||
|
|
||
| (defun cider-add-clojure-dependencies-maybe (dependencies) | ||
| "Return DEPENDENCIES with an added Clojure dependency if requested. | ||
| See also `cider-jack-in-auto-inject-clojure'." | ||
|
|
@@ -727,6 +775,14 @@ COMMAND is the resolved jack-in command, used to handle PowerShell quoting." | |
| (cider-add-clojure-dependencies-maybe cider-jack-in-dependencies) | ||
| (cider-jack-in-normalized-nrepl-middlewares))) | ||
|
|
||
| (defun cider--clojure-clr-cli-inject-deps (params _project-type command) | ||
| "Inject CIDER deps into PARAMS for a ClojureCLR CLI project. | ||
| COMMAND is the resolved jack-in command, used to handle PowerShell quoting." | ||
| (cider-clojure-clr-cli-jack-in-dependencies | ||
| params | ||
| `(("io.github.clojure/clr.tools.nrepl" ,cider-clojure-clr-cli-nrepl-sha)) | ||
| command)) | ||
|
|
||
| (defun cider-inject-jack-in-dependencies (params project-type &optional command) | ||
| "Return PARAMS with injected REPL dependencies for PROJECT-TYPE. | ||
| Looks up the tool's :inject-fn in `cider-jack-in-tools' and calls it with | ||
|
|
@@ -894,6 +950,13 @@ Throws an error if PROJECT-TYPE is unknown." | |
| :project-files '("basilisp.edn") | ||
| :dispatch-prefix-arg 5) | ||
|
|
||
| (cider-register-jack-in-tool 'clojure-clr-cli | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| :command-var 'cider-clojure-clr-cli-command | ||
| :params-var 'cider-clojure-clr-cli-parameters | ||
| :project-files '("deps-clr.edn") | ||
| :inject-fn #'cider--clojure-clr-cli-inject-deps | ||
| :dispatch-prefix-arg 6) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no tests yet. The cheap ones that would cover this, all in test/cider-jack-in-tests.el:
(describe "cider-clojure-clr-cli-jack-in-dependencies"
(it "produces a -Sdeps invocation with the clr.tools.nrepl git dep"
(let ((result (cider-clojure-clr-cli-jack-in-dependencies
nil '(("io.github.clojure/clr.tools.nrepl" "abc123")))))
(expect result :to-match "\\`-Sdeps ")
(expect result :to-match "io.github.clojure/clr.tools.nrepl")
(expect result :to-match ":git/sha")
(expect result :to-match "abc123")))
(it "appends params after the deps"
(expect (cider-clojure-clr-cli-jack-in-dependencies
"-X clojure.tools.nrepl/start-server!"
'(("io.github.clojure/clr.tools.nrepl" "abc123")))
:to-match "-X clojure.tools.nrepl/start-server!\\'")))
|
||
|
|
||
|
|
||
| ;;; ClojureScript jack-in helpers | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.