Skip to content

Commit cbe5b0e

Browse files
committed
Update Aniseed autoload again, fix completion of autoloaded modules
1 parent be55867 commit cbe5b0e

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

fnl/conjure/client/fennel/aniseed.fnl

+16-7
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,21 @@
113113

114114
(defn value->completions [x]
115115
(when (= :table (type x))
116-
(a.map
117-
(fn [[k v]]
118-
{:word k
119-
:kind (type v)
120-
:menu nil
121-
:info nil})
122-
(a.kv-pairs x))))
116+
(->> (if (. x :aniseed/autoload-enabled?)
117+
(do
118+
(. x :trick-aniseed-into-loading-the-module)
119+
(. x :aniseed/autoload-module))
120+
x)
121+
(a.kv-pairs)
122+
(a.filter
123+
(fn [[k v]]
124+
(not (text.starts-with k "aniseed/"))))
125+
(a.map
126+
(fn [[k v]]
127+
{:word k
128+
:kind (type v)
129+
:menu nil
130+
:info nil})))))
123131

124132
(defn completions [opts]
125133
(let [code (when (not (str.blank? opts.prefix))
@@ -131,6 +139,7 @@
131139
(a.concat
132140
(value->completions (a.get m :aniseed/locals))
133141
(value->completions (a.get-in m [:aniseed/local-fns :require]))
142+
(value->completions (a.get-in m [:aniseed/local-fns :autoload]))
134143
mods)
135144
mods))
136145
result-fn

lua/conjure/aniseed/autoload.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ do
4141
do
4242
local v_0_0
4343
local function autoload1(name)
44-
local res = {["conjure.aniseed.autoload/enabled?"] = true, ["conjure.aniseed.autoload/module"] = false}
44+
local res = {["aniseed/autoload-enabled?"] = true, ["aniseed/autoload-module"] = false}
4545
local function ensure()
46-
if res["conjure.aniseed.autoload/module"] then
47-
return res["conjure.aniseed.autoload/module"]
46+
if res["aniseed/autoload-module"] then
47+
return res["aniseed/autoload-module"]
4848
else
4949
local m = require(name)
50-
res["conjure.aniseed.autoload/module"] = m
50+
res["aniseed/autoload-module"] = m
5151
return m
5252
end
5353
end

lua/conjure/client/fennel/aniseed.lua

+16-2
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,21 @@ do
333333
local v = _arg_0_[2]
334334
return {info = nil, kind = type(v), menu = nil, word = k}
335335
end
336-
return a.map(_3_, a["kv-pairs"](x))
336+
local function _5_(_4_0)
337+
local _arg_0_ = _4_0
338+
local k = _arg_0_[1]
339+
local v = _arg_0_[2]
340+
return not text["starts-with"](k, "aniseed/")
341+
end
342+
local function _6_()
343+
if x["aniseed/autoload-enabled?"] then
344+
do local _ = x["trick-aniseed-into-loading-the-module"] end
345+
return x["aniseed/autoload-module"]
346+
else
347+
return x
348+
end
349+
end
350+
return a.map(_3_, a.filter(_5_, a["kv-pairs"](_6_())))
337351
end
338352
end
339353
v_0_0 = value__3ecompletions0
@@ -365,7 +379,7 @@ do
365379
end
366380
ok_3f, m = (opts.context and pcall(_3_))
367381
if ok_3f then
368-
locals = a.concat(value__3ecompletions(a.get(m, "aniseed/locals")), value__3ecompletions(a["get-in"](m, {"aniseed/local-fns", "require"})), mods)
382+
locals = a.concat(value__3ecompletions(a.get(m, "aniseed/locals")), value__3ecompletions(a["get-in"](m, {"aniseed/local-fns", "require"})), value__3ecompletions(a["get-in"](m, {"aniseed/local-fns", "autoload"})), mods)
369383
else
370384
locals = mods
371385
end

0 commit comments

Comments
 (0)