@@ -455,6 +455,16 @@ Should be newer than the required version for optimal results."
455
455
:package-version '(cider . " 1.2.0" )
456
456
:safe #'stringp )
457
457
458
+ (defcustom cider-enrich-classpath t
459
+ " Whether to use git.io/JiJVX for adding sources and javadocs to the classpath.
460
+
461
+ This is done in a clean manner, without interfering with classloaders.
462
+
463
+ Only available for Leiningen projects at the moment."
464
+ :type 'boolean
465
+ :group 'cider
466
+ :safe #'booleanp )
467
+
458
468
(defcustom cider-jack-in-auto-inject-clojure nil
459
469
" Version of clojure to auto-inject into REPL.
460
470
If nil, do not inject Clojure into the REPL. If `latest' , inject
@@ -484,25 +494,41 @@ want to inject some middleware only when within a project context.)")
484
494
(cider-add-to-alist 'cider-jack-in-lein-plugins
485
495
" cider/cider-nrepl" cider-injected-middleware-version)
486
496
497
+ (defvar cider-jack-in-lein-middlewares nil
498
+ " List of Leiningen :middleware values to be injected at jack-in.
499
+
500
+ Necessary for plugins which require an explicit middleware name to be specified.
501
+
502
+ Can also facilitate using middleware in a specific order." )
503
+ (put 'cider-jack-in-lein-middlewares 'risky-local-variable t )
504
+
487
505
(defvar cider-jack-in-cljs-lein-plugins nil
488
506
" List of Leiningen plugins to be injected at jack-in.
489
507
Added to `cider-jack-in-lein-plugins' (which see) when doing
490
508
`cider-jack-in-cljs' ." )
491
509
(put 'cider-jack-in-cljs-lein-plugins 'risky-local-variable t )
492
510
493
- (defun cider-jack-in-normalized-lein-plugins ()
511
+ (defun cider-jack-in-normalized-lein-plugins (&optional project-type )
494
512
" Return a normalized list of Leiningen plugins to be injected.
495
513
See `cider-jack-in-lein-plugins' for the format, except that the list
496
- returned by this function does not include keyword arguments."
497
- (thread-last cider-jack-in-lein-plugins
498
- (seq-filter
499
- (lambda (spec )
500
- (if-let* ((pred (plist-get (seq-drop spec 2 ) :predicate )))
501
- (funcall pred spec)
502
- t )))
503
- (mapcar
504
- (lambda (spec )
505
- (seq-take spec 2 )))))
514
+ returned by this function does not include keyword arguments.
515
+
516
+ PROJECT-TYPE will be observed, for avoiding injecting plugins
517
+ where it doesn't make sense."
518
+ (let* ((corpus (if (and cider-enrich-classpath
519
+ (eq project-type 'lein ))
520
+ (append cider-jack-in-lein-plugins
521
+ '((" mx.cider/enrich-classpath" " 1.4.1" )))
522
+ cider-jack-in-lein-plugins)))
523
+ (thread-last corpus
524
+ (seq-filter
525
+ (lambda (spec )
526
+ (if-let* ((pred (plist-get (seq-drop spec 2 ) :predicate )))
527
+ (funcall pred spec)
528
+ t )))
529
+ (mapcar
530
+ (lambda (spec )
531
+ (seq-take spec 2 ))))))
506
532
507
533
(defvar cider-jack-in-nrepl-middlewares nil
508
534
" List of Clojure variable names.
@@ -584,10 +610,10 @@ of EXCLUSIONS can be provided as well. The returned
584
610
string is quoted for passing as argument to an inferior shell."
585
611
(shell-quote-argument (format " [%s %S%s ] " (car list ) (cadr list ) (cider--lein-artifact-exclusions exclusions))))
586
612
587
- (defun cider-lein-jack-in-dependencies (global-opts params dependencies dependencies-exclusions lein-plugins )
613
+ (defun cider-lein-jack-in-dependencies (global-opts params dependencies dependencies-exclusions lein-plugins &optional lein-middlewares )
588
614
" Create lein jack-in dependencies.
589
615
Does so by concatenating GLOBAL-OPTS, DEPENDENCIES, with DEPENDENCIES-EXCLUSIONS
590
- removed, LEIN-PLUGINS, and finally PARAMS."
616
+ removed, LEIN-PLUGINS, LEIN-MIDDLEWARES and finally PARAMS."
591
617
(concat
592
618
global-opts
593
619
(unless (seq-empty-p global-opts) " " )
@@ -600,7 +626,11 @@ removed, LEIN-PLUGINS, and finally PARAMS."
600
626
(seq-map (lambda (plugin )
601
627
(concat " update-in :plugins conj "
602
628
(cider--list-as-lein-artifact plugin)))
603
- lein-plugins))
629
+ lein-plugins)
630
+ (seq-map (lambda (middleware )
631
+ (concat " update-in :middlewares conj "
632
+ middleware))
633
+ lein-middlewares))
604
634
" -- " )
605
635
" -- "
606
636
params))
@@ -614,6 +644,8 @@ one used."
614
644
(let* ((deps-string (string-join
615
645
(seq-map (lambda (dep )
616
646
(format " %s {:mvn/version \" %s \" }" (car dep) (cadr dep)))
647
+ ; ; NOTE: injecting Lein plugins for deps.edn projects
648
+ ; ; seems a bit dubious, worth revisiting at some point.
617
649
(append dependencies cider-jack-in-lein-plugins))
618
650
" " ))
619
651
(middleware (mapconcat
@@ -675,13 +707,17 @@ dependencies."
675
707
(cider-add-clojure-dependencies-maybe
676
708
cider-jack-in-dependencies)
677
709
cider-jack-in-dependencies-exclusions
678
- (cider-jack-in-normalized-lein-plugins)))
710
+ (cider-jack-in-normalized-lein-plugins project-type)
711
+ (if cider-enrich-classpath
712
+ (append cider-jack-in-lein-middlewares
713
+ '(" cider.enrich-classpath/middleware" ))
714
+ cider-jack-in-lein-middlewares)))
679
715
('boot (cider-boot-jack-in-dependencies
680
716
global-opts
681
717
params
682
718
(cider-add-clojure-dependencies-maybe
683
719
cider-jack-in-dependencies)
684
- (cider-jack-in-normalized-lein-plugins)
720
+ (cider-jack-in-normalized-lein-plugins project-type )
685
721
(cider-jack-in-normalized-nrepl-middlewares)))
686
722
('clojure-cli (cider-clojure-cli-jack-in-dependencies
687
723
global-opts
0 commit comments