-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
config.edn
202 lines (202 loc) · 9.17 KB
/
config.edn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
{:customREPLCommandSnippets
[{:name "Add Libs Enclosing"
:key "a"
:snippet (tap>
((requiring-resolve 'clojure.tools.deps.alpha.repl/add-libs)
'$enclosing-form))}
{:name "Tap Define Binding"
:key "d"
:snippet (tap> (def $selection))}
{:name "Tap Last Exception"
:key "e"
:snippet (tap> (Throwable->map *e))}
{:name "Tap Define to Input"
:key "i"
:snippet (let [v (read-string (read-line))]
(tap> (def $selection v)))}
{:name "Tap Namespace Publics"
:key "n"
:snippet (tap>
(-> (find-ns '$ns)
(clojure.datafy/datafy)
:publics))}
{:name "Tap Namespace Cleanup"
:key "z"
:snippet (tap>
(when-let [ns (find-ns '$ns)]
(tap> "Removing $ns... ")
(run! #(try (ns-unalias ns %)
(catch Throwable _))
(keys (ns-aliases ns)))
(run! #(try (ns-unmap ns %)
(catch Throwable _))
(keys (ns-interns ns)))
(->> (ns-refers ns)
(remove (fn [[_ v]]
(.startsWith (str v) "#'clojure.core/")))
(map key)
(run! #(try (ns-unmap ns %)
(catch Throwable _))))))}
{:name "Run Current Test"
:key "c"
:snippet (tap>
(with-out-str
(binding [clojure.test/*test-out* *out*]
(clojure.test/test-vars [#'$top-level-defined-symbol]))))}
{:name "Run Tests"
:key "t"
:snippet (tap>
(do
(tap> "Testing $ns... ")
(require '$ns)
(clojure.test/run-tests '$ns)))}
{:name "Run Tests For Source"
:key "x"
:snippet (tap>
(some #(let [nt (symbol (str "$ns-" %))]
(when (try (require nt) true
(catch Throwable _))
(tap> (str "Testing " nt "... "))
(clojure.test/run-tests nt)))
["test" "expectations"]))}
{:name "Portal Clear"
:key "k"
:snippet (portal.api/clear)}
{:name "Portal Start"
:key "p"
:snippet (do
(ns dev
(:require [clojure.string :as str]))
;; this custom submit code can work with the portal
;; middleware or without it. in order to keep any
;; tap>'d values as the most recent, top-of-window
;; value -- so that the various portal viewer/expand
;; commands can always navigate to it, we need to
;; delay tap>'d value submission until after we
;; display any output, test reports, or errors.
;; we assume direct tap> handling until the portal
;; middleware is known to be in play, then switch to
;; a delayed submission, so that the order can be
;; preserved.
;; in addition, we suppress any results of evaluating
;; portal API calls, so that they don't interfere with
;; the top-of-window value.
;; in the absence of specific tap> calls, if the
;; middleware is in play, we just submit it to portal.
(defonce ^{:doc "The last tap>'d value"}
*v (atom nil))
(defonce ^{:doc "Whether we've delayed tap>'ing a value."}
tap-pending (atom false))
(defonce ^{:doc "Whether to tap> (or delay)."}
tap-direct (atom true))
(defn submit*
"The reloadable implementation of submit."
[v]
(let [m (try (meta v) (catch Exception _))]
(if (:portal.nrepl/eval m)
(if @tap-pending
(let [{:keys [stdio report level]} v]
(when stdio
((requiring-resolve 'portal.api/submit) stdio))
(when report
((requiring-resolve 'portal.api/submit) report))
(when (= level :error)
((requiring-resolve 'portal.api/submit) v))
(reset! tap-pending false)
((requiring-resolve 'portal.api/submit) @dev/*v))
(when-not (or (some-> v :code (str/includes? "portal.api/"))
(some-> v :code (str/starts-with? "(tap>")))
(reset! tap-direct false)
((requiring-resolve 'portal.api/submit) v)))
(do
(when @tap-pending
(reset! tap-pending false)
((requiring-resolve 'portal.api/submit) @dev/*v))
(reset! dev/*v v)
(if (or @tap-direct (string? v))
((requiring-resolve 'portal.api/submit) v)
(reset! tap-pending true))))))
(defonce ^{:doc "Fixed wrapper around submit*."}
submit (fn [v] (submit* v)))
(def ^{:doc "Atom for currently selected value."}
portal
((requiring-resolve 'portal.api/open)
{:launcher :vs-code
:portal.launcher/window-title (System/getProperty "user.dir")}))
(add-tap submit))}
{:name "Tap Input Code"
:key "q"
:snippet (let [v (read-string (clojure.string/replace (read-line)
"*v"
"@dev/*v"))]
(tap> (eval v)))}
{:name "Portal Viewer"
:key "0"
:snippet (portal.api/eval-str
(str
'(let [state portal.ui.state/state]
(-> (portal.ui.commands/select-none state)
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-next-viewer state))
(.then #(portal.ui.commands/select-none state))))))}
{:name "Portal Expand First"
:key "1"
:snippet (portal.api/eval-str
(str
'(let [state portal.ui.state/state]
(-> (portal.ui.commands/select-none state)
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/toggle-expand state))
(.then #(portal.ui.commands/select-none state))))))}
{:name "Portal Expand Second"
:key "2"
:snippet (portal.api/eval-str
(str
'(let [state portal.ui.state/state]
(-> (portal.ui.commands/select-none state)
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/toggle-expand state))
(.then #(portal.ui.commands/select-none state))))))}
{:name "Portal Expand Third"
:key "3"
:snippet (portal.api/eval-str
(str
'(let [state portal.ui.state/state]
(-> (portal.ui.commands/select-none state)
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/toggle-expand state))
(.then #(portal.ui.commands/select-none state))))))}
{:name "Portal Expand Fourth"
:key "4"
:snippet (portal.api/eval-str
(str
'(let [state portal.ui.state/state]
(-> (portal.ui.commands/select-none state)
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/toggle-expand state))
(.then #(portal.ui.commands/select-none state))))))}
{:name "Portal Expand Fifth"
:key "5"
:snippet (portal.api/eval-str
(str
'(let [state portal.ui.state/state]
(-> (portal.ui.commands/select-none state)
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/select-child state))
(.then #(portal.ui.commands/toggle-expand state))
(.then #(portal.ui.commands/select-none state))))))}]}