Skip to content

Commit

Permalink
Introduce variable cider-clojure-cli-global-aliases (#3623)
Browse files Browse the repository at this point in the history
  • Loading branch information
behrica committed Apr 21, 2024
1 parent ebab3c7 commit 6b60332
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,8 +2,10 @@

## master (unreleased)

### New features


### New features
- [#3632](https://github.com/clojure-emacs/cider/pull/3623): new configuration variable `cider-clojure-cli-global-aliases`
- [#3366](https://github.com/clojure-emacs/cider/pull/3366): Support display of error overlays with #dbg! and #break! reader macros.
- [#3622](https://github.com/clojure-emacs/cider/pull/3461): Basic support for using CIDER from [clojure-ts-mode](https://github.com/clojure-emacs/clojure-ts-mode).
- The `clojure-mode` dependency is still required for CIDER to function.
Expand Down
40 changes: 32 additions & 8 deletions cider.el
Expand Up @@ -173,6 +173,20 @@ then concatenated into the \"-M[your-aliases]:cider/nrepl\" form."
:safe #'stringp
:package-version '(cider . "1.1"))


(defcustom cider-clojure-cli-global-aliases
nil
"Global aliases to include when jacking in with the clojure CLI.
This value should be a string of the form \":foo:bar\", and
will be prepended to the value of `cider-clojure-cli-aliases'.
Alias names should be of the form \":foo:bar\".
Leading \"-A\" \"-M\" \"-T\" or \"-X\" are stripped from aliases
then concatenated into the \"-M[your-aliases]:cider/nrepl\" form."
:type 'string
:safe #'stringp
:package-version '(cider . "1.14"))


(defcustom cider-shadow-cljs-command
"npx shadow-cljs"
"The command used to execute shadow-cljs.
Expand Down Expand Up @@ -817,6 +831,23 @@ rules to quote it."
(utf-16le-command (encode-coding-string command 'utf-16le)))
(format "-encodedCommand %s" (base64-encode-string utf-16le-command t))))


(defun cider--combined-aliases ()
"Creates the combined ailases as stringe separated by ':'."
(let ((final-cider-clojure-cli-aliases
(cond ((and cider-clojure-cli-global-aliases cider-clojure-cli-aliases)
(concat cider-clojure-cli-global-aliases ":" cider-clojure-cli-aliases))
(cider-clojure-cli-global-aliases cider-clojure-cli-global-aliases)
(t cider-clojure-cli-aliases))))
(if final-cider-clojure-cli-aliases
;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases
;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last
(let ((aliases (format "%s" (replace-regexp-in-string "^-\\(A\\|M\\|T\\|X\\)" "" final-cider-clojure-cli-aliases))))
(if (string-prefix-p ":" aliases)
aliases
(concat ":" aliases)))
"")))

(defun cider-clojure-cli-jack-in-dependencies (global-options params dependencies &optional command)
"Create Clojure tools.deps jack-in dependencies.
Does so by concatenating DEPENDENCIES, PARAMS and GLOBAL-OPTIONS into a
Expand Down Expand Up @@ -850,14 +881,7 @@ your aliases contain any mains, the cider/nrepl one will be the one used."
;; TODO: global-options are deprecated and should be removed in CIDER 2.0
(if global-options (format "%s " global-options) "")
deps-quoted
(if cider-clojure-cli-aliases
;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases
;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last
(let ((aliases (format "%s" (replace-regexp-in-string "^-\\(A\\|M\\|T\\|X\\)" "" cider-clojure-cli-aliases))))
(if (string-prefix-p ":" aliases)
aliases
(concat ":" aliases)))
"")
(cider--combined-aliases)
(if params (format " %s" params) ""))))

(defun cider-shadow-cljs-jack-in-dependencies (global-opts params dependencies)
Expand Down

0 comments on commit 6b60332

Please sign in to comment.