diff --git a/CHANGELOG.md b/CHANGELOG.md index 470e425d6..cc63cf3fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/cider.el b/cider.el index dc94d5218..5c2a1168e 100644 --- a/cider.el +++ b/cider.el @@ -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. @@ -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 @@ -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)