Description
Evolving the Cider support for Clojure CLI tools by providing a means to switch off the auto-injected dependencies.
Using Clojure CLI tools, the auto-injected dependencies and parameters can be replaced by a single alias (or combined aliases), simplifying the command line. This also allows for greater flexibility in how cider is run, whilst still providing the highly convenient jack-in experience.
Related to #2916
This is not meant to be a final design, but the next useful change without breaking the existing experience.
Use cases
-
Additional command line options
Add an alias to include extra paths and/or libraries to the Clojure repl (eg.:env/test
which adds the:extra-paths ["test"]
value so that the Cider test runner can find the unit test code in a project (without it having to be added to the main paths and ending up with test code in production).
The latest release of Cider already allows such an alias to be injected correctly along with the standard Clojure libraries and parameters -
Custom command line options
Use custom command line options that replace the auto-injected dependencies and params
Set cider-clojure-cli-global-options
(EDIT: this variable has been replaced by cider-clojure-cli-aliases
) value via .dir-locals.el
and use only that value as an argument to the clojure
command
The cider-clojure-cli-global-options
would provide an alias that included the relevant nrepl, nrepl-refator & cider-nrepl libraries.
Using the universal argument, this would also present a simplified command line, avoiding the need to delete the injected cider options
Suggested Code change
Update the cider-inject-jack-in-dependencies
function to include a check of the new variable called cider-clojure-cli-jack-in-options
, which should be set to true by default to retain the current behaviour of Cider.
Create a defcustom called cider-clojure-cli-jack-in-options
and set to true by default.
If cider-clojure-cli-jack-in-options
is set to nil
then only the value of cider-clojure-cli-global-options
is used with the clojure
command
Code change from line 635 of cider.el
('clojure-cli
(if cider-clojure-cli-jack-in-options
(cider-clojure-cli-jack-in-dependencies
global-opts
params
(cider-add-clojure-dependencies-maybe
cider-jack-in-dependencies))
global-opts))
A video of my experiments around this issue is here: https://youtu.be/XuquYgOSOnc?t=6879 (skipped to the conclusion as its about 2 hrs long)
@bbatsov if this approach seems sensible, I'll raise a PR with this change. Happy to discuss further if you wish.