Update aniseed
This commit is contained in:
parent
f83cf568af
commit
d9e70aa52e
@ -1,78 +1,37 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/autoload.fnl"
|
local _2afile_2a = "fnl/aniseed/autoload.fnl"
|
||||||
local _0_
|
|
||||||
do
|
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.autoload"
|
|
||||||
local module_0_
|
|
||||||
do
|
|
||||||
local x_0_ = package.loaded[name_0_]
|
|
||||||
if ("table" == type(x_0_)) then
|
|
||||||
module_0_ = x_0_
|
|
||||||
else
|
|
||||||
module_0_ = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module_0_["aniseed/module"] = name_0_
|
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
|
||||||
local autoload
|
|
||||||
local function _1_(...)
|
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
|
||||||
end
|
|
||||||
autoload = _1_
|
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.autoload"
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.autoload"
|
||||||
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end
|
local _2amodule_2a
|
||||||
local autoload0
|
|
||||||
do
|
do
|
||||||
local v_0_
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
do
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
local v_0_0
|
|
||||||
local function autoload1(name)
|
|
||||||
local res = {["aniseed/autoload-enabled?"] = true, ["aniseed/autoload-module"] = false}
|
|
||||||
local function ensure()
|
|
||||||
if res["aniseed/autoload-module"] then
|
|
||||||
return res["aniseed/autoload-module"]
|
|
||||||
else
|
|
||||||
local m = require(name)
|
|
||||||
do end (res)["aniseed/autoload-module"] = m
|
|
||||||
return m
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function _3_(t, ...)
|
|
||||||
return ensure()(...)
|
|
||||||
end
|
|
||||||
local function _4_(t, k)
|
|
||||||
return ensure()[k]
|
|
||||||
end
|
|
||||||
local function _5_(t, k, v)
|
|
||||||
ensure()[k] = v
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
return setmetatable(res, {__call = _3_, __index = _4_, __newindex = _5_})
|
|
||||||
end
|
|
||||||
v_0_0 = autoload1
|
|
||||||
_0_["autoload"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["autoload"] = v_0_
|
|
||||||
autoload0 = v_0_
|
|
||||||
end
|
end
|
||||||
return nil
|
local _2amodule_locals_2a
|
||||||
|
do
|
||||||
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
|
end
|
||||||
|
local function autoload(name)
|
||||||
|
local res = {["aniseed/autoload-enabled?"] = true, ["aniseed/autoload-module"] = false}
|
||||||
|
local function ensure()
|
||||||
|
if res["aniseed/autoload-module"] then
|
||||||
|
return res["aniseed/autoload-module"]
|
||||||
|
else
|
||||||
|
local m = require(name)
|
||||||
|
do end (res)["aniseed/autoload-module"] = m
|
||||||
|
return m
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function _2_(t, ...)
|
||||||
|
return ensure()(...)
|
||||||
|
end
|
||||||
|
local function _3_(t, k)
|
||||||
|
return ensure()[k]
|
||||||
|
end
|
||||||
|
local function _4_(t, k, v)
|
||||||
|
ensure()[k] = v
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return setmetatable(res, {__call = _2_, __index = _3_, __newindex = _4_})
|
||||||
|
end
|
||||||
|
_2amodule_2a["autoload"] = autoload
|
||||||
|
return _2amodule_2a
|
||||||
|
@ -1,146 +1,83 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/compile.fnl"
|
local _2afile_2a = "fnl/aniseed/compile.fnl"
|
||||||
local _0_
|
|
||||||
do
|
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.compile"
|
|
||||||
local module_0_
|
|
||||||
do
|
|
||||||
local x_0_ = package.loaded[name_0_]
|
|
||||||
if ("table" == type(x_0_)) then
|
|
||||||
module_0_ = x_0_
|
|
||||||
else
|
|
||||||
module_0_ = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module_0_["aniseed/module"] = name_0_
|
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
|
||||||
local autoload
|
|
||||||
local function _1_(...)
|
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
|
||||||
end
|
|
||||||
autoload = _1_
|
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.fennel"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim")}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {autoload = {a = "conjure-macroexpand.aniseed.core", fennel = "conjure-macroexpand.aniseed.fennel", fs = "conjure-macroexpand.aniseed.fs", nvim = "conjure-macroexpand.aniseed.nvim"}}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local a = _local_0_[1]
|
|
||||||
local fennel = _local_0_[2]
|
|
||||||
local fs = _local_0_[3]
|
|
||||||
local nvim = _local_0_[4]
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.compile"
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.compile"
|
||||||
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end
|
local _2amodule_2a
|
||||||
local macros_prefix
|
|
||||||
do
|
do
|
||||||
local v_0_
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
do
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
local v_0_0
|
|
||||||
local function macros_prefix0(code, opts)
|
|
||||||
local macros_module = "conjure-macroexpand.aniseed.macros"
|
|
||||||
local filename
|
|
||||||
do
|
|
||||||
local _3_ = a.get(opts, "filename")
|
|
||||||
if _3_ then
|
|
||||||
filename = string.gsub(_3_, (nvim.fn.getcwd() .. fs["path-sep"]), "")
|
|
||||||
else
|
|
||||||
filename = _3_
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _4_
|
|
||||||
if filename then
|
|
||||||
_4_ = ("\"" .. string.gsub(filename, "\\", "\\\\") .. "\"")
|
|
||||||
else
|
|
||||||
_4_ = "nil"
|
|
||||||
end
|
|
||||||
return ("(local *file* " .. _4_ .. ")" .. "(require-macros \"" .. macros_module .. "\")\n" .. code)
|
|
||||||
end
|
|
||||||
v_0_0 = macros_prefix0
|
|
||||||
_0_["macros-prefix"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["macros-prefix"] = v_0_
|
|
||||||
macros_prefix = v_0_
|
|
||||||
end
|
end
|
||||||
local str
|
local _2amodule_locals_2a
|
||||||
do
|
do
|
||||||
local v_0_
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
do
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
local v_0_0
|
|
||||||
local function str0(code, opts)
|
|
||||||
local fnl = fennel.impl()
|
|
||||||
local function _3_()
|
|
||||||
return fnl.compileString(macros_prefix(code, opts), a.merge({allowedGlobals = false}, opts))
|
|
||||||
end
|
|
||||||
return xpcall(_3_, fnl.traceback)
|
|
||||||
end
|
|
||||||
v_0_0 = str0
|
|
||||||
_0_["str"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["str"] = v_0_
|
|
||||||
str = v_0_
|
|
||||||
end
|
end
|
||||||
local file
|
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
||||||
do
|
local a, fennel, fs, nvim = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.fennel"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim")
|
||||||
local v_0_
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
|
_2amodule_locals_2a["fennel"] = fennel
|
||||||
|
_2amodule_locals_2a["fs"] = fs
|
||||||
|
_2amodule_locals_2a["nvim"] = nvim
|
||||||
|
local function wrap_macros(code, opts)
|
||||||
|
local macros_module = "conjure-macroexpand.aniseed.macros"
|
||||||
|
local filename
|
||||||
do
|
do
|
||||||
local v_0_0
|
local _1_ = a.get(opts, "filename")
|
||||||
local function file0(src, dest)
|
if (nil ~= _1_) then
|
||||||
local code = a.slurp(src)
|
filename = string.gsub(_1_, (nvim.fn.getcwd() .. fs["path-sep"]), "")
|
||||||
local _3_, _4_ = str(code, {filename = src})
|
else
|
||||||
if ((_3_ == false) and (nil ~= _4_)) then
|
filename = _1_
|
||||||
local err = _4_
|
|
||||||
return nvim.err_writeln(err)
|
|
||||||
elseif ((_3_ == true) and (nil ~= _4_)) then
|
|
||||||
local result = _4_
|
|
||||||
fs.mkdirp(fs.basename(dest))
|
|
||||||
return a.spit(dest, result)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
v_0_0 = file0
|
|
||||||
_0_["file"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
end
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
local function _3_()
|
||||||
t_0_["file"] = v_0_
|
if filename then
|
||||||
file = v_0_
|
return ("\"" .. string.gsub(filename, "\\", "\\\\") .. "\"")
|
||||||
end
|
else
|
||||||
local glob
|
return "nil"
|
||||||
do
|
|
||||||
local v_0_
|
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function glob0(src_expr, src_dir, dest_dir)
|
|
||||||
for _, path in ipairs(fs.relglob(src_dir, src_expr)) do
|
|
||||||
if fs["macro-file-path?"](path) then
|
|
||||||
a.spit((dest_dir .. path), a.slurp((src_dir .. path)))
|
|
||||||
else
|
|
||||||
file((src_dir .. path), string.gsub((dest_dir .. path), ".fnl$", ".lua"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
v_0_0 = glob0
|
|
||||||
_0_["glob"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
end
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
return ("(local *file* " .. _3_() .. ")" .. "(require-macros \"" .. macros_module .. "\")\n" .. "(wrap-module-body " .. (code or "") .. ")")
|
||||||
t_0_["glob"] = v_0_
|
|
||||||
glob = v_0_
|
|
||||||
end
|
end
|
||||||
return nil
|
_2amodule_2a["wrap-macros"] = wrap_macros
|
||||||
|
local marker_prefix = "ANISEED_"
|
||||||
|
_2amodule_2a["marker-prefix"] = marker_prefix
|
||||||
|
local delete_marker = (marker_prefix .. "DELETE_ME")
|
||||||
|
do end (_2amodule_2a)["delete-marker"] = delete_marker
|
||||||
|
local delete_marker_pat = ("\n[^\n]-\"" .. delete_marker .. "\".-")
|
||||||
|
do end (_2amodule_locals_2a)["delete-marker-pat"] = delete_marker_pat
|
||||||
|
local function str(code, opts)
|
||||||
|
ANISEED_STATIC_MODULES = (true == a.get(opts, "static?"))
|
||||||
|
local fnl = fennel.impl()
|
||||||
|
local function _4_()
|
||||||
|
return string.gsub(string.gsub(fnl.compileString(wrap_macros(code, opts), a["merge!"]({allowedGlobals = false, compilerEnv = _G}, opts)), (delete_marker_pat .. "\n"), "\n"), (delete_marker_pat .. "$"), "")
|
||||||
|
end
|
||||||
|
return xpcall(_4_, fnl.traceback)
|
||||||
|
end
|
||||||
|
_2amodule_2a["str"] = str
|
||||||
|
local function file(src, dest, opts)
|
||||||
|
local code = a.slurp(src)
|
||||||
|
local _5_, _6_ = str(code, a["merge!"]({filename = src, ["static?"] = true}, opts))
|
||||||
|
if ((_5_ == false) and (nil ~= _6_)) then
|
||||||
|
local err = _6_
|
||||||
|
return nvim.err_writeln(err)
|
||||||
|
elseif ((_5_ == true) and (nil ~= _6_)) then
|
||||||
|
local result = _6_
|
||||||
|
fs.mkdirp(fs.basename(dest))
|
||||||
|
return a.spit(dest, result)
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_2amodule_2a["file"] = file
|
||||||
|
local function glob(src_expr, src_dir, dest_dir, opts)
|
||||||
|
for _, path in ipairs(fs.relglob(src_dir, src_expr)) do
|
||||||
|
if fs["macro-file-path?"](path) then
|
||||||
|
local dest = (dest_dir .. path)
|
||||||
|
fs.mkdirp(fs.basename(dest))
|
||||||
|
a.spit(dest, a.slurp((src_dir .. path)))
|
||||||
|
else
|
||||||
|
file((src_dir .. path), string.gsub((dest_dir .. path), ".fnl$", ".lua"), opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
_2amodule_2a["glob"] = glob
|
||||||
|
return _2amodule_2a
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,382 +0,0 @@
|
|||||||
local type_order = {["function"] = 5, boolean = 2, number = 1, string = 3, table = 4, thread = 7, userdata = 6}
|
|
||||||
local function sort_keys(_0_0, _1_0)
|
|
||||||
local _1_ = _0_0
|
|
||||||
local a = _1_[1]
|
|
||||||
local _2_ = _1_0
|
|
||||||
local b = _2_[1]
|
|
||||||
local ta = type(a)
|
|
||||||
local tb = type(b)
|
|
||||||
if ((ta == tb) and ((ta == "string") or (ta == "number"))) then
|
|
||||||
return (a < b)
|
|
||||||
else
|
|
||||||
local dta = type_order[ta]
|
|
||||||
local dtb = type_order[tb]
|
|
||||||
if (dta and dtb) then
|
|
||||||
return (dta < dtb)
|
|
||||||
elseif dta then
|
|
||||||
return true
|
|
||||||
elseif dtb then
|
|
||||||
return false
|
|
||||||
else
|
|
||||||
return (ta < tb)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function table_kv_pairs(t)
|
|
||||||
local assoc_3f = false
|
|
||||||
local i = 1
|
|
||||||
local kv = {}
|
|
||||||
local insert = table.insert
|
|
||||||
for k, v in pairs(t) do
|
|
||||||
if ((type(k) ~= "number") or (k ~= i)) then
|
|
||||||
assoc_3f = true
|
|
||||||
end
|
|
||||||
i = (i + 1)
|
|
||||||
insert(kv, {k, v})
|
|
||||||
end
|
|
||||||
table.sort(kv, sort_keys)
|
|
||||||
if (#kv == 0) then
|
|
||||||
return kv, "empty"
|
|
||||||
else
|
|
||||||
local function _2_()
|
|
||||||
if assoc_3f then
|
|
||||||
return "table"
|
|
||||||
else
|
|
||||||
return "seq"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return kv, _2_()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function count_table_appearances(t, appearances)
|
|
||||||
if (type(t) == "table") then
|
|
||||||
if not appearances[t] then
|
|
||||||
appearances[t] = 1
|
|
||||||
for k, v in pairs(t) do
|
|
||||||
count_table_appearances(k, appearances)
|
|
||||||
count_table_appearances(v, appearances)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
appearances[t] = ((appearances[t] or 0) + 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return appearances
|
|
||||||
end
|
|
||||||
local function save_table(t, seen)
|
|
||||||
local seen0 = (seen or {len = 0})
|
|
||||||
local id = (seen0.len + 1)
|
|
||||||
if not seen0[t] then
|
|
||||||
seen0[t] = id
|
|
||||||
seen0.len = id
|
|
||||||
end
|
|
||||||
return seen0
|
|
||||||
end
|
|
||||||
local function detect_cycle(t, seen, _3fk)
|
|
||||||
if ("table" == type(t)) then
|
|
||||||
seen[t] = true
|
|
||||||
local _2_0, _3_0 = next(t, _3fk)
|
|
||||||
if ((nil ~= _2_0) and (nil ~= _3_0)) then
|
|
||||||
local k = _2_0
|
|
||||||
local v = _3_0
|
|
||||||
return (seen[k] or detect_cycle(k, seen) or seen[v] or detect_cycle(v, seen) or detect_cycle(t, seen, k))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function visible_cycle_3f(t, options)
|
|
||||||
return (options["detect-cycles?"] and detect_cycle(t, {}) and save_table(t, options.seen) and (1 < (options.appearances[t] or 0)))
|
|
||||||
end
|
|
||||||
local function table_indent(t, indent, id)
|
|
||||||
local opener_length = nil
|
|
||||||
if id then
|
|
||||||
opener_length = (#tostring(id) + 2)
|
|
||||||
else
|
|
||||||
opener_length = 1
|
|
||||||
end
|
|
||||||
return (indent + opener_length)
|
|
||||||
end
|
|
||||||
local pp = nil
|
|
||||||
local function concat_table_lines(elements, options, multiline_3f, indent, table_type, prefix)
|
|
||||||
local indent_str = ("\n" .. string.rep(" ", indent))
|
|
||||||
local open = nil
|
|
||||||
local function _2_()
|
|
||||||
if ("seq" == table_type) then
|
|
||||||
return "["
|
|
||||||
else
|
|
||||||
return "{"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
open = ((prefix or "") .. _2_())
|
|
||||||
local close = nil
|
|
||||||
if ("seq" == table_type) then
|
|
||||||
close = "]"
|
|
||||||
else
|
|
||||||
close = "}"
|
|
||||||
end
|
|
||||||
local oneline = (open .. table.concat(elements, " ") .. close)
|
|
||||||
if (not options["one-line?"] and (multiline_3f or ((indent + #oneline) > options["line-length"]))) then
|
|
||||||
return (open .. table.concat(elements, indent_str) .. close)
|
|
||||||
else
|
|
||||||
return oneline
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function pp_associative(t, kv, options, indent, key_3f)
|
|
||||||
local multiline_3f = false
|
|
||||||
local id = options.seen[t]
|
|
||||||
if (options.level >= options.depth) then
|
|
||||||
return "{...}"
|
|
||||||
elseif (id and options["detect-cycles?"]) then
|
|
||||||
return ("@" .. id .. "{...}")
|
|
||||||
else
|
|
||||||
local visible_cycle_3f0 = visible_cycle_3f(t, options)
|
|
||||||
local id0 = (visible_cycle_3f0 and options.seen[t])
|
|
||||||
local indent0 = table_indent(t, indent, id0)
|
|
||||||
local slength = nil
|
|
||||||
local function _3_()
|
|
||||||
local _2_0 = rawget(_G, "utf8")
|
|
||||||
if _2_0 then
|
|
||||||
return _2_0.len
|
|
||||||
else
|
|
||||||
return _2_0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function _4_(_241)
|
|
||||||
return #_241
|
|
||||||
end
|
|
||||||
slength = ((options["utf8?"] and _3_()) or _4_)
|
|
||||||
local prefix = nil
|
|
||||||
if visible_cycle_3f0 then
|
|
||||||
prefix = ("@" .. id0)
|
|
||||||
else
|
|
||||||
prefix = ""
|
|
||||||
end
|
|
||||||
local items = nil
|
|
||||||
do
|
|
||||||
local tbl_0_ = {}
|
|
||||||
for _, _6_0 in pairs(kv) do
|
|
||||||
local _7_ = _6_0
|
|
||||||
local k = _7_[1]
|
|
||||||
local v = _7_[2]
|
|
||||||
local _8_
|
|
||||||
do
|
|
||||||
local k0 = pp(k, options, (indent0 + 1), true)
|
|
||||||
local v0 = pp(v, options, (indent0 + slength(k0) + 1))
|
|
||||||
multiline_3f = (multiline_3f or k0:find("\n") or v0:find("\n"))
|
|
||||||
_8_ = (k0 .. " " .. v0)
|
|
||||||
end
|
|
||||||
tbl_0_[(#tbl_0_ + 1)] = _8_
|
|
||||||
end
|
|
||||||
items = tbl_0_
|
|
||||||
end
|
|
||||||
return concat_table_lines(items, options, multiline_3f, indent0, "table", prefix)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function pp_sequence(t, kv, options, indent)
|
|
||||||
local multiline_3f = false
|
|
||||||
local id = options.seen[t]
|
|
||||||
if (options.level >= options.depth) then
|
|
||||||
return "[...]"
|
|
||||||
elseif (id and options["detect-cycles?"]) then
|
|
||||||
return ("@" .. id .. "[...]")
|
|
||||||
else
|
|
||||||
local visible_cycle_3f0 = visible_cycle_3f(t, options)
|
|
||||||
local id0 = (visible_cycle_3f0 and options.seen[t])
|
|
||||||
local indent0 = table_indent(t, indent, id0)
|
|
||||||
local prefix = nil
|
|
||||||
if visible_cycle_3f0 then
|
|
||||||
prefix = ("@" .. id0)
|
|
||||||
else
|
|
||||||
prefix = ""
|
|
||||||
end
|
|
||||||
local items = nil
|
|
||||||
do
|
|
||||||
local tbl_0_ = {}
|
|
||||||
for _, _3_0 in pairs(kv) do
|
|
||||||
local _4_ = _3_0
|
|
||||||
local _0 = _4_[1]
|
|
||||||
local v = _4_[2]
|
|
||||||
local _5_
|
|
||||||
do
|
|
||||||
local v0 = pp(v, options, indent0)
|
|
||||||
multiline_3f = (multiline_3f or v0:find("\n"))
|
|
||||||
_5_ = v0
|
|
||||||
end
|
|
||||||
tbl_0_[(#tbl_0_ + 1)] = _5_
|
|
||||||
end
|
|
||||||
items = tbl_0_
|
|
||||||
end
|
|
||||||
return concat_table_lines(items, options, multiline_3f, indent0, "seq", prefix)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function concat_lines(lines, options, indent, force_multi_line_3f)
|
|
||||||
if (#lines == 0) then
|
|
||||||
if options["empty-as-sequence?"] then
|
|
||||||
return "[]"
|
|
||||||
else
|
|
||||||
return "{}"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local oneline = nil
|
|
||||||
local _2_
|
|
||||||
do
|
|
||||||
local tbl_0_ = {}
|
|
||||||
for _, line in ipairs(lines) do
|
|
||||||
tbl_0_[(#tbl_0_ + 1)] = line:gsub("^%s+", "")
|
|
||||||
end
|
|
||||||
_2_ = tbl_0_
|
|
||||||
end
|
|
||||||
oneline = table.concat(_2_, " ")
|
|
||||||
if (not options["one-line?"] and (force_multi_line_3f or oneline:find("\n") or ((indent + #oneline) > options["line-length"]))) then
|
|
||||||
return table.concat(lines, ("\n" .. string.rep(" ", indent)))
|
|
||||||
else
|
|
||||||
return oneline
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function pp_metamethod(t, metamethod, options, indent)
|
|
||||||
if (options.level >= options.depth) then
|
|
||||||
if options["empty-as-sequence?"] then
|
|
||||||
return "[...]"
|
|
||||||
else
|
|
||||||
return "{...}"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local _ = nil
|
|
||||||
local function _2_(_241)
|
|
||||||
return visible_cycle_3f(_241, options)
|
|
||||||
end
|
|
||||||
options["visible-cycle?"] = _2_
|
|
||||||
_ = nil
|
|
||||||
local lines, force_multi_line_3f = metamethod(t, pp, options, indent)
|
|
||||||
options["visible-cycle?"] = nil
|
|
||||||
local _3_0 = type(lines)
|
|
||||||
if (_3_0 == "string") then
|
|
||||||
return lines
|
|
||||||
elseif (_3_0 == "table") then
|
|
||||||
return concat_lines(lines, options, indent, force_multi_line_3f)
|
|
||||||
else
|
|
||||||
local _0 = _3_0
|
|
||||||
return error("__fennelview metamethod must return a table of lines")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function pp_table(x, options, indent)
|
|
||||||
options.level = (options.level + 1)
|
|
||||||
local x0 = nil
|
|
||||||
do
|
|
||||||
local _2_0 = nil
|
|
||||||
if options["metamethod?"] then
|
|
||||||
local _3_0 = x
|
|
||||||
if _3_0 then
|
|
||||||
local _4_0 = getmetatable(_3_0)
|
|
||||||
if _4_0 then
|
|
||||||
_2_0 = _4_0.__fennelview
|
|
||||||
else
|
|
||||||
_2_0 = _4_0
|
|
||||||
end
|
|
||||||
else
|
|
||||||
_2_0 = _3_0
|
|
||||||
end
|
|
||||||
else
|
|
||||||
_2_0 = nil
|
|
||||||
end
|
|
||||||
if (nil ~= _2_0) then
|
|
||||||
local metamethod = _2_0
|
|
||||||
x0 = pp_metamethod(x, metamethod, options, indent)
|
|
||||||
else
|
|
||||||
local _ = _2_0
|
|
||||||
local _4_0, _5_0 = table_kv_pairs(x)
|
|
||||||
if (true and (_5_0 == "empty")) then
|
|
||||||
local _0 = _4_0
|
|
||||||
if options["empty-as-sequence?"] then
|
|
||||||
x0 = "[]"
|
|
||||||
else
|
|
||||||
x0 = "{}"
|
|
||||||
end
|
|
||||||
elseif ((nil ~= _4_0) and (_5_0 == "table")) then
|
|
||||||
local kv = _4_0
|
|
||||||
x0 = pp_associative(x, kv, options, indent)
|
|
||||||
elseif ((nil ~= _4_0) and (_5_0 == "seq")) then
|
|
||||||
local kv = _4_0
|
|
||||||
x0 = pp_sequence(x, kv, options, indent)
|
|
||||||
else
|
|
||||||
x0 = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
options.level = (options.level - 1)
|
|
||||||
return x0
|
|
||||||
end
|
|
||||||
local function number__3estring(n)
|
|
||||||
local _2_0 = string.gsub(tostring(n), ",", ".")
|
|
||||||
return _2_0
|
|
||||||
end
|
|
||||||
local function colon_string_3f(s)
|
|
||||||
return s:find("^[-%w?^_!$%&*+./@|<=>]+$")
|
|
||||||
end
|
|
||||||
local function pp_string(str, options, indent)
|
|
||||||
local escs = nil
|
|
||||||
local _2_
|
|
||||||
if (options["escape-newlines?"] and (#str < (options["line-length"] - indent))) then
|
|
||||||
_2_ = "\\n"
|
|
||||||
else
|
|
||||||
_2_ = "\n"
|
|
||||||
end
|
|
||||||
local function _4_(_241, _242)
|
|
||||||
return ("\\%03d"):format(_242:byte())
|
|
||||||
end
|
|
||||||
escs = setmetatable({["\""] = "\\\"", ["\11"] = "\\v", ["\12"] = "\\f", ["\13"] = "\\r", ["\7"] = "\\a", ["\8"] = "\\b", ["\9"] = "\\t", ["\\"] = "\\\\", ["\n"] = _2_}, {__index = _4_})
|
|
||||||
return ("\"" .. str:gsub("[%c\\\"]", escs) .. "\"")
|
|
||||||
end
|
|
||||||
local function make_options(t, options)
|
|
||||||
local defaults = {["detect-cycles?"] = true, ["empty-as-sequence?"] = false, ["escape-newlines?"] = false, ["line-length"] = 80, ["metamethod?"] = true, ["one-line?"] = false, ["prefer-colon?"] = false, ["utf8?"] = true, depth = 128}
|
|
||||||
local overrides = {appearances = count_table_appearances(t, {}), level = 0, seen = {len = 0}}
|
|
||||||
for k, v in pairs((options or {})) do
|
|
||||||
defaults[k] = v
|
|
||||||
end
|
|
||||||
for k, v in pairs(overrides) do
|
|
||||||
defaults[k] = v
|
|
||||||
end
|
|
||||||
return defaults
|
|
||||||
end
|
|
||||||
local function _2_(x, options, indent, colon_3f)
|
|
||||||
local indent0 = (indent or 0)
|
|
||||||
local options0 = (options or make_options(x))
|
|
||||||
local tv = type(x)
|
|
||||||
local function _4_()
|
|
||||||
local _3_0 = getmetatable(x)
|
|
||||||
if _3_0 then
|
|
||||||
return _3_0.__fennelview
|
|
||||||
else
|
|
||||||
return _3_0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if ((tv == "table") or ((tv == "userdata") and _4_())) then
|
|
||||||
return pp_table(x, options0, indent0)
|
|
||||||
elseif (tv == "number") then
|
|
||||||
return number__3estring(x)
|
|
||||||
else
|
|
||||||
local function _5_()
|
|
||||||
if (colon_3f ~= nil) then
|
|
||||||
return colon_3f
|
|
||||||
elseif ("function" == type(options0["prefer-colon?"])) then
|
|
||||||
return options0["prefer-colon?"](x)
|
|
||||||
else
|
|
||||||
return options0["prefer-colon?"]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if ((tv == "string") and colon_string_3f(x) and _5_()) then
|
|
||||||
return (":" .. x)
|
|
||||||
elseif (tv == "string") then
|
|
||||||
return pp_string(x, options0, indent0)
|
|
||||||
elseif ((tv == "boolean") or (tv == "nil")) then
|
|
||||||
return tostring(x)
|
|
||||||
else
|
|
||||||
return ("#<" .. tostring(x) .. ">")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
pp = _2_
|
|
||||||
local function view(x, options)
|
|
||||||
return pp(x, make_options(x, options), 0)
|
|
||||||
end
|
|
||||||
return view
|
|
1058
lua/conjure-macroexpand/aniseed/deps/fun.lua
Normal file
1058
lua/conjure-macroexpand/aniseed/deps/fun.lua
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,108 +1,63 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/env.fnl"
|
local _2afile_2a = "fnl/aniseed/env.fnl"
|
||||||
local _0_
|
|
||||||
do
|
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.env"
|
|
||||||
local module_0_
|
|
||||||
do
|
|
||||||
local x_0_ = package.loaded[name_0_]
|
|
||||||
if ("table" == type(x_0_)) then
|
|
||||||
module_0_ = x_0_
|
|
||||||
else
|
|
||||||
module_0_ = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module_0_["aniseed/module"] = name_0_
|
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
|
||||||
local autoload
|
|
||||||
local function _1_(...)
|
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
|
||||||
end
|
|
||||||
autoload = _1_
|
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {autoload("conjure-macroexpand.aniseed.compile"), autoload("conjure-macroexpand.aniseed.fennel"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim")}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {autoload = {compile = "conjure-macroexpand.aniseed.compile", fennel = "conjure-macroexpand.aniseed.fennel", fs = "conjure-macroexpand.aniseed.fs", nvim = "conjure-macroexpand.aniseed.nvim"}}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local compile = _local_0_[1]
|
|
||||||
local fennel = _local_0_[2]
|
|
||||||
local fs = _local_0_[3]
|
|
||||||
local nvim = _local_0_[4]
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.env"
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.env"
|
||||||
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end
|
local _2amodule_2a
|
||||||
local config_dir
|
|
||||||
do
|
do
|
||||||
local v_0_ = nvim.fn.stdpath("config")
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
t_0_["config-dir"] = v_0_
|
|
||||||
config_dir = v_0_
|
|
||||||
end
|
end
|
||||||
local quiet_require
|
local _2amodule_locals_2a
|
||||||
do
|
do
|
||||||
local v_0_
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
local function quiet_require0(m)
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
local ok_3f, err = nil, nil
|
end
|
||||||
local function _3_()
|
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
||||||
return require(m)
|
local compile, fennel, fs, nvim = autoload("conjure-macroexpand.aniseed.compile"), autoload("conjure-macroexpand.aniseed.fennel"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim")
|
||||||
end
|
do end (_2amodule_locals_2a)["compile"] = compile
|
||||||
ok_3f, err = pcall(_3_)
|
_2amodule_locals_2a["fennel"] = fennel
|
||||||
if (not ok_3f and not err:find(("module '" .. m .. "' not found"))) then
|
_2amodule_locals_2a["fs"] = fs
|
||||||
return nvim.ex.echoerr(err)
|
_2amodule_locals_2a["nvim"] = nvim
|
||||||
|
local config_dir = nvim.fn.stdpath("config")
|
||||||
|
do end (_2amodule_locals_2a)["config-dir"] = config_dir
|
||||||
|
local function quiet_require(m)
|
||||||
|
local ok_3f, err = nil, nil
|
||||||
|
local function _1_()
|
||||||
|
return require(m)
|
||||||
|
end
|
||||||
|
ok_3f, err = pcall(_1_)
|
||||||
|
if (not ok_3f and not err:find(("module '" .. m .. "' not found"))) then
|
||||||
|
return nvim.ex.echoerr(err)
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_2amodule_locals_2a["quiet-require"] = quiet_require
|
||||||
|
local function init(opts)
|
||||||
|
local opts0
|
||||||
|
if ("table" == type(opts)) then
|
||||||
|
opts0 = opts
|
||||||
|
else
|
||||||
|
opts0 = {}
|
||||||
|
end
|
||||||
|
local glob_expr = "**/*.fnl"
|
||||||
|
local fnl_dir = nvim.fn.expand((opts0.input or (config_dir .. fs["path-sep"] .. "fnl")))
|
||||||
|
local lua_dir = nvim.fn.expand((opts0.output or (config_dir .. fs["path-sep"] .. "lua")))
|
||||||
|
if opts0.output then
|
||||||
|
package.path = (package.path .. ";" .. lua_dir .. fs["path-sep"] .. "?.lua")
|
||||||
|
else
|
||||||
|
end
|
||||||
|
local function _5_(path)
|
||||||
|
if fs["macro-file-path?"](path) then
|
||||||
|
return path
|
||||||
|
else
|
||||||
|
return string.gsub(path, ".fnl$", ".lua")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
v_0_ = quiet_require0
|
if (((false ~= opts0.compile) or os.getenv("ANISEED_ENV_COMPILE")) and fs["glob-dir-newer?"](fnl_dir, lua_dir, glob_expr, _5_)) then
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
fennel["add-path"]((fnl_dir .. fs["path-sep"] .. "?.fnl"))
|
||||||
t_0_["quiet-require"] = v_0_
|
compile.glob(glob_expr, fnl_dir, lua_dir, opts0)
|
||||||
quiet_require = v_0_
|
else
|
||||||
end
|
|
||||||
local init
|
|
||||||
do
|
|
||||||
local v_0_
|
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function init0(opts)
|
|
||||||
local opts0
|
|
||||||
if ("table" == type(opts)) then
|
|
||||||
opts0 = opts
|
|
||||||
else
|
|
||||||
opts0 = {}
|
|
||||||
end
|
|
||||||
local glob_expr = "**/*.fnl"
|
|
||||||
local fnl_dir = (opts0.input or (config_dir .. fs["path-sep"] .. "fnl"))
|
|
||||||
local lua_dir = (opts0.output or (config_dir .. fs["path-sep"] .. "lua"))
|
|
||||||
package.path = (package.path .. ";" .. lua_dir .. fs["path-sep"] .. "?.lua")
|
|
||||||
local function _4_(path)
|
|
||||||
if fs["macro-file-path?"](path) then
|
|
||||||
return path
|
|
||||||
else
|
|
||||||
return string.gsub(path, ".fnl$", ".lua")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (((false ~= opts0.compile) or os.getenv("ANISEED_ENV_COMPILE")) and fs["glob-dir-newer?"](fnl_dir, lua_dir, glob_expr, _4_)) then
|
|
||||||
fennel["add-path"]((fnl_dir .. fs["path-sep"] .. "?.fnl"))
|
|
||||||
compile.glob(glob_expr, fnl_dir, lua_dir, opts0)
|
|
||||||
end
|
|
||||||
return quiet_require((opts0.module or "init"))
|
|
||||||
end
|
|
||||||
v_0_0 = init0
|
|
||||||
_0_["init"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
end
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
return quiet_require((opts0.module or "init"))
|
||||||
t_0_["init"] = v_0_
|
|
||||||
init = v_0_
|
|
||||||
end
|
end
|
||||||
return nil
|
_2amodule_2a["init"] = init
|
||||||
|
return _2amodule_2a
|
||||||
|
@ -1,67 +1,72 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/eval.fnl"
|
local _2afile_2a = "fnl/aniseed/eval.fnl"
|
||||||
local _0_
|
|
||||||
do
|
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.eval"
|
|
||||||
local module_0_
|
|
||||||
do
|
|
||||||
local x_0_ = package.loaded[name_0_]
|
|
||||||
if ("table" == type(x_0_)) then
|
|
||||||
module_0_ = x_0_
|
|
||||||
else
|
|
||||||
module_0_ = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module_0_["aniseed/module"] = name_0_
|
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
|
||||||
local autoload
|
|
||||||
local function _1_(...)
|
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
|
||||||
end
|
|
||||||
autoload = _1_
|
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.compile"), autoload("conjure-macroexpand.aniseed.fennel"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim")}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {autoload = {a = "conjure-macroexpand.aniseed.core", compile = "conjure-macroexpand.aniseed.compile", fennel = "conjure-macroexpand.aniseed.fennel", fs = "conjure-macroexpand.aniseed.fs", nvim = "conjure-macroexpand.aniseed.nvim"}}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local a = _local_0_[1]
|
|
||||||
local compile = _local_0_[2]
|
|
||||||
local fennel = _local_0_[3]
|
|
||||||
local fs = _local_0_[4]
|
|
||||||
local nvim = _local_0_[5]
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.eval"
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.eval"
|
||||||
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end
|
local _2amodule_2a
|
||||||
local str
|
|
||||||
do
|
do
|
||||||
local v_0_
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
do
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
local v_0_0
|
|
||||||
local function str0(code, opts)
|
|
||||||
local fnl = fennel.impl()
|
|
||||||
local function _3_()
|
|
||||||
return fnl.eval(compile["macros-prefix"](code, opts), a.merge({["compiler-env"] = _G}, opts))
|
|
||||||
end
|
|
||||||
return xpcall(_3_, fnl.traceback)
|
|
||||||
end
|
|
||||||
v_0_0 = str0
|
|
||||||
_0_["str"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["str"] = v_0_
|
|
||||||
str = v_0_
|
|
||||||
end
|
end
|
||||||
return nil
|
local _2amodule_locals_2a
|
||||||
|
do
|
||||||
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
|
end
|
||||||
|
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
||||||
|
local a, compile, fennel, fs, nvim = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.compile"), autoload("conjure-macroexpand.aniseed.fennel"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim")
|
||||||
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
|
_2amodule_locals_2a["compile"] = compile
|
||||||
|
_2amodule_locals_2a["fennel"] = fennel
|
||||||
|
_2amodule_locals_2a["fs"] = fs
|
||||||
|
_2amodule_locals_2a["nvim"] = nvim
|
||||||
|
local function str(code, opts)
|
||||||
|
local fnl = fennel.impl()
|
||||||
|
local function _1_()
|
||||||
|
return fnl.eval(compile["wrap-macros"](code, opts), a.merge({compilerEnv = _G}, opts))
|
||||||
|
end
|
||||||
|
return xpcall(_1_, fnl.traceback)
|
||||||
|
end
|
||||||
|
_2amodule_2a["str"] = str
|
||||||
|
local function clean_values(vals)
|
||||||
|
local function _2_(val)
|
||||||
|
if a["table?"](val) then
|
||||||
|
return (compile["delete-marker"] ~= a.first(val))
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return a.filter(_2_, vals)
|
||||||
|
end
|
||||||
|
_2amodule_locals_2a["clean-values"] = clean_values
|
||||||
|
local function clean_error(err)
|
||||||
|
return string.gsub(string.gsub(err, "^%b[string .-%b]:%d+: ", ""), "^Compile error in .-:%d+\n%s+", "")
|
||||||
|
end
|
||||||
|
_2amodule_2a["clean-error"] = clean_error
|
||||||
|
local function repl(opts)
|
||||||
|
local eval_values = nil
|
||||||
|
local fnl = fennel.impl()
|
||||||
|
local opts0 = (opts or {})
|
||||||
|
local co
|
||||||
|
local function _4_()
|
||||||
|
local function _5_(_241)
|
||||||
|
eval_values = clean_values(_241)
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
local function _6_(_241, _242)
|
||||||
|
return (opts0["error-handler"] or nvim.err_writeln)(clean_error(_242))
|
||||||
|
end
|
||||||
|
return fnl.repl(a.merge({compilerEnv = _G, pp = a.identity, readChunk = coroutine.yield, onValues = _5_, onError = _6_}, opts0))
|
||||||
|
end
|
||||||
|
co = coroutine.create(_4_)
|
||||||
|
coroutine.resume(co)
|
||||||
|
coroutine.resume(co, compile["wrap-macros"](nil, opts0))
|
||||||
|
eval_values = nil
|
||||||
|
local function _7_(code)
|
||||||
|
ANISEED_STATIC_MODULES = false
|
||||||
|
coroutine.resume(co, code)
|
||||||
|
local prev_eval_values = eval_values
|
||||||
|
eval_values = nil
|
||||||
|
return prev_eval_values
|
||||||
|
end
|
||||||
|
return _7_
|
||||||
|
end
|
||||||
|
_2amodule_2a["repl"] = repl
|
||||||
|
return _2amodule_2a
|
||||||
|
@ -1,112 +1,55 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/fennel.fnl"
|
local _2afile_2a = "fnl/aniseed/fennel.fnl"
|
||||||
local _0_
|
|
||||||
do
|
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.fennel"
|
|
||||||
local module_0_
|
|
||||||
do
|
|
||||||
local x_0_ = package.loaded[name_0_]
|
|
||||||
if ("table" == type(x_0_)) then
|
|
||||||
module_0_ = x_0_
|
|
||||||
else
|
|
||||||
module_0_ = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module_0_["aniseed/module"] = name_0_
|
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
|
||||||
local autoload
|
|
||||||
local function _1_(...)
|
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
|
||||||
end
|
|
||||||
autoload = _1_
|
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim")}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {autoload = {fs = "conjure-macroexpand.aniseed.fs", nvim = "conjure-macroexpand.aniseed.nvim"}}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local fs = _local_0_[1]
|
|
||||||
local nvim = _local_0_[2]
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.fennel"
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.fennel"
|
||||||
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end
|
local _2amodule_2a
|
||||||
local sync_rtp
|
|
||||||
do
|
do
|
||||||
local v_0_
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
do
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
local v_0_0
|
end
|
||||||
local function sync_rtp0(compiler)
|
local _2amodule_locals_2a
|
||||||
local sep = fs["path-sep"]
|
do
|
||||||
local fnl_suffix = (sep .. "fnl" .. sep .. "?.fnl")
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
local rtp = nvim.o.runtimepath
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
local fnl_path = (rtp:gsub(",", (fnl_suffix .. ";")) .. fnl_suffix)
|
end
|
||||||
local lua_path = fnl_path:gsub((sep .. "fnl" .. sep), (sep .. "lua" .. sep))
|
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
||||||
do end (compiler)["path"] = (fnl_path .. ";" .. lua_path)
|
local a, fs, nvim, str = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim"), autoload("conjure-macroexpand.aniseed.string")
|
||||||
return nil
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
end
|
_2amodule_locals_2a["fs"] = fs
|
||||||
v_0_0 = sync_rtp0
|
_2amodule_locals_2a["nvim"] = nvim
|
||||||
_0_["sync-rtp"] = v_0_0
|
_2amodule_locals_2a["str"] = str
|
||||||
v_0_ = v_0_0
|
local function sync_rtp(compiler)
|
||||||
|
local fnl_suffix = (fs["path-sep"] .. "fnl" .. fs["path-sep"] .. "?.fnl")
|
||||||
|
local lua_suffix = (fs["path-sep"] .. "lua" .. fs["path-sep"] .. "?.fnl")
|
||||||
|
local rtps = nvim.list_runtime_paths()
|
||||||
|
local fnl_paths
|
||||||
|
local function _1_(_241)
|
||||||
|
return (_241 .. fnl_suffix)
|
||||||
end
|
end
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
fnl_paths = a.map(_1_, rtps)
|
||||||
t_0_["sync-rtp"] = v_0_
|
local lua_paths
|
||||||
sync_rtp = v_0_
|
local function _2_(_241)
|
||||||
end
|
return (_241 .. lua_suffix)
|
||||||
local state
|
|
||||||
do
|
|
||||||
local v_0_ = {["compiler-loaded?"] = false}
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["state"] = v_0_
|
|
||||||
state = v_0_
|
|
||||||
end
|
|
||||||
local impl
|
|
||||||
do
|
|
||||||
local v_0_
|
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function impl0()
|
|
||||||
local compiler = require("conjure-macroexpand.aniseed.deps.fennel")
|
|
||||||
if not state["compiler-loaded?"] then
|
|
||||||
state["compiler-loaded?"] = true
|
|
||||||
sync_rtp(compiler)
|
|
||||||
end
|
|
||||||
return compiler
|
|
||||||
end
|
|
||||||
v_0_0 = impl0
|
|
||||||
_0_["impl"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
end
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
lua_paths = a.map(_2_, rtps)
|
||||||
t_0_["impl"] = v_0_
|
do end (compiler)["macro-path"] = str.join(";", a.concat(fnl_paths, lua_paths))
|
||||||
impl = v_0_
|
return nil
|
||||||
end
|
end
|
||||||
local add_path
|
_2amodule_2a["sync-rtp"] = sync_rtp
|
||||||
do
|
local state = {["compiler-loaded?"] = false}
|
||||||
local v_0_
|
_2amodule_locals_2a["state"] = state
|
||||||
do
|
local function impl()
|
||||||
local v_0_0
|
local compiler = require("conjure-macroexpand.aniseed.deps.fennel")
|
||||||
local function add_path0(path)
|
if not state["compiler-loaded?"] then
|
||||||
local fnl = impl()
|
state["compiler-loaded?"] = true
|
||||||
do end (fnl)["path"] = (fnl.path .. ";" .. path)
|
sync_rtp(compiler)
|
||||||
return nil
|
else
|
||||||
end
|
|
||||||
v_0_0 = add_path0
|
|
||||||
_0_["add-path"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
end
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
return compiler
|
||||||
t_0_["add-path"] = v_0_
|
|
||||||
add_path = v_0_
|
|
||||||
end
|
end
|
||||||
return nil
|
_2amodule_2a["impl"] = impl
|
||||||
|
local function add_path(path)
|
||||||
|
local fnl = impl()
|
||||||
|
do end (fnl)["macro-path"] = (fnl["macro-path"] .. ";" .. path)
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
_2amodule_2a["add-path"] = add_path
|
||||||
|
return _2amodule_2a
|
||||||
|
@ -1,154 +1,58 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/fs.fnl"
|
local _2afile_2a = "fnl/aniseed/fs.fnl"
|
||||||
local _0_
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.fs"
|
||||||
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.fs"
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
local module_0_
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
do
|
end
|
||||||
local x_0_ = package.loaded[name_0_]
|
local _2amodule_locals_2a
|
||||||
if ("table" == type(x_0_)) then
|
do
|
||||||
module_0_ = x_0_
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
|
end
|
||||||
|
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
||||||
|
local a, nvim = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.nvim")
|
||||||
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
|
_2amodule_locals_2a["nvim"] = nvim
|
||||||
|
local function basename(path)
|
||||||
|
return nvim.fn.fnamemodify(path, ":h")
|
||||||
|
end
|
||||||
|
_2amodule_2a["basename"] = basename
|
||||||
|
local function mkdirp(dir)
|
||||||
|
return nvim.fn.mkdir(dir, "p")
|
||||||
|
end
|
||||||
|
_2amodule_2a["mkdirp"] = mkdirp
|
||||||
|
local function relglob(dir, expr)
|
||||||
|
local dir_len = a.inc(string.len(dir))
|
||||||
|
local function _1_(_241)
|
||||||
|
return string.sub(_241, dir_len)
|
||||||
|
end
|
||||||
|
return a.map(_1_, nvim.fn.globpath(dir, expr, true, true))
|
||||||
|
end
|
||||||
|
_2amodule_2a["relglob"] = relglob
|
||||||
|
local function glob_dir_newer_3f(a_dir, b_dir, expr, b_dir_path_fn)
|
||||||
|
local newer_3f = false
|
||||||
|
for _, path in ipairs(relglob(a_dir, expr)) do
|
||||||
|
if (nvim.fn.getftime((a_dir .. path)) > nvim.fn.getftime((b_dir .. b_dir_path_fn(path)))) then
|
||||||
|
newer_3f = true
|
||||||
else
|
else
|
||||||
module_0_ = {}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
module_0_["aniseed/module"] = name_0_
|
return newer_3f
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
end
|
||||||
local autoload
|
_2amodule_2a["glob-dir-newer?"] = glob_dir_newer_3f
|
||||||
local function _1_(...)
|
local function macro_file_path_3f(path)
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
return a["string?"](string.match(path, "macros?.fnl$"))
|
||||||
end
|
end
|
||||||
autoload = _1_
|
_2amodule_2a["macro-file-path?"] = macro_file_path_3f
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.nvim")}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {autoload = {a = "conjure-macroexpand.aniseed.core", nvim = "conjure-macroexpand.aniseed.nvim"}}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local a = _local_0_[1]
|
|
||||||
local nvim = _local_0_[2]
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.fs"
|
|
||||||
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end
|
|
||||||
local path_sep
|
local path_sep
|
||||||
do
|
do
|
||||||
local v_0_
|
local os = string.lower(jit.os)
|
||||||
do
|
if (("linux" == os) or ("osx" == os) or ("bsd" == os)) then
|
||||||
local v_0_0
|
path_sep = "/"
|
||||||
do
|
else
|
||||||
local os = string.lower(jit.os)
|
path_sep = "\\"
|
||||||
if (("linux" == os) or ("osx" == os) or ("bsd" == os)) then
|
|
||||||
v_0_0 = "/"
|
|
||||||
else
|
|
||||||
v_0_0 = "\\"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
_0_["path-sep"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
end
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["path-sep"] = v_0_
|
|
||||||
path_sep = v_0_
|
|
||||||
end
|
end
|
||||||
local basename
|
_2amodule_2a["path-sep"] = path_sep
|
||||||
do
|
return _2amodule_2a
|
||||||
local v_0_
|
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function basename0(path)
|
|
||||||
return nvim.fn.fnamemodify(path, ":h")
|
|
||||||
end
|
|
||||||
v_0_0 = basename0
|
|
||||||
_0_["basename"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["basename"] = v_0_
|
|
||||||
basename = v_0_
|
|
||||||
end
|
|
||||||
local mkdirp
|
|
||||||
do
|
|
||||||
local v_0_
|
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function mkdirp0(dir)
|
|
||||||
return nvim.fn.mkdir(dir, "p")
|
|
||||||
end
|
|
||||||
v_0_0 = mkdirp0
|
|
||||||
_0_["mkdirp"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["mkdirp"] = v_0_
|
|
||||||
mkdirp = v_0_
|
|
||||||
end
|
|
||||||
local relglob
|
|
||||||
do
|
|
||||||
local v_0_
|
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function relglob0(dir, expr)
|
|
||||||
local dir_len = a.inc(string.len(dir))
|
|
||||||
local function _3_(_241)
|
|
||||||
return string.sub(_241, dir_len)
|
|
||||||
end
|
|
||||||
return a.map(_3_, nvim.fn.globpath(dir, expr, true, true))
|
|
||||||
end
|
|
||||||
v_0_0 = relglob0
|
|
||||||
_0_["relglob"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["relglob"] = v_0_
|
|
||||||
relglob = v_0_
|
|
||||||
end
|
|
||||||
local glob_dir_newer_3f
|
|
||||||
do
|
|
||||||
local v_0_
|
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function glob_dir_newer_3f0(a_dir, b_dir, expr, b_dir_path_fn)
|
|
||||||
local newer_3f = false
|
|
||||||
for _, path in ipairs(relglob(a_dir, expr)) do
|
|
||||||
if (nvim.fn.getftime((a_dir .. path)) > nvim.fn.getftime((b_dir .. b_dir_path_fn(path)))) then
|
|
||||||
newer_3f = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return newer_3f
|
|
||||||
end
|
|
||||||
v_0_0 = glob_dir_newer_3f0
|
|
||||||
_0_["glob-dir-newer?"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["glob-dir-newer?"] = v_0_
|
|
||||||
glob_dir_newer_3f = v_0_
|
|
||||||
end
|
|
||||||
local macro_file_path_3f
|
|
||||||
do
|
|
||||||
local v_0_
|
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function macro_file_path_3f0(path)
|
|
||||||
return string.match(path, "macros.fnl$")
|
|
||||||
end
|
|
||||||
v_0_0 = macro_file_path_3f0
|
|
||||||
_0_["macro-file-path?"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["macro-file-path?"] = v_0_
|
|
||||||
macro_file_path_3f = v_0_
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
|
@ -3,7 +3,16 @@
|
|||||||
|
|
||||||
;; Automatically loaded through require-macros for all Aniseed based evaluations.
|
;; Automatically loaded through require-macros for all Aniseed based evaluations.
|
||||||
|
|
||||||
(local module-sym (gensym))
|
(fn nil? [x]
|
||||||
|
(= :nil (type x)))
|
||||||
|
|
||||||
|
(fn seq? [x]
|
||||||
|
(not (nil? (. x 1))))
|
||||||
|
|
||||||
|
(fn str [x]
|
||||||
|
(if (= :string (type x))
|
||||||
|
x
|
||||||
|
(tostring x)))
|
||||||
|
|
||||||
(fn sorted-each [f x]
|
(fn sorted-each [f x]
|
||||||
(let [acc []]
|
(let [acc []]
|
||||||
@ -12,122 +21,186 @@
|
|||||||
(table.sort
|
(table.sort
|
||||||
acc
|
acc
|
||||||
(fn [a b]
|
(fn [a b]
|
||||||
(< (. a 1) (. b 1))))
|
(< (str (. a 1)) (str (. b 1)))))
|
||||||
(each [_ [k v] (ipairs acc)]
|
(each [_ [k v] (ipairs acc)]
|
||||||
(f k v))))
|
(f k v))))
|
||||||
|
|
||||||
(fn module [name new-local-fns initial-mod]
|
(fn contains? [t target]
|
||||||
`(-> [(local ,module-sym
|
(var seen? false)
|
||||||
(let [name# ,(tostring name)
|
(each [k v (pairs t)]
|
||||||
module# (let [x# (. package.loaded name#)]
|
(when (= k target)
|
||||||
(if (= :table (type x#))
|
(set seen? true)))
|
||||||
x#
|
seen?)
|
||||||
,(or initial-mod {})))]
|
|
||||||
(tset module# :aniseed/module name#)
|
|
||||||
(tset module# :aniseed/locals (or (. module# :aniseed/locals) {}))
|
|
||||||
(tset module# :aniseed/local-fns (or (. module# :aniseed/local-fns) {}))
|
|
||||||
(tset package.loaded name# module#)
|
|
||||||
module#))
|
|
||||||
|
|
||||||
,module-sym
|
(fn ensure-sym [x]
|
||||||
|
(if (= :string (type x))
|
||||||
|
(sym x)
|
||||||
|
x))
|
||||||
|
|
||||||
;; Meta! Autoload the autoload function, so it's only loaded when used.
|
;; This marker can be used by a post-processor to delete a useless byproduct line.
|
||||||
(local ,(sym :autoload)
|
(local delete-marker :ANISEED_DELETE_ME)
|
||||||
(fn [...] ((. (require :aniseed.autoload) :autoload) ...)))
|
|
||||||
|
|
||||||
,(let [aliases []
|
;; We store all locals under this for later splatting.
|
||||||
vals []
|
(local locals-key :aniseed/locals)
|
||||||
effects []
|
|
||||||
pkg (let [x (. package.loaded (tostring name))]
|
|
||||||
(when (= :table (type x))
|
|
||||||
x))
|
|
||||||
locals (-?> pkg (. :aniseed/locals))
|
|
||||||
local-fns (or (and (not new-local-fns)
|
|
||||||
(?. pkg :aniseed/local-fns))
|
|
||||||
{})]
|
|
||||||
|
|
||||||
(when new-local-fns
|
;; Various symbols we want to use multiple times.
|
||||||
(each [action binds (pairs new-local-fns)]
|
;; Avoids the compiler complaining that we're introducing locals without gensym.
|
||||||
(let [action-str (tostring action)
|
(local mod-name-sym (sym :*module-name*))
|
||||||
current (or (. local-fns action-str) {})]
|
(local mod-sym (sym :*module*))
|
||||||
(tset local-fns action-str current)
|
(local mod-locals-sym (sym :*module-locals*))
|
||||||
(each [alias module (pairs binds)]
|
(local autoload-sym (sym :autoload))
|
||||||
(if (= :number (type alias))
|
|
||||||
(tset current (tostring module) true)
|
|
||||||
(tset current (tostring alias) (tostring module)))))))
|
|
||||||
|
|
||||||
(sorted-each
|
;; Upserts the existence of the module for subsequent def forms and expands the
|
||||||
(fn [action binds]
|
;; bound function calls into the current context.
|
||||||
(sorted-each
|
;;
|
||||||
(fn [alias-or-val val]
|
;; On subsequent interactive calls it will expand the existing module into your
|
||||||
(if (= true val)
|
;; current context. This should be used by Conjure as you enter a buffer.
|
||||||
|
;;
|
||||||
|
;; (module foo
|
||||||
|
;; {require {nvim aniseed.nvim}}
|
||||||
|
;; {:some-optional-base :table-of-things
|
||||||
|
;; :to-base :the-module-off-of})
|
||||||
|
;;
|
||||||
|
;; (module foo) ;; expands foo into your current context
|
||||||
|
(fn module [mod-name mod-fns mod-base]
|
||||||
|
(let [;; So we can check for existing values and know if we're in an interactive eval.
|
||||||
|
;; If the module doesn't exist we're compiling and can skip interactive tooling.
|
||||||
|
existing-mod (. package.loaded (tostring mod-name))
|
||||||
|
|
||||||
;; {require-macros [bar]}
|
;; Determine if we're in an interactive eval or not.
|
||||||
(table.insert effects `(,(sym action) ,alias-or-val))
|
|
||||||
|
|
||||||
;; {require {foo bar}}
|
;; We don't count userdata / other types as an existing module since we
|
||||||
(do
|
;; can't really work with anything other than a table. If it's not a
|
||||||
(table.insert aliases (sym alias-or-val))
|
;; table it's probably not a module Aniseed can work with in general
|
||||||
(table.insert vals `(,(sym action) ,val)))))
|
;; since it's assumed all Aniseed modules are table based.
|
||||||
|
|
||||||
binds))
|
;; We can also completely disable the interactive mode which is used by
|
||||||
local-fns)
|
;; `aniseed.env` but can also be enabled by others. Sadly this works
|
||||||
|
;; through global variables but still!
|
||||||
|
interactive? (and (table? existing-mod)
|
||||||
|
(not _G.ANISEED_STATIC_MODULES))
|
||||||
|
|
||||||
(when locals
|
;; The final result table that gets returned from the macro.
|
||||||
(sorted-each
|
;; This is the best way I've found to introduce many (local ...) forms from one macro.
|
||||||
(fn [alias val]
|
result `[,delete-marker
|
||||||
(table.insert aliases (sym alias))
|
|
||||||
(table.insert vals `(. ,module-sym :aniseed/locals ,alias)))
|
|
||||||
locals))
|
|
||||||
|
|
||||||
`[,effects
|
;; We can't refer to things like (local (foo bar) (10 foo)).
|
||||||
(local ,aliases
|
;; So we need to define them in an earlier local.
|
||||||
(let [(ok?# val#)
|
(local ,mod-name-sym ,(tostring mod-name))
|
||||||
(pcall
|
|
||||||
(fn [] ,vals))]
|
;; Only expose the module table if it doesn't exist yet.
|
||||||
(if ok?#
|
(local ,mod-sym ,(if interactive?
|
||||||
(do
|
`(. package.loaded ,mod-name-sym)
|
||||||
(tset ,module-sym :aniseed/local-fns ,local-fns)
|
`(do
|
||||||
val#)
|
(tset package.loaded ,mod-name-sym ,(or mod-base {}))
|
||||||
(print val#))))
|
(. package.loaded ,mod-name-sym))))
|
||||||
(local ,(sym "*module*") ,module-sym)
|
|
||||||
(local ,(sym "*module-name*") ,(tostring name))])]
|
;; As we def values we insert them into locals.
|
||||||
(. 2)))
|
;; This table is then expanded in subsequent interactive evals.
|
||||||
|
(local ,mod-locals-sym ,(if interactive?
|
||||||
|
`(. ,mod-sym ,locals-key)
|
||||||
|
`(do
|
||||||
|
(tset ,mod-sym ,locals-key {})
|
||||||
|
(. ,mod-sym ,locals-key))))]
|
||||||
|
|
||||||
|
;; Bindings that are returned from the macro.
|
||||||
|
;; (=> :some-symbol :some-value)
|
||||||
|
keys []
|
||||||
|
vals []
|
||||||
|
=> (fn [k v]
|
||||||
|
(table.insert keys k)
|
||||||
|
(table.insert vals v))]
|
||||||
|
|
||||||
|
;; For each function / value pair...
|
||||||
|
(when mod-fns
|
||||||
|
(sorted-each
|
||||||
|
(fn [mod-fn args]
|
||||||
|
(if (seq? args)
|
||||||
|
;; If it's sequential, we execute the fn for side effects.
|
||||||
|
(each [_ arg (ipairs args)]
|
||||||
|
(=> (sym :_) `(,mod-fn ,(tostring arg))))
|
||||||
|
|
||||||
|
;; Otherwise we need to bind the execution to a name.
|
||||||
|
(sorted-each
|
||||||
|
(fn [bind arg]
|
||||||
|
(=> (ensure-sym bind) `(,mod-fn ,(tostring arg))))
|
||||||
|
args)))
|
||||||
|
mod-fns)
|
||||||
|
|
||||||
|
;; Only require autoload if it's used.
|
||||||
|
(when (contains? mod-fns autoload-sym)
|
||||||
|
(table.insert result `(local ,autoload-sym (. (require "conjure-macroexpand.aniseed.autoload") :autoload)))))
|
||||||
|
|
||||||
|
;; When we have some keys insert the key/vals pairs locals.
|
||||||
|
;; If this is empty we end up generating invalid Lua.
|
||||||
|
(when (seq? keys)
|
||||||
|
(table.insert result `(local ,(list (unpack keys)) (values ,(unpack vals))))
|
||||||
|
|
||||||
|
;; We also bind these exposed locals into *module-locals* for future splatting.
|
||||||
|
(each [_ k (ipairs keys)]
|
||||||
|
(if (sym? k)
|
||||||
|
;; Normal symbols can just be assigned into module-locals.
|
||||||
|
(table.insert result `(tset ,mod-locals-sym ,(tostring k) ,k))
|
||||||
|
|
||||||
|
;; Tables mean we're using Fennel destructure syntax.
|
||||||
|
;; So we need to unpack the assignments so they can be used later in interactive evals.
|
||||||
|
(sorted-each
|
||||||
|
(fn [k v]
|
||||||
|
(table.insert
|
||||||
|
result
|
||||||
|
`(tset ,mod-locals-sym ,(tostring k) ,v)))
|
||||||
|
k))))
|
||||||
|
|
||||||
|
;; Now we can expand any existing locals into the current scope.
|
||||||
|
;; Since this will only happen in interactive evals we can generate messy code.
|
||||||
|
(when interactive?
|
||||||
|
;; Expand exported values into the current scope, except aniseed/locals.
|
||||||
|
(sorted-each
|
||||||
|
(fn [k v]
|
||||||
|
(when (not= k locals-key)
|
||||||
|
(table.insert result `(local ,(sym k) (. ,mod-sym ,k)))))
|
||||||
|
existing-mod)
|
||||||
|
|
||||||
|
;; Expand locals into the current scope.
|
||||||
|
(when (. existing-mod locals-key)
|
||||||
|
(sorted-each
|
||||||
|
(fn [k v]
|
||||||
|
(table.insert result `(local ,(sym k) (. ,mod-locals-sym ,k))))
|
||||||
|
(. existing-mod locals-key))))
|
||||||
|
|
||||||
|
result))
|
||||||
|
|
||||||
(fn def- [name value]
|
(fn def- [name value]
|
||||||
`(local ,name
|
`[,delete-marker
|
||||||
(let [v# ,value
|
(local ,name ,value)
|
||||||
t# (. ,module-sym :aniseed/locals)]
|
(tset ,mod-locals-sym ,(tostring name) ,name)])
|
||||||
(tset t# ,(tostring name) v#)
|
|
||||||
v#)))
|
|
||||||
|
|
||||||
(fn def [name value]
|
(fn def [name value]
|
||||||
`(def- ,name
|
`[,delete-marker
|
||||||
(do
|
(local ,name ,value)
|
||||||
(let [v# ,value]
|
(tset ,mod-sym ,(tostring name) ,name)])
|
||||||
(tset ,module-sym ,(tostring name) v#)
|
|
||||||
v#))))
|
|
||||||
|
|
||||||
(fn defn- [name ...]
|
(fn defn- [name ...]
|
||||||
`(def- ,name (fn ,name ,...)))
|
`[,delete-marker
|
||||||
|
(fn ,name ,...)
|
||||||
|
(tset ,mod-locals-sym ,(tostring name) ,name)])
|
||||||
|
|
||||||
(fn defn [name ...]
|
(fn defn [name ...]
|
||||||
`(def ,name (fn ,name ,...)))
|
`[,delete-marker
|
||||||
|
(fn ,name ,...)
|
||||||
|
(tset ,mod-sym ,(tostring name) ,name)])
|
||||||
|
|
||||||
(fn defonce- [name value]
|
(fn defonce- [name value]
|
||||||
`(def- ,name
|
`(def- ,name (or (. ,mod-sym ,(tostring name)) ,value)))
|
||||||
(or (. ,module-sym :aniseed/locals ,(tostring name))
|
|
||||||
,value)))
|
|
||||||
|
|
||||||
(fn defonce [name value]
|
(fn defonce [name value]
|
||||||
`(def ,name
|
`(def ,name (or (. ,mod-sym ,(tostring name)) ,value)))
|
||||||
(or (. ,module-sym ,(tostring name))
|
|
||||||
,value)))
|
|
||||||
|
|
||||||
(fn deftest [name ...]
|
(fn deftest [name ...]
|
||||||
`(let [tests# (or (. ,module-sym :aniseed/tests) {})]
|
`(let [tests# (or (. ,mod-sym :aniseed/tests
|
||||||
|
) {})]
|
||||||
(tset tests# ,(tostring name) (fn [,(sym :t)] ,...))
|
(tset tests# ,(tostring name) (fn [,(sym :t)] ,...))
|
||||||
(tset ,module-sym :aniseed/tests tests#)))
|
(tset ,mod-sym :aniseed/tests tests#)))
|
||||||
|
|
||||||
(fn time [...]
|
(fn time [...]
|
||||||
`(let [start# (vim.loop.hrtime)
|
`(let [start# (vim.loop.hrtime)
|
||||||
@ -136,9 +209,90 @@
|
|||||||
(print (.. "Elapsed time: " (/ (- end# start#) 1000000) " msecs"))
|
(print (.. "Elapsed time: " (/ (- end# start#) 1000000) " msecs"))
|
||||||
result#))
|
result#))
|
||||||
|
|
||||||
|
;; Checks surrounding scope for *module* and, if found, makes sure *module* is
|
||||||
|
;; inserted after `last-expr` (and therefore *module* is returned)
|
||||||
|
(fn wrap-last-expr [last-expr]
|
||||||
|
(if (in-scope? mod-sym)
|
||||||
|
`(do ,last-expr ,mod-sym)
|
||||||
|
last-expr))
|
||||||
|
|
||||||
|
;; Used by aniseed.compile to wrap the entire body of a file, replacing the
|
||||||
|
;; last expression with another wrapper; `wrap-last-expr` which handles the
|
||||||
|
;; module's return value.
|
||||||
|
;;
|
||||||
|
;; i.e.
|
||||||
|
;; (wrap-module-body
|
||||||
|
;; (module foo)
|
||||||
|
;; (def x 1)
|
||||||
|
;; (vim.cmd "...")) ; vim.cmd returns a string which becomes the returned value
|
||||||
|
;; ; for the entire file once compiled
|
||||||
|
;; --> expands to:
|
||||||
|
;; (do
|
||||||
|
;; (module foo)
|
||||||
|
;; (def x 1)
|
||||||
|
;; (wrap-last-expr (vim.cmd "...")))
|
||||||
|
;; --> expands to:
|
||||||
|
;; (do
|
||||||
|
;; (module foo)
|
||||||
|
;; (def x 1)
|
||||||
|
;; (do
|
||||||
|
;; (vim.cmd "...")
|
||||||
|
;; *module*))
|
||||||
|
(fn wrap-module-body [...]
|
||||||
|
(let [body# [...]
|
||||||
|
last-expr# (table.remove body#)]
|
||||||
|
(table.insert body# `(wrap-last-expr ,last-expr#))
|
||||||
|
`(do ,(unpack body#))))
|
||||||
|
|
||||||
|
(fn conditional-let [branch bindings ...]
|
||||||
|
(assert (= 2 (length bindings)) "expected a single binding pair")
|
||||||
|
|
||||||
|
(let [[bind-expr value-expr] bindings]
|
||||||
|
(if
|
||||||
|
;; Simple symbols
|
||||||
|
;; [foo bar]
|
||||||
|
(sym? bind-expr)
|
||||||
|
`(let [,bind-expr ,value-expr]
|
||||||
|
(,branch ,bind-expr ,...))
|
||||||
|
|
||||||
|
;; List / values destructure
|
||||||
|
;; [(a b) c]
|
||||||
|
(list? bind-expr)
|
||||||
|
(do
|
||||||
|
;; Even if the user isn't using the first slot, we will.
|
||||||
|
;; [(_ val) (pcall #:foo)]
|
||||||
|
;; => [(bindGENSYM12345 val) (pcall #:foo)]
|
||||||
|
(when (= '_ (. bind-expr 1))
|
||||||
|
(tset bind-expr 1 (gensym "bind")))
|
||||||
|
|
||||||
|
`(let [,bind-expr ,value-expr]
|
||||||
|
(,branch ,(. bind-expr 1) ,...)))
|
||||||
|
|
||||||
|
;; Sequential and associative table destructure
|
||||||
|
;; [[a b] c]
|
||||||
|
;; [{: a : b} c]
|
||||||
|
(table? bind-expr)
|
||||||
|
`(let [value# ,value-expr
|
||||||
|
,bind-expr (or value# {})]
|
||||||
|
(,branch value# ,...))
|
||||||
|
|
||||||
|
;; We should never get here, but just in case.
|
||||||
|
(assert (.. "unknown bind-expr type: " (type bind-expr))))))
|
||||||
|
|
||||||
|
(fn if-let [bindings ...]
|
||||||
|
(assert (<= (length [...]) 2) (.. "if-let does not support more than two branches"))
|
||||||
|
(conditional-let 'if bindings ...))
|
||||||
|
|
||||||
|
(fn when-let [bindings ...]
|
||||||
|
(conditional-let 'when bindings ...))
|
||||||
|
|
||||||
{:module module
|
{:module module
|
||||||
:def- def- :def def
|
:def- def- :def def
|
||||||
:defn- defn- :defn defn
|
:defn- defn- :defn defn
|
||||||
:defonce- defonce- :defonce defonce
|
:defonce- defonce- :defonce defonce
|
||||||
|
:if-let if-let
|
||||||
|
:when-let when-let
|
||||||
|
:wrap-last-expr wrap-last-expr
|
||||||
|
:wrap-module-body wrap-module-body
|
||||||
:deftest deftest
|
:deftest deftest
|
||||||
:time time}
|
:time time}
|
||||||
|
@ -1,41 +1,12 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/nvim.fnl"
|
local _2afile_2a = "fnl/aniseed/nvim.fnl"
|
||||||
local _0_
|
|
||||||
do
|
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.nvim"
|
|
||||||
local module_0_
|
|
||||||
do
|
|
||||||
local x_0_ = package.loaded[name_0_]
|
|
||||||
if ("table" == type(x_0_)) then
|
|
||||||
module_0_ = x_0_
|
|
||||||
else
|
|
||||||
module_0_ = require("conjure-macroexpand.aniseed.deps.nvim")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module_0_["aniseed/module"] = name_0_
|
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
|
||||||
local autoload
|
|
||||||
local function _1_(...)
|
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
|
||||||
end
|
|
||||||
autoload = _1_
|
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.nvim"
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.nvim"
|
||||||
return ({nil, _0_, nil, {{}, nil, nil, nil}})[2]
|
local _2amodule_2a
|
||||||
|
do
|
||||||
|
package.loaded[_2amodule_name_2a] = require("conjure-macroexpand.aniseed.deps.nvim")
|
||||||
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
|
end
|
||||||
|
local _2amodule_locals_2a
|
||||||
|
do
|
||||||
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
|
end
|
||||||
|
@ -1,122 +1,63 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/nvim/util.fnl"
|
local _2afile_2a = "fnl/aniseed/nvim/util.fnl"
|
||||||
local _0_
|
|
||||||
do
|
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.nvim.util"
|
|
||||||
local module_0_
|
|
||||||
do
|
|
||||||
local x_0_ = package.loaded[name_0_]
|
|
||||||
if ("table" == type(x_0_)) then
|
|
||||||
module_0_ = x_0_
|
|
||||||
else
|
|
||||||
module_0_ = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module_0_["aniseed/module"] = name_0_
|
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
|
||||||
local autoload
|
|
||||||
local function _1_(...)
|
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
|
||||||
end
|
|
||||||
autoload = _1_
|
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {autoload("conjure-macroexpand.aniseed.nvim")}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {autoload = {nvim = "conjure-macroexpand.aniseed.nvim"}}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local nvim = _local_0_[1]
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.nvim.util"
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.nvim.util"
|
||||||
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end
|
local _2amodule_2a
|
||||||
local normal
|
|
||||||
do
|
do
|
||||||
local v_0_
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
do
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
local v_0_0
|
|
||||||
local function normal0(keys)
|
|
||||||
return nvim.ex.silent(("exe \"normal! " .. keys .. "\""))
|
|
||||||
end
|
|
||||||
v_0_0 = normal0
|
|
||||||
_0_["normal"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["normal"] = v_0_
|
|
||||||
normal = v_0_
|
|
||||||
end
|
end
|
||||||
local fn_bridge
|
local _2amodule_locals_2a
|
||||||
do
|
do
|
||||||
local v_0_
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
do
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
local v_0_0
|
|
||||||
local function fn_bridge0(viml_name, mod, lua_name, opts)
|
|
||||||
local _let_0_ = (opts or {})
|
|
||||||
local range = _let_0_["range"]
|
|
||||||
local _return = _let_0_["return"]
|
|
||||||
local _3_
|
|
||||||
if range then
|
|
||||||
_3_ = " range"
|
|
||||||
else
|
|
||||||
_3_ = ""
|
|
||||||
end
|
|
||||||
local _5_
|
|
||||||
if (_return ~= false) then
|
|
||||||
_5_ = "return"
|
|
||||||
else
|
|
||||||
_5_ = "call"
|
|
||||||
end
|
|
||||||
local _7_
|
|
||||||
if range then
|
|
||||||
_7_ = "\" . a:firstline . \", \" . a:lastline . \", "
|
|
||||||
else
|
|
||||||
_7_ = ""
|
|
||||||
end
|
|
||||||
return nvim.ex.function_((viml_name .. "(...)" .. _3_ .. "\n " .. _5_ .. " luaeval(\"require('" .. mod .. "')['" .. lua_name .. "'](" .. _7_ .. "unpack(_A))\", a:000)\n endfunction"))
|
|
||||||
end
|
|
||||||
v_0_0 = fn_bridge0
|
|
||||||
_0_["fn-bridge"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["fn-bridge"] = v_0_
|
|
||||||
fn_bridge = v_0_
|
|
||||||
end
|
end
|
||||||
local with_out_str
|
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
||||||
do
|
local nvim = autoload("conjure-macroexpand.aniseed.nvim")
|
||||||
local v_0_
|
do end (_2amodule_locals_2a)["nvim"] = nvim
|
||||||
do
|
local function normal(keys)
|
||||||
local v_0_0
|
return nvim.ex.silent(("exe \"normal! " .. keys .. "\""))
|
||||||
local function with_out_str0(f)
|
|
||||||
nvim.ex.redir("=> g:aniseed_nvim_util_out_str")
|
|
||||||
do
|
|
||||||
local ok_3f, err = pcall(f)
|
|
||||||
nvim.ex.redir("END")
|
|
||||||
nvim.ex.echon("")
|
|
||||||
nvim.ex.redraw()
|
|
||||||
if not ok_3f then
|
|
||||||
error(err)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return string.gsub(nvim.g.aniseed_nvim_util_out_str, "^(\n?)(.*)$", "%2%1")
|
|
||||||
end
|
|
||||||
v_0_0 = with_out_str0
|
|
||||||
_0_["with-out-str"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["with-out-str"] = v_0_
|
|
||||||
with_out_str = v_0_
|
|
||||||
end
|
end
|
||||||
return nil
|
_2amodule_2a["normal"] = normal
|
||||||
|
local function fn_bridge(viml_name, mod, lua_name, opts)
|
||||||
|
local _let_1_ = (opts or {})
|
||||||
|
local range = _let_1_["range"]
|
||||||
|
local _return = _let_1_["return"]
|
||||||
|
local function _2_()
|
||||||
|
if range then
|
||||||
|
return " range"
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function _3_()
|
||||||
|
if (_return ~= false) then
|
||||||
|
return "return"
|
||||||
|
else
|
||||||
|
return "call"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function _4_()
|
||||||
|
if range then
|
||||||
|
return "\" . a:firstline . \", \" . a:lastline . \", "
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nvim.ex.function_((viml_name .. "(...)" .. _2_() .. "\n " .. _3_() .. " luaeval(\"require('" .. mod .. "')['" .. lua_name .. "'](" .. _4_() .. "unpack(_A))\", a:000)\n endfunction"))
|
||||||
|
end
|
||||||
|
_2amodule_2a["fn-bridge"] = fn_bridge
|
||||||
|
local function with_out_str(f)
|
||||||
|
nvim.ex.redir("=> g:aniseed_nvim_util_out_str")
|
||||||
|
do
|
||||||
|
local ok_3f, err = pcall(f)
|
||||||
|
nvim.ex.redir("END")
|
||||||
|
nvim.ex.echon("")
|
||||||
|
nvim.ex.redraw()
|
||||||
|
if not ok_3f then
|
||||||
|
error(err)
|
||||||
|
else
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return string.gsub(nvim.g.aniseed_nvim_util_out_str, "^(\n?)(.*)$", "%2%1")
|
||||||
|
end
|
||||||
|
_2amodule_2a["with-out-str"] = with_out_str
|
||||||
|
return _2amodule_2a
|
||||||
|
61
lua/conjure-macroexpand/aniseed/setup.lua
Normal file
61
lua/conjure-macroexpand/aniseed/setup.lua
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
local _2afile_2a = "fnl/aniseed/setup.fnl"
|
||||||
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.setup"
|
||||||
|
local _2amodule_2a
|
||||||
|
do
|
||||||
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
|
end
|
||||||
|
local _2amodule_locals_2a
|
||||||
|
do
|
||||||
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
|
end
|
||||||
|
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
||||||
|
local a, env, eval, nvim = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.env"), autoload("conjure-macroexpand.aniseed.eval"), autoload("conjure-macroexpand.aniseed.nvim")
|
||||||
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
|
_2amodule_locals_2a["env"] = env
|
||||||
|
_2amodule_locals_2a["eval"] = eval
|
||||||
|
_2amodule_locals_2a["nvim"] = nvim
|
||||||
|
local function init()
|
||||||
|
if (1 == nvim.fn.has("nvim-0.7")) then
|
||||||
|
local function _1_(cmd)
|
||||||
|
local ok_3f, res = eval.str(cmd.args, {})
|
||||||
|
if ok_3f then
|
||||||
|
return nvim.echo(res)
|
||||||
|
else
|
||||||
|
return nvim.err_writeln(res)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
nvim.create_user_command("AniseedEval", _1_, {nargs = 1})
|
||||||
|
local function _3_(cmd)
|
||||||
|
local code
|
||||||
|
local function _4_()
|
||||||
|
if ("" == cmd.args) then
|
||||||
|
return nvim.buf_get_name(nvim.get_current_buf())
|
||||||
|
else
|
||||||
|
return cmd.args
|
||||||
|
end
|
||||||
|
end
|
||||||
|
code = a.slurp(_4_())
|
||||||
|
if code then
|
||||||
|
local ok_3f, res = eval.str(code, {})
|
||||||
|
if ok_3f then
|
||||||
|
return nvim.echo(res)
|
||||||
|
else
|
||||||
|
return nvim.err_writeln(res)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return nvim.err_writeln(("File '" .. (cmd.args or "nil") .. "' not found"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
nvim.create_user_command("AniseedEvalFile", _3_, {nargs = "?", complete = "file"})
|
||||||
|
else
|
||||||
|
end
|
||||||
|
if nvim.g["aniseed#env"] then
|
||||||
|
return env.init(nvim.g["aniseed#env"])
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_2amodule_2a["init"] = init
|
||||||
|
return _2amodule_2a
|
@ -1,182 +1,84 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/string.fnl"
|
local _2afile_2a = "fnl/aniseed/string.fnl"
|
||||||
local _0_
|
|
||||||
do
|
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.string"
|
|
||||||
local module_0_
|
|
||||||
do
|
|
||||||
local x_0_ = package.loaded[name_0_]
|
|
||||||
if ("table" == type(x_0_)) then
|
|
||||||
module_0_ = x_0_
|
|
||||||
else
|
|
||||||
module_0_ = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module_0_["aniseed/module"] = name_0_
|
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
|
||||||
local autoload
|
|
||||||
local function _1_(...)
|
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
|
||||||
end
|
|
||||||
autoload = _1_
|
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {autoload("conjure-macroexpand.aniseed.core")}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {autoload = {a = "conjure-macroexpand.aniseed.core"}}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local a = _local_0_[1]
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.string"
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.string"
|
||||||
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end
|
local _2amodule_2a
|
||||||
local join
|
|
||||||
do
|
do
|
||||||
local v_0_
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
do
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
local v_0_0
|
end
|
||||||
local function join0(...)
|
local _2amodule_locals_2a
|
||||||
local args = {...}
|
do
|
||||||
local function _3_(...)
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
if (2 == a.count(args)) then
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
return args
|
end
|
||||||
else
|
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
||||||
return {"", a.first(args)}
|
local a = autoload("conjure-macroexpand.aniseed.core")
|
||||||
end
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
|
local function join(...)
|
||||||
|
local args = {...}
|
||||||
|
local function _2_(...)
|
||||||
|
if (2 == a.count(args)) then
|
||||||
|
return args
|
||||||
|
else
|
||||||
|
return {"", a.first(args)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local _let_1_ = _2_(...)
|
||||||
|
local sep = _let_1_[1]
|
||||||
|
local xs = _let_1_[2]
|
||||||
|
local len = a.count(xs)
|
||||||
|
local result = {}
|
||||||
|
if (len > 0) then
|
||||||
|
for i = 1, len do
|
||||||
|
local x = xs[i]
|
||||||
|
local _3_
|
||||||
|
if ("string" == type(x)) then
|
||||||
|
_3_ = x
|
||||||
|
elseif (nil == x) then
|
||||||
|
_3_ = x
|
||||||
|
else
|
||||||
|
_3_ = a["pr-str"](x)
|
||||||
end
|
end
|
||||||
local _let_0_ = _3_(...)
|
if (_3_ ~= nil) then
|
||||||
local sep = _let_0_[1]
|
table.insert(result, _3_)
|
||||||
local xs = _let_0_[2]
|
else
|
||||||
local len = a.count(xs)
|
|
||||||
local result = {}
|
|
||||||
if (len > 0) then
|
|
||||||
for i = 1, len do
|
|
||||||
local x = xs[i]
|
|
||||||
local _4_
|
|
||||||
if ("string" == type(x)) then
|
|
||||||
_4_ = x
|
|
||||||
elseif (nil == x) then
|
|
||||||
_4_ = x
|
|
||||||
else
|
|
||||||
_4_ = a["pr-str"](x)
|
|
||||||
end
|
|
||||||
if _4_ then
|
|
||||||
table.insert(result, _4_)
|
|
||||||
else
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return table.concat(result, sep)
|
|
||||||
end
|
end
|
||||||
v_0_0 = join0
|
else
|
||||||
_0_["join"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
end
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
return table.concat(result, sep)
|
||||||
t_0_["join"] = v_0_
|
|
||||||
join = v_0_
|
|
||||||
end
|
end
|
||||||
local split
|
_2amodule_2a["join"] = join
|
||||||
do
|
local function split(s, pat)
|
||||||
local v_0_
|
local done_3f = false
|
||||||
do
|
local acc = {}
|
||||||
local v_0_0
|
local index = 1
|
||||||
local function split0(s, pat)
|
while not done_3f do
|
||||||
local done_3f = false
|
local start, _end = string.find(s, pat, index)
|
||||||
local acc = {}
|
if ("nil" == type(start)) then
|
||||||
local index = 1
|
table.insert(acc, string.sub(s, index))
|
||||||
while not done_3f do
|
done_3f = true
|
||||||
local start, _end = string.find(s, pat, index)
|
else
|
||||||
if ("nil" == type(start)) then
|
table.insert(acc, string.sub(s, index, (start - 1)))
|
||||||
table.insert(acc, string.sub(s, index))
|
index = (_end + 1)
|
||||||
done_3f = true
|
|
||||||
else
|
|
||||||
table.insert(acc, string.sub(s, index, (start - 1)))
|
|
||||||
index = (_end + 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return acc
|
|
||||||
end
|
end
|
||||||
v_0_0 = split0
|
|
||||||
_0_["split"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
end
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
return acc
|
||||||
t_0_["split"] = v_0_
|
|
||||||
split = v_0_
|
|
||||||
end
|
end
|
||||||
local blank_3f
|
_2amodule_2a["split"] = split
|
||||||
do
|
local function blank_3f(s)
|
||||||
local v_0_
|
return (a["empty?"](s) or not string.find(s, "[^%s]"))
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function blank_3f0(s)
|
|
||||||
return (a["empty?"](s) or not string.find(s, "[^%s]"))
|
|
||||||
end
|
|
||||||
v_0_0 = blank_3f0
|
|
||||||
_0_["blank?"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["blank?"] = v_0_
|
|
||||||
blank_3f = v_0_
|
|
||||||
end
|
end
|
||||||
local triml
|
_2amodule_2a["blank?"] = blank_3f
|
||||||
do
|
local function triml(s)
|
||||||
local v_0_
|
return string.gsub(s, "^%s*(.-)", "%1")
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function triml0(s)
|
|
||||||
return string.gsub(s, "^%s*(.-)", "%1")
|
|
||||||
end
|
|
||||||
v_0_0 = triml0
|
|
||||||
_0_["triml"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["triml"] = v_0_
|
|
||||||
triml = v_0_
|
|
||||||
end
|
end
|
||||||
local trimr
|
_2amodule_2a["triml"] = triml
|
||||||
do
|
local function trimr(s)
|
||||||
local v_0_
|
return string.gsub(s, "(.-)%s*$", "%1")
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function trimr0(s)
|
|
||||||
return string.gsub(s, "(.-)%s*$", "%1")
|
|
||||||
end
|
|
||||||
v_0_0 = trimr0
|
|
||||||
_0_["trimr"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["trimr"] = v_0_
|
|
||||||
trimr = v_0_
|
|
||||||
end
|
end
|
||||||
local trim
|
_2amodule_2a["trimr"] = trimr
|
||||||
do
|
local function trim(s)
|
||||||
local v_0_
|
return string.gsub(s, "^%s*(.-)%s*$", "%1")
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function trim0(s)
|
|
||||||
return string.gsub(s, "^%s*(.-)%s*$", "%1")
|
|
||||||
end
|
|
||||||
v_0_0 = trim0
|
|
||||||
_0_["trim"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["trim"] = v_0_
|
|
||||||
trim = v_0_
|
|
||||||
end
|
end
|
||||||
return nil
|
_2amodule_2a["trim"] = trim
|
||||||
|
return _2amodule_2a
|
||||||
|
@ -1,235 +1,153 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/test.fnl"
|
local _2afile_2a = "fnl/aniseed/test.fnl"
|
||||||
local _0_
|
|
||||||
do
|
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.test"
|
|
||||||
local module_0_
|
|
||||||
do
|
|
||||||
local x_0_ = package.loaded[name_0_]
|
|
||||||
if ("table" == type(x_0_)) then
|
|
||||||
module_0_ = x_0_
|
|
||||||
else
|
|
||||||
module_0_ = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module_0_["aniseed/module"] = name_0_
|
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
|
||||||
local autoload
|
|
||||||
local function _1_(...)
|
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
|
||||||
end
|
|
||||||
autoload = _1_
|
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim"), autoload("conjure-macroexpand.aniseed.string")}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {autoload = {a = "conjure-macroexpand.aniseed.core", fs = "conjure-macroexpand.aniseed.fs", nvim = "conjure-macroexpand.aniseed.nvim", str = "conjure-macroexpand.aniseed.string"}}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local a = _local_0_[1]
|
|
||||||
local fs = _local_0_[2]
|
|
||||||
local nvim = _local_0_[3]
|
|
||||||
local str = _local_0_[4]
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.test"
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.test"
|
||||||
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end
|
local _2amodule_2a
|
||||||
local ok_3f
|
|
||||||
do
|
do
|
||||||
local v_0_
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
do
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
local v_0_0
|
|
||||||
local function ok_3f0(_3_)
|
|
||||||
local _arg_0_ = _3_
|
|
||||||
local tests = _arg_0_["tests"]
|
|
||||||
local tests_passed = _arg_0_["tests-passed"]
|
|
||||||
return (tests == tests_passed)
|
|
||||||
end
|
|
||||||
v_0_0 = ok_3f0
|
|
||||||
_0_["ok?"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["ok?"] = v_0_
|
|
||||||
ok_3f = v_0_
|
|
||||||
end
|
end
|
||||||
local display_results
|
local _2amodule_locals_2a
|
||||||
do
|
do
|
||||||
local v_0_
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
do
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
local v_0_0
|
|
||||||
local function display_results0(results, prefix)
|
|
||||||
do
|
|
||||||
local _let_0_ = results
|
|
||||||
local assertions = _let_0_["assertions"]
|
|
||||||
local assertions_passed = _let_0_["assertions-passed"]
|
|
||||||
local tests = _let_0_["tests"]
|
|
||||||
local tests_passed = _let_0_["tests-passed"]
|
|
||||||
local _3_
|
|
||||||
if ok_3f(results) then
|
|
||||||
_3_ = "OK"
|
|
||||||
else
|
|
||||||
_3_ = "FAILED"
|
|
||||||
end
|
|
||||||
a.println((prefix .. " " .. _3_ .. " " .. tests_passed .. "/" .. tests .. " tests and " .. assertions_passed .. "/" .. assertions .. " assertions passed"))
|
|
||||||
end
|
|
||||||
return results
|
|
||||||
end
|
|
||||||
v_0_0 = display_results0
|
|
||||||
_0_["display-results"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["display-results"] = v_0_
|
|
||||||
display_results = v_0_
|
|
||||||
end
|
end
|
||||||
local run
|
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
||||||
do
|
local a, fs, nvim, str = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim"), autoload("conjure-macroexpand.aniseed.string")
|
||||||
local v_0_
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
do
|
_2amodule_locals_2a["fs"] = fs
|
||||||
local v_0_0
|
_2amodule_locals_2a["nvim"] = nvim
|
||||||
local function run0(mod_name)
|
_2amodule_locals_2a["str"] = str
|
||||||
local mod = package.loaded[mod_name]
|
local function ok_3f(_1_)
|
||||||
local tests = (a["table?"](mod) and mod["aniseed/tests"])
|
local _arg_2_ = _1_
|
||||||
if a["table?"](tests) then
|
local tests = _arg_2_["tests"]
|
||||||
local results = {["assertions-passed"] = 0, ["tests-passed"] = 0, assertions = 0, tests = #tests}
|
local tests_passed = _arg_2_["tests-passed"]
|
||||||
for label, f in pairs(tests) do
|
return (tests == tests_passed)
|
||||||
local test_failed = false
|
|
||||||
a.update(results, "tests", a.inc)
|
|
||||||
do
|
|
||||||
local prefix = ("[" .. mod_name .. "/" .. label .. "]")
|
|
||||||
local fail
|
|
||||||
local function _3_(desc, ...)
|
|
||||||
test_failed = true
|
|
||||||
local function _4_(...)
|
|
||||||
if desc then
|
|
||||||
return (" (" .. desc .. ")")
|
|
||||||
else
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return a.println((str.join({prefix, " ", ...}) .. _4_(...)))
|
|
||||||
end
|
|
||||||
fail = _3_
|
|
||||||
local begin
|
|
||||||
local function _4_()
|
|
||||||
return a.update(results, "assertions", a.inc)
|
|
||||||
end
|
|
||||||
begin = _4_
|
|
||||||
local pass
|
|
||||||
local function _5_()
|
|
||||||
return a.update(results, "assertions-passed", a.inc)
|
|
||||||
end
|
|
||||||
pass = _5_
|
|
||||||
local t
|
|
||||||
local function _6_(e, r, desc)
|
|
||||||
begin()
|
|
||||||
if (e == r) then
|
|
||||||
return pass()
|
|
||||||
else
|
|
||||||
return fail(desc, "Expected '", a["pr-str"](e), "' but received '", a["pr-str"](r), "'")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function _7_(r, desc)
|
|
||||||
begin()
|
|
||||||
if r then
|
|
||||||
return pass()
|
|
||||||
else
|
|
||||||
return fail(desc, "Expected truthy result but received '", a["pr-str"](r), "'")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function _8_(e, r, desc)
|
|
||||||
begin()
|
|
||||||
local se = a["pr-str"](e)
|
|
||||||
local sr = a["pr-str"](r)
|
|
||||||
if (se == sr) then
|
|
||||||
return pass()
|
|
||||||
else
|
|
||||||
return fail(desc, "Expected (with pr) '", se, "' but received '", sr, "'")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
t = {["="] = _6_, ["ok?"] = _7_, ["pr="] = _8_}
|
|
||||||
local _9_, _10_ = nil, nil
|
|
||||||
local function _11_()
|
|
||||||
return f(t)
|
|
||||||
end
|
|
||||||
_9_, _10_ = pcall(_11_)
|
|
||||||
if ((_9_ == false) and (nil ~= _10_)) then
|
|
||||||
local err = _10_
|
|
||||||
fail("Exception: ", err)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not test_failed then
|
|
||||||
a.update(results, "tests-passed", a.inc)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return display_results(results, ("[" .. mod_name .. "]"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
v_0_0 = run0
|
|
||||||
_0_["run"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["run"] = v_0_
|
|
||||||
run = v_0_
|
|
||||||
end
|
end
|
||||||
local run_all
|
_2amodule_2a["ok?"] = ok_3f
|
||||||
do
|
local function display_results(results, prefix)
|
||||||
local v_0_
|
|
||||||
do
|
do
|
||||||
local v_0_0
|
local _let_3_ = results
|
||||||
local function run_all0()
|
local tests = _let_3_["tests"]
|
||||||
local function _3_(totals, results)
|
local tests_passed = _let_3_["tests-passed"]
|
||||||
for k, v in pairs(results) do
|
local assertions = _let_3_["assertions"]
|
||||||
totals[k] = (v + totals[k])
|
local assertions_passed = _let_3_["assertions-passed"]
|
||||||
end
|
local function _4_()
|
||||||
return totals
|
if ok_3f(results) then
|
||||||
end
|
return "OK"
|
||||||
return display_results(a.reduce(_3_, {["assertions-passed"] = 0, ["tests-passed"] = 0, assertions = 0, tests = 0}, a.filter(a["table?"], a.map(run, a.keys(package.loaded)))), "[total]")
|
|
||||||
end
|
|
||||||
v_0_0 = run_all0
|
|
||||||
_0_["run-all"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["run-all"] = v_0_
|
|
||||||
run_all = v_0_
|
|
||||||
end
|
|
||||||
local suite
|
|
||||||
do
|
|
||||||
local v_0_
|
|
||||||
do
|
|
||||||
local v_0_0
|
|
||||||
local function suite0()
|
|
||||||
do
|
|
||||||
local sep = fs["path-sep"]
|
|
||||||
local function _3_(path)
|
|
||||||
return require(string.gsub(string.match(path, ("^test" .. sep .. "fnl" .. sep .. "(.-).fnl$")), sep, "."))
|
|
||||||
end
|
|
||||||
a["run!"](_3_, nvim.fn.globpath(("test" .. sep .. "fnl"), "**/*-test.fnl", false, true))
|
|
||||||
end
|
|
||||||
if ok_3f(run_all()) then
|
|
||||||
return nvim.ex.q()
|
|
||||||
else
|
else
|
||||||
return nvim.ex.cq()
|
return "FAILED"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
v_0_0 = suite0
|
a.println((prefix .. " " .. _4_() .. " " .. tests_passed .. "/" .. tests .. " tests and " .. assertions_passed .. "/" .. assertions .. " assertions passed"))
|
||||||
_0_["suite"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
end
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
return results
|
||||||
t_0_["suite"] = v_0_
|
|
||||||
suite = v_0_
|
|
||||||
end
|
end
|
||||||
return nil
|
_2amodule_2a["display-results"] = display_results
|
||||||
|
local function run(mod_name)
|
||||||
|
local mod = _G.package.loaded[mod_name]
|
||||||
|
local tests = (a["table?"](mod) and mod["aniseed/tests"])
|
||||||
|
if a["table?"](tests) then
|
||||||
|
local results = {tests = #tests, ["tests-passed"] = 0, assertions = 0, ["assertions-passed"] = 0}
|
||||||
|
for label, f in pairs(tests) do
|
||||||
|
local test_failed = false
|
||||||
|
a.update(results, "tests", a.inc)
|
||||||
|
do
|
||||||
|
local prefix = ("[" .. mod_name .. "/" .. label .. "]")
|
||||||
|
local fail
|
||||||
|
local function _5_(desc, ...)
|
||||||
|
test_failed = true
|
||||||
|
local function _6_(...)
|
||||||
|
if desc then
|
||||||
|
return (" (" .. desc .. ")")
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return a.println((str.join({prefix, " ", ...}) .. _6_(...)))
|
||||||
|
end
|
||||||
|
fail = _5_
|
||||||
|
local begin
|
||||||
|
local function _7_()
|
||||||
|
return a.update(results, "assertions", a.inc)
|
||||||
|
end
|
||||||
|
begin = _7_
|
||||||
|
local pass
|
||||||
|
local function _8_()
|
||||||
|
return a.update(results, "assertions-passed", a.inc)
|
||||||
|
end
|
||||||
|
pass = _8_
|
||||||
|
local t
|
||||||
|
local function _9_(e, r, desc)
|
||||||
|
begin()
|
||||||
|
if (e == r) then
|
||||||
|
return pass()
|
||||||
|
else
|
||||||
|
return fail(desc, "Expected '", a["pr-str"](e), "' but received '", a["pr-str"](r), "'")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function _11_(e, r, desc)
|
||||||
|
begin()
|
||||||
|
local se = a["pr-str"](e)
|
||||||
|
local sr = a["pr-str"](r)
|
||||||
|
if (se == sr) then
|
||||||
|
return pass()
|
||||||
|
else
|
||||||
|
return fail(desc, "Expected (with pr) '", se, "' but received '", sr, "'")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function _13_(r, desc)
|
||||||
|
begin()
|
||||||
|
if r then
|
||||||
|
return pass()
|
||||||
|
else
|
||||||
|
return fail(desc, "Expected truthy result but received '", a["pr-str"](r), "'")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
t = {["="] = _9_, ["pr="] = _11_, ["ok?"] = _13_}
|
||||||
|
local _15_, _16_ = nil, nil
|
||||||
|
local function _17_()
|
||||||
|
return f(t)
|
||||||
|
end
|
||||||
|
_15_, _16_ = pcall(_17_)
|
||||||
|
if ((_15_ == false) and (nil ~= _16_)) then
|
||||||
|
local err = _16_
|
||||||
|
fail("Exception: ", err)
|
||||||
|
else
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not test_failed then
|
||||||
|
a.update(results, "tests-passed", a.inc)
|
||||||
|
else
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return display_results(results, ("[" .. mod_name .. "]"))
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_2amodule_2a["run"] = run
|
||||||
|
local function run_all()
|
||||||
|
local function _21_(totals, results)
|
||||||
|
for k, v in pairs(results) do
|
||||||
|
totals[k] = (v + totals[k])
|
||||||
|
end
|
||||||
|
return totals
|
||||||
|
end
|
||||||
|
return display_results(a.reduce(_21_, {tests = 0, ["tests-passed"] = 0, assertions = 0, ["assertions-passed"] = 0}, a.filter(a["table?"], a.map(run, a.keys(_G.package.loaded)))), "[total]")
|
||||||
|
end
|
||||||
|
_2amodule_2a["run-all"] = run_all
|
||||||
|
local function suite()
|
||||||
|
do
|
||||||
|
local sep = fs["path-sep"]
|
||||||
|
local function _22_(path)
|
||||||
|
return require(string.gsub(string.match(path, ("^test" .. sep .. "fnl" .. sep .. "(.-).fnl$")), sep, "."))
|
||||||
|
end
|
||||||
|
a["run!"](_22_, nvim.fn.globpath(("test" .. sep .. "fnl"), "**/*-test.fnl", false, true))
|
||||||
|
end
|
||||||
|
if ok_3f(run_all()) then
|
||||||
|
return nvim.ex.q()
|
||||||
|
else
|
||||||
|
return nvim.ex.cq()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_2amodule_2a["suite"] = suite
|
||||||
|
return _2amodule_2a
|
||||||
|
@ -1,58 +1,19 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/view.fnl"
|
local _2afile_2a = "fnl/aniseed/view.fnl"
|
||||||
local _0_
|
|
||||||
do
|
|
||||||
local name_0_ = "conjure-macroexpand.aniseed.view"
|
|
||||||
local module_0_
|
|
||||||
do
|
|
||||||
local x_0_ = package.loaded[name_0_]
|
|
||||||
if ("table" == type(x_0_)) then
|
|
||||||
module_0_ = x_0_
|
|
||||||
else
|
|
||||||
module_0_ = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module_0_["aniseed/module"] = name_0_
|
|
||||||
module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {})
|
|
||||||
do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {})
|
|
||||||
do end (package.loaded)[name_0_] = module_0_
|
|
||||||
_0_ = module_0_
|
|
||||||
end
|
|
||||||
local autoload
|
|
||||||
local function _1_(...)
|
|
||||||
return (require("conjure-macroexpand.aniseed.autoload")).autoload(...)
|
|
||||||
end
|
|
||||||
autoload = _1_
|
|
||||||
local function _2_(...)
|
|
||||||
local ok_3f_0_, val_0_ = nil, nil
|
|
||||||
local function _2_()
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
ok_3f_0_, val_0_ = pcall(_2_)
|
|
||||||
if ok_3f_0_ then
|
|
||||||
_0_["aniseed/local-fns"] = {}
|
|
||||||
return val_0_
|
|
||||||
else
|
|
||||||
return print(val_0_)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local _local_0_ = _2_(...)
|
|
||||||
local _2amodule_2a = _0_
|
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.view"
|
local _2amodule_name_2a = "conjure-macroexpand.aniseed.view"
|
||||||
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end
|
local _2amodule_2a
|
||||||
local serialise
|
|
||||||
do
|
do
|
||||||
local v_0_
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
do
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
local v_0_0
|
|
||||||
local function _3_(...)
|
|
||||||
return require("conjure-macroexpand.aniseed.deps.fennelview")(...)
|
|
||||||
end
|
|
||||||
v_0_0 = _3_
|
|
||||||
_0_["serialise"] = v_0_0
|
|
||||||
v_0_ = v_0_0
|
|
||||||
end
|
|
||||||
local t_0_ = (_0_)["aniseed/locals"]
|
|
||||||
t_0_["serialise"] = v_0_
|
|
||||||
serialise = v_0_
|
|
||||||
end
|
end
|
||||||
return nil
|
local _2amodule_locals_2a
|
||||||
|
do
|
||||||
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
|
end
|
||||||
|
local fnl = require("conjure-macroexpand.aniseed.fennel")
|
||||||
|
do end (_2amodule_locals_2a)["fnl"] = fnl
|
||||||
|
local function serialise(...)
|
||||||
|
return fnl.impl().view(...)
|
||||||
|
end
|
||||||
|
_2amodule_2a["serialise"] = serialise
|
||||||
|
return _2amodule_2a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user