Skip to content

Commit a2af089

Browse files
committed
Restore enhanced cljs completions for everything except shadow-cljs
1 parent 7c72e95 commit a2af089

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master (unreleased)
44

5+
### Bugs Fixed
6+
7+
* Enable `suitable`'s enhanced completions for anything but `shadow-cljs`.
8+
59
## 0.25.9 (2021-02-13)
610

711
### Bugs Fixed

project.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
:global-vars {*assert* true}}
8888

8989
:test {:source-paths ["test/src"]
90-
:jvm-opts ["-Dcider.internal.test.cljs-suitable-enabled=true"]
9190
:java-source-paths ["test/java"]
9291
:resource-paths ["test/resources"]
9392
:dependencies [[pjstadig/humane-test-output "0.10.0"]

src/cider/nrepl/middleware/complete.clj

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@
1010
[orchard.misc :as misc]
1111
[suitable.compliment.sources.cljs :as suitable-sources]))
1212

13-
;; TODO: Replace this with a presence check for shadow-cljs
14-
;; See https://github.com/rksm/clj-suitable/issues/15 for details
15-
(def suitable-enabled? (System/getProperty "cider.internal.test.cljs-suitable-enabled"))
13+
(def shadow-cljs-present?
14+
(try (require 'shadow.cljs.devtools.api) true
15+
(catch Throwable _ false)))
1616

17-
(when suitable-enabled?
18-
(require 'suitable.complete-for-nrepl))
17+
;; TODO: Suitable is currently broken for shadow-cljs
18+
;; See https://github.com/rksm/clj-suitable/issues/15 for details
19+
(def suitable-enabled? (not shadow-cljs-present?))
1920

2021
(def suitable-complete-for-nrepl
2122
(when suitable-enabled?
23+
(require 'suitable.complete-for-nrepl)
2224
@(resolve 'suitable.complete-for-nrepl/complete-for-nrepl)))
2325

2426
(def clj-sources
25-
"Source keywords for Clojure completions."
27+
"A list of Clojure completion sources for compliment."
2628
[:compliment.sources.special-forms/literals
2729
:compliment.sources.class-members/static-members
2830
:compliment.sources.ns-mappings/ns-mappings
@@ -34,7 +36,7 @@
3436
:compliment.sources.special-forms/special-forms])
3537

3638
(def cljs-sources
37-
"Source keywords for ClojureScript completions."
39+
"A list of ClojureScript completion sources for compliment."
3840
[::suitable-sources/cljs-source])
3941

4042
(defn complete
@@ -45,10 +47,15 @@
4547
:context context
4648
:extra-metadata (set (map keyword extra-metadata))}]
4749
(if-let [cljs-env (cljs/grab-cljs-env msg)]
50+
;; ClojureScript completion
4851
(binding [suitable-sources/*compiler-env* cljs-env]
52+
;; First we get whatever candidates we can from the ClojureScript compiler source
4953
(cond-> (complete/completions prefix (merge completion-opts {:sources cljs-sources}))
54+
;; and we optionally append to them dynamically obtained candidates
55+
;; See https://github.com/rksm/clj-suitable#how-does-it-work for details
5056
(and suitable-enabled? enhanced-cljs-completion?)
5157
(concat (suitable-complete-for-nrepl (assoc msg :symbol prefix)))))
58+
;; Clojure completion
5259
(complete/completions prefix (merge completion-opts {:sources clj-sources})))))
5360

5461
(defn completion-doc

0 commit comments

Comments
 (0)