79
79
(require 'cider-common )
80
80
(require 'cider-compat )
81
81
(require 'cider-debug )
82
+ (require 'cider-util )
82
83
83
84
(require 'tramp-sh )
84
85
(require 'subr-x )
@@ -214,42 +215,42 @@ By default we favor the project-specific shadow-cljs over the system-wide."
214
215
:safe #'stringp
215
216
:package-version '(cider . " 0.10.0" ))
216
217
217
- (defcustom cider-jack-in-default (if (executable-find " clojure" ) " clojure-cli" " lein" )
218
+ (defcustom cider-jack-in-default (if (executable-find " clojure" ) ' clojure-cli ' lein )
218
219
" The default tool to use when doing `cider-jack-in' outside a project.
219
220
This value will only be consulted when no identifying file types, i.e.
220
221
project.clj for leiningen or build.boot for boot, could be found.
221
222
222
223
As the Clojure CLI is bundled with Clojure itself, it's the default.
223
224
In the absence of the Clojure CLI (e.g. on Windows), we fallback
224
225
to Leiningen."
225
- :type '(choice (const " lein" )
226
- (const " boot" )
227
- (const " clojure-cli" )
228
- (const " shadow-cljs" )
229
- (const " gradle" ))
226
+ :type '(choice (const ' lein )
227
+ (const ' boot )
228
+ (const ' clojure-cli )
229
+ (const ' shadow-cljs )
230
+ (const ' gradle ))
230
231
:group 'cider
231
- :safe #'stringp
232
+ :safe #'symbolp
232
233
:package-version '(cider . " 0.9.0" ))
233
234
234
235
(define-obsolete-variable-alias 'cider-default-repl-command 'cider-jack-in-default )
235
236
236
237
(defcustom cider-preferred-build-tool
237
238
nil
238
239
" Allow choosing a build system when there are many.
239
- When there are artifacts from multiple build systems (\" lein\" , \" boot \" ,
240
- \" gradle \" ) the user is prompted to select one of them. When non-nil, this
240
+ When there are project markers from multiple build systems (e.g. lein and
241
+ boot ) the user is prompted to select one of them. When non-nil, this
241
242
variable will suppress this behavior and will select whatever build system
242
243
is indicated by the variable if present. Note, this is only when CIDER
243
244
cannot decide which of many build systems to use and will never override a
244
245
command when there is no ambiguity."
245
- :type '(choice (const " lein" )
246
- (const " boot" )
247
- (const " clojure-cli" )
248
- (const " shadow-cljs" )
249
- (const " gradle" )
246
+ :type '(choice (const ' lein )
247
+ (const ' boot )
248
+ (const ' clojure-cli )
249
+ (const ' shadow-cljs )
250
+ (const ' gradle )
250
251
(const :tag " Always ask" nil ))
251
252
:group 'cider
252
- :safe #'stringp
253
+ :safe #'symbolp
253
254
:package-version '(cider . " 0.13.0" ))
254
255
255
256
(defcustom cider-allow-jack-in-without-project 'warn
@@ -320,54 +321,54 @@ Sub-match 1 must be the project path.")
320
321
(defun cider-jack-in-command (project-type )
321
322
" Determine the command `cider-jack-in' needs to invoke for the PROJECT-TYPE."
322
323
(pcase project-type
323
- (" lein" cider-lein-command)
324
- (" boot" cider-boot-command)
325
- (" clojure-cli" cider-clojure-cli-command)
326
- (" shadow-cljs" cider-shadow-cljs-command)
327
- (" gradle" cider-gradle-command)
328
- (_ (user-error " Unsupported project type `%s ' " project-type))))
324
+ (' lein cider-lein-command)
325
+ (' boot cider-boot-command)
326
+ (' clojure-cli cider-clojure-cli-command)
327
+ (' shadow-cljs cider-shadow-cljs-command)
328
+ (' gradle cider-gradle-command)
329
+ (_ (user-error " Unsupported project type `%S ' " project-type))))
329
330
330
331
(defun cider-jack-in-resolve-command (project-type )
331
332
" Determine the resolved file path to `cider-jack-in-command' .
332
333
Throws an error if PROJECT-TYPE is unknown."
333
334
(pcase project-type
334
- (" lein" (cider--resolve-command cider-lein-command))
335
- (" boot" (cider--resolve-command cider-boot-command))
336
- (" clojure-cli" (cider--resolve-command cider-clojure-cli-command))
335
+ (' lein (cider--resolve-command cider-lein-command))
336
+ (' boot (cider--resolve-command cider-boot-command))
337
+ (' clojure-cli (cider--resolve-command cider-clojure-cli-command))
337
338
; ; here we have to account for the possibility that the command is either
338
339
; ; "npx shadow-cljs" or just "shadow-cljs"
339
- (" shadow-cljs" (let ((parts (split-string cider-shadow-cljs-command)))
340
+ (' shadow-cljs (let ((parts (split-string cider-shadow-cljs-command)))
340
341
(when-let* ((command (cider--resolve-command (car parts))))
341
342
(mapconcat #'identity (cons command (cdr parts)) " " ))))
342
- (" gradle" (cider--resolve-command cider-gradle-command))
343
- (_ (user-error " Unsupported project type `%s ' " project-type))))
343
+ (' gradle (cider--resolve-command cider-gradle-command))
344
+ (_ (user-error " Unsupported project type `%S ' " project-type))))
344
345
345
346
(defun cider-jack-in-global-options (project-type )
346
347
" Determine the command line options for `cider-jack-in' for the PROJECT-TYPE."
347
348
(pcase project-type
348
- (" lein" cider-lein-global-options)
349
- (" boot" cider-boot-global-options)
350
- (" clojure-cli" cider-clojure-cli-global-options)
351
- (" shadow-cljs" cider-shadow-cljs-global-options)
352
- (" gradle" cider-gradle-global-options)
353
- (_ (user-error " Unsupported project type `%s ' " project-type))))
349
+ (' lein cider-lein-global-options)
350
+ (' boot cider-boot-global-options)
351
+ (' clojure-cli cider-clojure-cli-global-options)
352
+ (' shadow-cljs cider-shadow-cljs-global-options)
353
+ (' gradle cider-gradle-global-options)
354
+ (_ (user-error " Unsupported project type `%S ' " project-type))))
354
355
355
356
(defun cider-jack-in-params (project-type )
356
357
" Determine the commands params for `cider-jack-in' for the PROJECT-TYPE."
357
358
(pcase project-type
358
- (" lein" cider-lein-parameters)
359
- (" boot" cider-boot-parameters)
360
- (" clojure-cli" (format cider-clojure-cli-parameters
359
+ (' lein cider-lein-parameters)
360
+ (' boot cider-boot-parameters)
361
+ (' clojure-cli (format cider-clojure-cli-parameters
361
362
(concat
362
363
" ["
363
364
(mapconcat
364
365
(apply-partially #'format " \" %s\" " )
365
366
(cider-jack-in-normalized-nrepl-middlewares)
366
367
" , " )
367
368
" ]" )))
368
- (" shadow-cljs" cider-shadow-cljs-parameters)
369
- (" gradle" cider-gradle-parameters)
370
- (_ (user-error " Unsupported project type `%s ' " project-type))))
369
+ (' shadow-cljs cider-shadow-cljs-parameters)
370
+ (' gradle cider-gradle-parameters)
371
+ (_ (user-error " Unsupported project type `%S ' " project-type))))
371
372
372
373
373
374
; ;; Jack-in dependencies injection
@@ -607,35 +608,35 @@ the used PROJECT-TYPE. Eliminates the need for hacking profiles.clj or the
607
608
boot script for supporting cider with its nREPL middleware and
608
609
dependencies."
609
610
(pcase project-type
610
- (" lein" (cider-lein-jack-in-dependencies
611
- global-opts
612
- params
613
- (cider-add-clojure-dependencies-maybe
614
- cider-jack-in-dependencies)
615
- cider-jack-in-dependencies-exclusions
616
- (cider-jack-in-normalized-lein-plugins)))
617
- (" boot" (cider-boot-jack-in-dependencies
618
- global-opts
619
- params
620
- (cider-add-clojure-dependencies-maybe
621
- cider-jack-in-dependencies)
622
- (cider-jack-in-normalized-lein-plugins)
623
- (cider-jack-in-normalized-nrepl-middlewares)))
624
- (" clojure-cli" (cider-clojure-cli-jack-in-dependencies
625
- global-opts
626
- params
627
- (cider-add-clojure-dependencies-maybe
628
- cider-jack-in-dependencies)))
629
- (" shadow-cljs" (cider-shadow-cljs-jack-in-dependencies
630
- global-opts
631
- params
632
- (cider-add-clojure-dependencies-maybe
633
- cider-jack-in-dependencies)))
634
- (" gradle" (concat
635
- global-opts
636
- (unless (seq-empty-p global-opts) " " )
637
- params))
638
- (_ (error " Unsupported project type `%s ' " project-type))))
611
+ (' lein (cider-lein-jack-in-dependencies
612
+ global-opts
613
+ params
614
+ (cider-add-clojure-dependencies-maybe
615
+ cider-jack-in-dependencies)
616
+ cider-jack-in-dependencies-exclusions
617
+ (cider-jack-in-normalized-lein-plugins)))
618
+ (' boot (cider-boot-jack-in-dependencies
619
+ global-opts
620
+ params
621
+ (cider-add-clojure-dependencies-maybe
622
+ cider-jack-in-dependencies)
623
+ (cider-jack-in-normalized-lein-plugins)
624
+ (cider-jack-in-normalized-nrepl-middlewares)))
625
+ (' clojure-cli (cider-clojure-cli-jack-in-dependencies
626
+ global-opts
627
+ params
628
+ (cider-add-clojure-dependencies-maybe
629
+ cider-jack-in-dependencies)))
630
+ (' shadow-cljs (cider-shadow-cljs-jack-in-dependencies
631
+ global-opts
632
+ params
633
+ (cider-add-clojure-dependencies-maybe
634
+ cider-jack-in-dependencies)))
635
+ (' gradle (concat
636
+ global-opts
637
+ (unless (seq-empty-p global-opts) " " )
638
+ params))
639
+ (_ (error " Unsupported project type `%S ' " project-type))))
639
640
640
641
641
642
; ;; ClojureScript REPL creation
@@ -1362,10 +1363,13 @@ tool in `cider-preferred-build-tool', otherwise prompt the user to choose.
1362
1363
PROJECT-DIR defaults to the current project."
1363
1364
(let* ((choices (cider--identify-buildtools-present project-dir))
1364
1365
(multiple-project-choices (> (length choices) 1 ))
1365
- (default (car choices)))
1366
+ (default (car choices))
1367
+ ; ; `cider-preferred-build-tool' used to be a string prior to CIDER
1368
+ ; ; 0.18, therefore the need for `cider-maybe-intern'
1369
+ (preferred-build-tool (cider-maybe-intern cider-preferred-build-tool)))
1366
1370
(cond ((and multiple-project-choices
1367
- (member cider- preferred-build-tool choices))
1368
- cider- preferred-build-tool)
1371
+ (member preferred-build-tool choices))
1372
+ preferred-build-tool)
1369
1373
(multiple-project-choices
1370
1374
(completing-read (format " Which command should be used (default %s ): " default )
1371
1375
choices nil t nil nil default ))
@@ -1374,7 +1378,9 @@ PROJECT-DIR defaults to the current project."
1374
1378
; ; TODO: Move this fallback outside the project-type check
1375
1379
; ; if we're outside a project we fallback to whatever tool
1376
1380
; ; is specified in `cider-jack-in-default' (normally clojure-cli)
1377
- (t cider-jack-in-default))))
1381
+ ; ; `cider-jack-in-default' used to be a string prior to CIDER
1382
+ ; ; 0.18, therefore the need for `cider-maybe-intern'
1383
+ (t (cider-maybe-intern cider-jack-in-default)))))
1378
1384
1379
1385
1380
1386
; ; TODO: Implement a check for command presence over tramp
0 commit comments