File tree Expand file tree Collapse file tree 4 files changed +27
-21
lines changed Expand file tree Collapse file tree 4 files changed +27
-21
lines changed Original file line number Diff line number Diff line change 1414 (:command k)
1515 k))))
1616
17- (defn completions []
18- (map #(if-not (:desc %)
19- #js {:completion (str (:command %)) :text (str (:command %))}
20- #js {:completion (str (:command %)) :text (:desc %)})
21- (vals (:commands @manager))))
17+ (defn completions [token]
18+ (if (and token
19+ (= (subs token 0 1 ) " :" ))
20+ (map #(do #js {:completion (str (:command %)) :text (str (:command %))}) (vals (:commands @manager)))
21+ (map #(if-not (:desc %)
22+ #js {:completion (str (:command %)) :text (str (:command %))}
23+ #js {:completion (str (:command %)) :text (:desc %)})
24+ (vals (:commands @manager)))))
2225
2326(defn exec!
2427 " Execute a Light Table command with the given args"
Original file line number Diff line number Diff line change 7474 (aset cur " select" wrapped-replacement))
7575 cur )
7676
77-
78- (defn user-behavior-completions []
79- (map #(if-not (:desc %)
80- (->wrapped-behavior % #js {:text (str (:name %))})
81- (->wrapped-behavior % #js {:text (:desc %)}))
82- (filter #(= (:type %) :user ) (vals @object/behaviors))))
77+ (defn user-behavior-completions [_ _ token]
78+ (if (and token
79+ (= (subs token 0 1 ) " :" ))
80+ (map #(->wrapped-behavior % #js {:text (str (:name %))}) (vals @object/behaviors))
81+ (map #(if-not (:desc %)
82+ (->wrapped-behavior % #js {:text (str (:name %))})
83+ (->wrapped-behavior % #js {:text (:desc %)}))
84+ (filter #(= (:type %) :user ) (vals @object/behaviors)))))
8385
8486(def completions {:root [#js {:completion " :+" }
8587 #js {:completion " :-" }]
103105
104106(behavior ::behavior-hints
105107 :triggers #{:hints+ }
106- :reaction (fn [this hints]
108+ :reaction (fn [this hints token ]
107109 (let [comps (completions (pos->state this))]
108110 (if-not comps
109111 hints
110112 (if (fn? comps)
111113 (let [idx (->index this)]
112- (comps (pos->behavior this (- idx 2 )) (dec idx)))
114+ (comps (pos->behavior this (- idx 2 )) (dec idx) token ))
113115 comps)))))
114116
115117(behavior ::show-info-on-move
Original file line number Diff line number Diff line change 7070(behavior ::keymap-hints
7171 :triggers #{:hints+ }
7272 :exclusive [:lt.plugins.auto-complete/textual-hints ]
73- :reaction (fn [this hints]
73+ :reaction (fn [this hints token ]
7474 (let [comps (completions (pos->state this))]
7575 (if-not comps
7676 hints
7777 (if (fn? comps)
78- (comps )
78+ (comps token )
7979 comps)))))
8080
8181(behavior ::show-info-on-move
Original file line number Diff line number Diff line change 147147
148148(def hinter (-> (scmd/filter-list {:items (fn []
149149 (when-let [cur (pool/last-active )]
150- (distinct-completions
151- (if (:starting-token @hinter)
152- (remove #(= (-> @hinter :starting-token :string ) (.-completion %))
153- (object/raise-reduce cur :hints+ []))
154- (object/raise-reduce cur :hints+ [])))))
150+ (let [token (-> @hinter :starting-token :string )]
151+ (distinct-completions
152+ (if token
153+ (remove #(= token (.-completion %))
154+ (object/raise-reduce cur :hints+ [] token))
155+ (object/raise-reduce cur :hints+ []))))))
155156 :key text|completion})
156157 (object/add-tags [:hinter ])))
157158
338339 (js/CodeMirror.extendMode " clojure" (clj->js {:hint-pattern #"[\w\-\>\:\*\$\?\<\!\+\.\/ foo]" }))
339340 (js/CodeMirror.extendMode " text/x-clojurescript" (clj->js {:hint-pattern #"[\w\-\>\:\*\$\?\<\!\+\.\/ foo]" }))
340341 (js/CodeMirror.extendMode " css" (clj->js {:hint-pattern #"[\w\.\-\# ]" }))
341- ))
342+ ))
You can’t perform that action at this time.
0 commit comments