Update aniseed

This commit is contained in:
Walter Leibbrandt 2022-10-07 02:35:32 +02:00
parent f83cf568af
commit d9e70aa52e
17 changed files with 5046 additions and 4039 deletions

View File

@ -1,50 +1,16 @@
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] = {}
_2amodule_2a = package.loaded[_2amodule_name_2a]
end
local _2amodule_locals_2a
do do
local v_0_0 _2amodule_2a["aniseed/locals"] = {}
local function autoload1(name) _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
end
local function autoload(name)
local res = {["aniseed/autoload-enabled?"] = true, ["aniseed/autoload-module"] = false} local res = {["aniseed/autoload-enabled?"] = true, ["aniseed/autoload-module"] = false}
local function ensure() local function ensure()
if res["aniseed/autoload-module"] then if res["aniseed/autoload-module"] then
@ -55,24 +21,17 @@ do
return m return m
end end
end end
local function _3_(t, ...) local function _2_(t, ...)
return ensure()(...) return ensure()(...)
end end
local function _4_(t, k) local function _3_(t, k)
return ensure()[k] return ensure()[k]
end end
local function _5_(t, k, v) local function _4_(t, k, v)
ensure()[k] = v ensure()[k] = v
return nil return nil
end end
return setmetatable(res, {__call = _3_, __index = _4_, __newindex = _5_}) return setmetatable(res, {__call = _2_, __index = _3_, __newindex = _4_})
end end
v_0_0 = autoload1 _2amodule_2a["autoload"] = autoload
_0_["autoload"] = v_0_0 return _2amodule_2a
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["autoload"] = v_0_
autoload0 = v_0_
end
return nil

View File

@ -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] = {}
_2amodule_2a = package.loaded[_2amodule_name_2a]
end
local _2amodule_locals_2a
do do
local v_0_0 _2amodule_2a["aniseed/locals"] = {}
local function macros_prefix0(code, opts) _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
end
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
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")
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 macros_module = "conjure-macroexpand.aniseed.macros"
local filename local filename
do do
local _3_ = a.get(opts, "filename") local _1_ = a.get(opts, "filename")
if _3_ then if (nil ~= _1_) then
filename = string.gsub(_3_, (nvim.fn.getcwd() .. fs["path-sep"]), "") filename = string.gsub(_1_, (nvim.fn.getcwd() .. fs["path-sep"]), "")
else else
filename = _3_ filename = _1_
end end
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
local str
do
local v_0_
do
local v_0_0
local function str0(code, opts)
local fnl = fennel.impl()
local function _3_() local function _3_()
return fnl.compileString(macros_prefix(code, opts), a.merge({allowedGlobals = false}, opts)) if filename then
return ("\"" .. string.gsub(filename, "\\", "\\\\") .. "\"")
else
return "nil"
end end
return xpcall(_3_, fnl.traceback)
end end
v_0_0 = str0 return ("(local *file* " .. _3_() .. ")" .. "(require-macros \"" .. macros_module .. "\")\n" .. "(wrap-module-body " .. (code or "") .. ")")
_0_["str"] = v_0_0
v_0_ = v_0_0
end end
local t_0_ = (_0_)["aniseed/locals"] _2amodule_2a["wrap-macros"] = wrap_macros
t_0_["str"] = v_0_ local marker_prefix = "ANISEED_"
str = v_0_ _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 end
local file return xpcall(_4_, fnl.traceback)
do end
local v_0_ _2amodule_2a["str"] = str
do local function file(src, dest, opts)
local v_0_0
local function file0(src, dest)
local code = a.slurp(src) local code = a.slurp(src)
local _3_, _4_ = str(code, {filename = src}) local _5_, _6_ = str(code, a["merge!"]({filename = src, ["static?"] = true}, opts))
if ((_3_ == false) and (nil ~= _4_)) then if ((_5_ == false) and (nil ~= _6_)) then
local err = _4_ local err = _6_
return nvim.err_writeln(err) return nvim.err_writeln(err)
elseif ((_3_ == true) and (nil ~= _4_)) then elseif ((_5_ == true) and (nil ~= _6_)) then
local result = _4_ local result = _6_
fs.mkdirp(fs.basename(dest)) fs.mkdirp(fs.basename(dest))
return a.spit(dest, result) return a.spit(dest, result)
else
return nil
end end
end end
v_0_0 = file0 _2amodule_2a["file"] = file
_0_["file"] = v_0_0 local function glob(src_expr, src_dir, dest_dir, opts)
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["file"] = v_0_
file = v_0_
end
local glob
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 for _, path in ipairs(fs.relglob(src_dir, src_expr)) do
if fs["macro-file-path?"](path) then if fs["macro-file-path?"](path) then
a.spit((dest_dir .. path), a.slurp((src_dir .. path))) local dest = (dest_dir .. path)
fs.mkdirp(fs.basename(dest))
a.spit(dest, a.slurp((src_dir .. path)))
else else
file((src_dir .. path), string.gsub((dest_dir .. path), ".fnl$", ".lua")) file((src_dir .. path), string.gsub((dest_dir .. path), ".fnl$", ".lua"), opts)
end end
end end
return nil return nil
end end
v_0_0 = glob0 _2amodule_2a["glob"] = glob
_0_["glob"] = v_0_0 return _2amodule_2a
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["glob"] = v_0_
glob = v_0_
end
return nil

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -1,79 +1,37 @@
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"]
end
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
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")
do end (_2amodule_locals_2a)["compile"] = compile
_2amodule_locals_2a["fennel"] = fennel
_2amodule_locals_2a["fs"] = fs
_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 ok_3f, err = nil, nil
local function _3_() local function _1_()
return require(m) return require(m)
end end
ok_3f, err = pcall(_3_) ok_3f, err = pcall(_1_)
if (not ok_3f and not err:find(("module '" .. m .. "' not found"))) then if (not ok_3f and not err:find(("module '" .. m .. "' not found"))) then
return nvim.ex.echoerr(err) return nvim.ex.echoerr(err)
else
return nil
end end
end end
v_0_ = quiet_require0 _2amodule_locals_2a["quiet-require"] = quiet_require
local t_0_ = (_0_)["aniseed/locals"] local function init(opts)
t_0_["quiet-require"] = v_0_
quiet_require = v_0_
end
local init
do
local v_0_
do
local v_0_0
local function init0(opts)
local opts0 local opts0
if ("table" == type(opts)) then if ("table" == type(opts)) then
opts0 = opts opts0 = opts
@ -81,28 +39,25 @@ do
opts0 = {} opts0 = {}
end end
local glob_expr = "**/*.fnl" local glob_expr = "**/*.fnl"
local fnl_dir = (opts0.input or (config_dir .. fs["path-sep"] .. "fnl")) local fnl_dir = nvim.fn.expand((opts0.input or (config_dir .. fs["path-sep"] .. "fnl")))
local lua_dir = (opts0.output or (config_dir .. fs["path-sep"] .. "lua")) 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") package.path = (package.path .. ";" .. lua_dir .. fs["path-sep"] .. "?.lua")
local function _4_(path) else
end
local function _5_(path)
if fs["macro-file-path?"](path) then if fs["macro-file-path?"](path) then
return path return path
else else
return string.gsub(path, ".fnl$", ".lua") return string.gsub(path, ".fnl$", ".lua")
end end
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 if (((false ~= opts0.compile) or os.getenv("ANISEED_ENV_COMPILE")) and fs["glob-dir-newer?"](fnl_dir, lua_dir, glob_expr, _5_)) then
fennel["add-path"]((fnl_dir .. fs["path-sep"] .. "?.fnl")) fennel["add-path"]((fnl_dir .. fs["path-sep"] .. "?.fnl"))
compile.glob(glob_expr, fnl_dir, lua_dir, opts0) compile.glob(glob_expr, fnl_dir, lua_dir, opts0)
else
end end
return quiet_require((opts0.module or "init")) return quiet_require((opts0.module or "init"))
end end
v_0_0 = init0 _2amodule_2a["init"] = init
_0_["init"] = v_0_0 return _2amodule_2a
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["init"] = v_0_
init = v_0_
end
return nil

View File

@ -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] = {}
_2amodule_2a = package.loaded[_2amodule_name_2a]
end
local _2amodule_locals_2a
do do
local v_0_0 _2amodule_2a["aniseed/locals"] = {}
local function str0(code, opts) _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 fnl = fennel.impl()
local function _3_() local function _1_()
return fnl.eval(compile["macros-prefix"](code, opts), a.merge({["compiler-env"] = _G}, opts)) return fnl.eval(compile["wrap-macros"](code, opts), a.merge({compilerEnv = _G}, opts))
end end
return xpcall(_3_, fnl.traceback) return xpcall(_1_, fnl.traceback)
end end
v_0_0 = str0 _2amodule_2a["str"] = str
_0_["str"] = v_0_0 local function clean_values(vals)
v_0_ = v_0_0 local function _2_(val)
if a["table?"](val) then
return (compile["delete-marker"] ~= a.first(val))
else
return true
end end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["str"] = v_0_
str = v_0_
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 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

View File

@ -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] = {}
_2amodule_2a = package.loaded[_2amodule_name_2a]
end
local _2amodule_locals_2a
do do
local v_0_0 _2amodule_2a["aniseed/locals"] = {}
local function sync_rtp0(compiler) _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
local sep = fs["path-sep"] end
local fnl_suffix = (sep .. "fnl" .. sep .. "?.fnl") local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
local rtp = nvim.o.runtimepath 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 fnl_path = (rtp:gsub(",", (fnl_suffix .. ";")) .. fnl_suffix) do end (_2amodule_locals_2a)["a"] = a
local lua_path = fnl_path:gsub((sep .. "fnl" .. sep), (sep .. "lua" .. sep)) _2amodule_locals_2a["fs"] = fs
do end (compiler)["path"] = (fnl_path .. ";" .. lua_path) _2amodule_locals_2a["nvim"] = nvim
_2amodule_locals_2a["str"] = str
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
fnl_paths = a.map(_1_, rtps)
local lua_paths
local function _2_(_241)
return (_241 .. lua_suffix)
end
lua_paths = a.map(_2_, rtps)
do end (compiler)["macro-path"] = str.join(";", a.concat(fnl_paths, lua_paths))
return nil return nil
end end
v_0_0 = sync_rtp0 _2amodule_2a["sync-rtp"] = sync_rtp
_0_["sync-rtp"] = v_0_0 local state = {["compiler-loaded?"] = false}
v_0_ = v_0_0 _2amodule_locals_2a["state"] = state
end local function impl()
local t_0_ = (_0_)["aniseed/locals"]
t_0_["sync-rtp"] = v_0_
sync_rtp = v_0_
end
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") local compiler = require("conjure-macroexpand.aniseed.deps.fennel")
if not state["compiler-loaded?"] then if not state["compiler-loaded?"] then
state["compiler-loaded?"] = true state["compiler-loaded?"] = true
sync_rtp(compiler) sync_rtp(compiler)
else
end end
return compiler return compiler
end end
v_0_0 = impl0 _2amodule_2a["impl"] = impl
_0_["impl"] = v_0_0 local function add_path(path)
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["impl"] = v_0_
impl = v_0_
end
local add_path
do
local v_0_
do
local v_0_0
local function add_path0(path)
local fnl = impl() local fnl = impl()
do end (fnl)["path"] = (fnl.path .. ";" .. path) do end (fnl)["macro-path"] = (fnl["macro-path"] .. ";" .. path)
return nil return nil
end end
v_0_0 = add_path0 _2amodule_2a["add-path"] = add_path
_0_["add-path"] = v_0_0 return _2amodule_2a
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["add-path"] = v_0_
add_path = v_0_
end
return nil

View File

@ -1,154 +1,58 @@
local _2afile_2a = "fnl/aniseed/fs.fnl" local _2afile_2a = "fnl/aniseed/fs.fnl"
local _0_
do
local name_0_ = "conjure-macroexpand.aniseed.fs"
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.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" local _2amodule_name_2a = "conjure-macroexpand.aniseed.fs"
do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end local _2amodule_2a
local path_sep
do do
local v_0_ package.loaded[_2amodule_name_2a] = {}
do _2amodule_2a = package.loaded[_2amodule_name_2a]
local v_0_0
do
local os = string.lower(jit.os)
if (("linux" == os) or ("osx" == os) or ("bsd" == os)) then
v_0_0 = "/"
else
v_0_0 = "\\"
end end
end local _2amodule_locals_2a
_0_["path-sep"] = v_0_0
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["path-sep"] = v_0_
path_sep = v_0_
end
local basename
do do
local v_0_ _2amodule_2a["aniseed/locals"] = {}
do _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
local v_0_0 end
local function basename0(path) 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") return nvim.fn.fnamemodify(path, ":h")
end end
v_0_0 = basename0 _2amodule_2a["basename"] = basename
_0_["basename"] = v_0_0 local function mkdirp(dir)
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") return nvim.fn.mkdir(dir, "p")
end end
v_0_0 = mkdirp0 _2amodule_2a["mkdirp"] = mkdirp
_0_["mkdirp"] = v_0_0 local function relglob(dir, expr)
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 dir_len = a.inc(string.len(dir))
local function _3_(_241) local function _1_(_241)
return string.sub(_241, dir_len) return string.sub(_241, dir_len)
end end
return a.map(_3_, nvim.fn.globpath(dir, expr, true, true)) return a.map(_1_, nvim.fn.globpath(dir, expr, true, true))
end end
v_0_0 = relglob0 _2amodule_2a["relglob"] = relglob
_0_["relglob"] = v_0_0 local function glob_dir_newer_3f(a_dir, b_dir, expr, b_dir_path_fn)
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 local newer_3f = false
for _, path in ipairs(relglob(a_dir, expr)) do 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 if (nvim.fn.getftime((a_dir .. path)) > nvim.fn.getftime((b_dir .. b_dir_path_fn(path)))) then
newer_3f = true newer_3f = true
else
end end
end end
return newer_3f return newer_3f
end end
v_0_0 = glob_dir_newer_3f0 _2amodule_2a["glob-dir-newer?"] = glob_dir_newer_3f
_0_["glob-dir-newer?"] = v_0_0 local function macro_file_path_3f(path)
v_0_ = v_0_0 return a["string?"](string.match(path, "macros?.fnl$"))
end end
local t_0_ = (_0_)["aniseed/locals"] _2amodule_2a["macro-file-path?"] = macro_file_path_3f
t_0_["glob-dir-newer?"] = v_0_ local path_sep
glob_dir_newer_3f = v_0_
end
local macro_file_path_3f
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 = "/"
local function macro_file_path_3f0(path) else
return string.match(path, "macros.fnl$") path_sep = "\\"
end end
v_0_0 = macro_file_path_3f0
_0_["macro-file-path?"] = v_0_0
v_0_ = v_0_0
end end
local t_0_ = (_0_)["aniseed/locals"] _2amodule_2a["path-sep"] = path_sep
t_0_["macro-file-path?"] = v_0_ return _2amodule_2a
macro_file_path_3f = v_0_
end
return nil

View File

@ -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))
;; Meta! Autoload the autoload function, so it's only loaded when used. (sym x)
(local ,(sym :autoload)
(fn [...] ((. (require :aniseed.autoload) :autoload) ...)))
,(let [aliases []
vals []
effects []
pkg (let [x (. package.loaded (tostring name))]
(when (= :table (type x))
x)) x))
locals (-?> pkg (. :aniseed/locals))
local-fns (or (and (not new-local-fns)
(?. pkg :aniseed/local-fns))
{})]
(when new-local-fns ;; This marker can be used by a post-processor to delete a useless byproduct line.
(each [action binds (pairs new-local-fns)] (local delete-marker :ANISEED_DELETE_ME)
(let [action-str (tostring action)
current (or (. local-fns action-str) {})]
(tset local-fns action-str current)
(each [alias module (pairs binds)]
(if (= :number (type alias))
(tset current (tostring module) true)
(tset current (tostring alias) (tostring module)))))))
;; We store all locals under this for later splatting.
(local locals-key :aniseed/locals)
;; Various symbols we want to use multiple times.
;; Avoids the compiler complaining that we're introducing locals without gensym.
(local mod-name-sym (sym :*module-name*))
(local mod-sym (sym :*module*))
(local mod-locals-sym (sym :*module-locals*))
(local autoload-sym (sym :autoload))
;; Upserts the existence of the module for subsequent def forms and expands the
;; bound function calls into the current context.
;;
;; On subsequent interactive calls it will expand the existing module into your
;; 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))
;; Determine if we're in an interactive eval or not.
;; We don't count userdata / other types as an existing module since we
;; can't really work with anything other than a table. If it's not a
;; table it's probably not a module Aniseed can work with in general
;; since it's assumed all Aniseed modules are table based.
;; We can also completely disable the interactive mode which is used by
;; `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))
;; The final result table that gets returned from the macro.
;; This is the best way I've found to introduce many (local ...) forms from one macro.
result `[,delete-marker
;; We can't refer to things like (local (foo bar) (10 foo)).
;; So we need to define them in an earlier local.
(local ,mod-name-sym ,(tostring mod-name))
;; Only expose the module table if it doesn't exist yet.
(local ,mod-sym ,(if interactive?
`(. package.loaded ,mod-name-sym)
`(do
(tset package.loaded ,mod-name-sym ,(or mod-base {}))
(. package.loaded ,mod-name-sym))))
;; As we def values we insert them into locals.
;; 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 (sorted-each
(fn [action binds] (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 (sorted-each
(fn [alias-or-val val] (fn [bind arg]
(if (= true val) (=> (ensure-sym bind) `(,mod-fn ,(tostring arg))))
args)))
mod-fns)
;; {require-macros [bar]} ;; Only require autoload if it's used.
(table.insert effects `(,(sym action) ,alias-or-val)) (when (contains? mod-fns autoload-sym)
(table.insert result `(local ,autoload-sym (. (require "conjure-macroexpand.aniseed.autoload") :autoload)))))
;; {require {foo bar}} ;; When we have some keys insert the key/vals pairs locals.
(do ;; If this is empty we end up generating invalid Lua.
(table.insert aliases (sym alias-or-val)) (when (seq? keys)
(table.insert vals `(,(sym action) ,val))))) (table.insert result `(local ,(list (unpack keys)) (values ,(unpack vals))))
binds)) ;; We also bind these exposed locals into *module-locals* for future splatting.
local-fns) (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))
(when locals ;; 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 (sorted-each
(fn [alias val] (fn [k v]
(table.insert aliases (sym alias)) (table.insert
(table.insert vals `(. ,module-sym :aniseed/locals ,alias))) result
locals)) `(tset ,mod-locals-sym ,(tostring k) ,v)))
k))))
`[,effects ;; Now we can expand any existing locals into the current scope.
(local ,aliases ;; Since this will only happen in interactive evals we can generate messy code.
(let [(ok?# val#) (when interactive?
(pcall ;; Expand exported values into the current scope, except aniseed/locals.
(fn [] ,vals))] (sorted-each
(if ok?# (fn [k v]
(do (when (not= k locals-key)
(tset ,module-sym :aniseed/local-fns ,local-fns) (table.insert result `(local ,(sym k) (. ,mod-sym ,k)))))
val#) existing-mod)
(print val#))))
(local ,(sym "*module*") ,module-sym) ;; Expand locals into the current scope.
(local ,(sym "*module-name*") ,(tostring name))])] (when (. existing-mod locals-key)
(. 2))) (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}

View File

@ -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

View File

@ -1,104 +1,51 @@
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] = {}
_2amodule_2a = package.loaded[_2amodule_name_2a]
end
local _2amodule_locals_2a
do do
local v_0_0 _2amodule_2a["aniseed/locals"] = {}
local function normal0(keys) _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
end
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
local nvim = autoload("conjure-macroexpand.aniseed.nvim")
do end (_2amodule_locals_2a)["nvim"] = nvim
local function normal(keys)
return nvim.ex.silent(("exe \"normal! " .. keys .. "\"")) return nvim.ex.silent(("exe \"normal! " .. keys .. "\""))
end end
v_0_0 = normal0 _2amodule_2a["normal"] = normal
_0_["normal"] = v_0_0 local function fn_bridge(viml_name, mod, lua_name, opts)
v_0_ = v_0_0 local _let_1_ = (opts or {})
end local range = _let_1_["range"]
local t_0_ = (_0_)["aniseed/locals"] local _return = _let_1_["return"]
t_0_["normal"] = v_0_ local function _2_()
normal = v_0_
end
local fn_bridge
do
local v_0_
do
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 if range then
_3_ = " range" return " range"
else else
_3_ = "" return ""
end end
local _5_ end
local function _3_()
if (_return ~= false) then if (_return ~= false) then
_5_ = "return" return "return"
else else
_5_ = "call" return "call"
end end
local _7_ end
local function _4_()
if range then if range then
_7_ = "\" . a:firstline . \", \" . a:lastline . \", " return "\" . a:firstline . \", \" . a:lastline . \", "
else else
_7_ = "" return ""
end end
return nvim.ex.function_((viml_name .. "(...)" .. _3_ .. "\n " .. _5_ .. " luaeval(\"require('" .. mod .. "')['" .. lua_name .. "'](" .. _7_ .. "unpack(_A))\", a:000)\n endfunction"))
end end
v_0_0 = fn_bridge0 return nvim.ex.function_((viml_name .. "(...)" .. _2_() .. "\n " .. _3_() .. " luaeval(\"require('" .. mod .. "')['" .. lua_name .. "'](" .. _4_() .. "unpack(_A))\", a:000)\n endfunction"))
_0_["fn-bridge"] = v_0_0
v_0_ = v_0_0
end end
local t_0_ = (_0_)["aniseed/locals"] _2amodule_2a["fn-bridge"] = fn_bridge
t_0_["fn-bridge"] = v_0_ local function with_out_str(f)
fn_bridge = v_0_
end
local with_out_str
do
local v_0_
do
local v_0_0
local function with_out_str0(f)
nvim.ex.redir("=> g:aniseed_nvim_util_out_str") nvim.ex.redir("=> g:aniseed_nvim_util_out_str")
do do
local ok_3f, err = pcall(f) local ok_3f, err = pcall(f)
@ -107,16 +54,10 @@ do
nvim.ex.redraw() nvim.ex.redraw()
if not ok_3f then if not ok_3f then
error(err) error(err)
else
end end
end end
return string.gsub(nvim.g.aniseed_nvim_util_out_str, "^(\n?)(.*)$", "%2%1") return string.gsub(nvim.g.aniseed_nvim_util_out_str, "^(\n?)(.*)$", "%2%1")
end end
v_0_0 = with_out_str0 _2amodule_2a["with-out-str"] = with_out_str
_0_["with-out-str"] = v_0_0 return _2amodule_2a
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
return nil

View 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

View File

@ -1,97 +1,54 @@
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] = {}
_2amodule_2a = package.loaded[_2amodule_name_2a]
end
local _2amodule_locals_2a
do do
local v_0_0 _2amodule_2a["aniseed/locals"] = {}
local function join0(...) _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
end
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
local a = autoload("conjure-macroexpand.aniseed.core")
do end (_2amodule_locals_2a)["a"] = a
local function join(...)
local args = {...} local args = {...}
local function _3_(...) local function _2_(...)
if (2 == a.count(args)) then if (2 == a.count(args)) then
return args return args
else else
return {"", a.first(args)} return {"", a.first(args)}
end end
end end
local _let_0_ = _3_(...) local _let_1_ = _2_(...)
local sep = _let_0_[1] local sep = _let_1_[1]
local xs = _let_0_[2] local xs = _let_1_[2]
local len = a.count(xs) local len = a.count(xs)
local result = {} local result = {}
if (len > 0) then if (len > 0) then
for i = 1, len do for i = 1, len do
local x = xs[i] local x = xs[i]
local _4_ local _3_
if ("string" == type(x)) then if ("string" == type(x)) then
_4_ = x _3_ = x
elseif (nil == x) then elseif (nil == x) then
_4_ = x _3_ = x
else else
_4_ = a["pr-str"](x) _3_ = a["pr-str"](x)
end end
if _4_ then if (_3_ ~= nil) then
table.insert(result, _4_) table.insert(result, _3_)
else else
end end
end end
else
end end
return table.concat(result, sep) return table.concat(result, sep)
end end
v_0_0 = join0 _2amodule_2a["join"] = join
_0_["join"] = v_0_0 local function split(s, pat)
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["join"] = v_0_
join = v_0_
end
local split
do
local v_0_
do
local v_0_0
local function split0(s, pat)
local done_3f = false local done_3f = false
local acc = {} local acc = {}
local index = 1 local index = 1
@ -107,76 +64,21 @@ do
end end
return acc return acc
end end
v_0_0 = split0 _2amodule_2a["split"] = split
_0_["split"] = v_0_0 local function blank_3f(s)
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["split"] = v_0_
split = v_0_
end
local blank_3f
do
local v_0_
do
local v_0_0
local function blank_3f0(s)
return (a["empty?"](s) or not string.find(s, "[^%s]")) return (a["empty?"](s) or not string.find(s, "[^%s]"))
end end
v_0_0 = blank_3f0 _2amodule_2a["blank?"] = blank_3f
_0_["blank?"] = v_0_0 local function triml(s)
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["blank?"] = v_0_
blank_3f = v_0_
end
local triml
do
local v_0_
do
local v_0_0
local function triml0(s)
return string.gsub(s, "^%s*(.-)", "%1") return string.gsub(s, "^%s*(.-)", "%1")
end end
v_0_0 = triml0 _2amodule_2a["triml"] = triml
_0_["triml"] = v_0_0 local function trimr(s)
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["triml"] = v_0_
triml = v_0_
end
local trimr
do
local v_0_
do
local v_0_0
local function trimr0(s)
return string.gsub(s, "(.-)%s*$", "%1") return string.gsub(s, "(.-)%s*$", "%1")
end end
v_0_0 = trimr0 _2amodule_2a["trimr"] = trimr
_0_["trimr"] = v_0_0 local function trim(s)
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["trimr"] = v_0_
trimr = v_0_
end
local trim
do
local v_0_
do
local v_0_0
local function trim0(s)
return string.gsub(s, "^%s*(.-)%s*$", "%1") return string.gsub(s, "^%s*(.-)%s*$", "%1")
end end
v_0_0 = trim0 _2amodule_2a["trim"] = trim
_0_["trim"] = v_0_0 return _2amodule_2a
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["trim"] = v_0_
trim = v_0_
end
return nil

View File

@ -1,137 +1,82 @@
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] = {}
_2amodule_2a = package.loaded[_2amodule_name_2a]
end
local _2amodule_locals_2a
do do
local v_0_0 _2amodule_2a["aniseed/locals"] = {}
local function ok_3f0(_3_) _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
local _arg_0_ = _3_ end
local tests = _arg_0_["tests"] local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
local tests_passed = _arg_0_["tests-passed"] 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")
do end (_2amodule_locals_2a)["a"] = a
_2amodule_locals_2a["fs"] = fs
_2amodule_locals_2a["nvim"] = nvim
_2amodule_locals_2a["str"] = str
local function ok_3f(_1_)
local _arg_2_ = _1_
local tests = _arg_2_["tests"]
local tests_passed = _arg_2_["tests-passed"]
return (tests == tests_passed) return (tests == tests_passed)
end end
v_0_0 = ok_3f0 _2amodule_2a["ok?"] = ok_3f
_0_["ok?"] = v_0_0 local function display_results(results, prefix)
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["ok?"] = v_0_
ok_3f = v_0_
end
local display_results
do do
local v_0_ local _let_3_ = results
do local tests = _let_3_["tests"]
local v_0_0 local tests_passed = _let_3_["tests-passed"]
local function display_results0(results, prefix) local assertions = _let_3_["assertions"]
do local assertions_passed = _let_3_["assertions-passed"]
local _let_0_ = results local function _4_()
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 if ok_3f(results) then
_3_ = "OK" return "OK"
else else
_3_ = "FAILED" return "FAILED"
end end
a.println((prefix .. " " .. _3_ .. " " .. tests_passed .. "/" .. tests .. " tests and " .. assertions_passed .. "/" .. assertions .. " assertions passed")) end
a.println((prefix .. " " .. _4_() .. " " .. tests_passed .. "/" .. tests .. " tests and " .. assertions_passed .. "/" .. assertions .. " assertions passed"))
end end
return results return results
end end
v_0_0 = display_results0 _2amodule_2a["display-results"] = display_results
_0_["display-results"] = v_0_0 local function run(mod_name)
v_0_ = v_0_0 local mod = _G.package.loaded[mod_name]
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["display-results"] = v_0_
display_results = v_0_
end
local run
do
local v_0_
do
local v_0_0
local function run0(mod_name)
local mod = package.loaded[mod_name]
local tests = (a["table?"](mod) and mod["aniseed/tests"]) local tests = (a["table?"](mod) and mod["aniseed/tests"])
if a["table?"](tests) then if a["table?"](tests) then
local results = {["assertions-passed"] = 0, ["tests-passed"] = 0, assertions = 0, tests = #tests} local results = {tests = #tests, ["tests-passed"] = 0, assertions = 0, ["assertions-passed"] = 0}
for label, f in pairs(tests) do for label, f in pairs(tests) do
local test_failed = false local test_failed = false
a.update(results, "tests", a.inc) a.update(results, "tests", a.inc)
do do
local prefix = ("[" .. mod_name .. "/" .. label .. "]") local prefix = ("[" .. mod_name .. "/" .. label .. "]")
local fail local fail
local function _3_(desc, ...) local function _5_(desc, ...)
test_failed = true test_failed = true
local function _4_(...) local function _6_(...)
if desc then if desc then
return (" (" .. desc .. ")") return (" (" .. desc .. ")")
else else
return "" return ""
end end
end end
return a.println((str.join({prefix, " ", ...}) .. _4_(...))) return a.println((str.join({prefix, " ", ...}) .. _6_(...)))
end end
fail = _3_ fail = _5_
local begin local begin
local function _4_() local function _7_()
return a.update(results, "assertions", a.inc) return a.update(results, "assertions", a.inc)
end end
begin = _4_ begin = _7_
local pass local pass
local function _5_() local function _8_()
return a.update(results, "assertions-passed", a.inc) return a.update(results, "assertions-passed", a.inc)
end end
pass = _5_ pass = _8_
local t local t
local function _6_(e, r, desc) local function _9_(e, r, desc)
begin() begin()
if (e == r) then if (e == r) then
return pass() return pass()
@ -139,15 +84,7 @@ do
return fail(desc, "Expected '", a["pr-str"](e), "' but received '", a["pr-str"](r), "'") return fail(desc, "Expected '", a["pr-str"](e), "' but received '", a["pr-str"](r), "'")
end end
end end
local function _7_(r, desc) local function _11_(e, 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() begin()
local se = a["pr-str"](e) local se = a["pr-str"](e)
local sr = a["pr-str"](r) local sr = a["pr-str"](r)
@ -157,66 +94,54 @@ do
return fail(desc, "Expected (with pr) '", se, "' but received '", sr, "'") return fail(desc, "Expected (with pr) '", se, "' but received '", sr, "'")
end end
end end
t = {["="] = _6_, ["ok?"] = _7_, ["pr="] = _8_} local function _13_(r, desc)
local _9_, _10_ = nil, nil begin()
local function _11_() 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) return f(t)
end end
_9_, _10_ = pcall(_11_) _15_, _16_ = pcall(_17_)
if ((_9_ == false) and (nil ~= _10_)) then if ((_15_ == false) and (nil ~= _16_)) then
local err = _10_ local err = _16_
fail("Exception: ", err) fail("Exception: ", err)
else
end end
end end
if not test_failed then if not test_failed then
a.update(results, "tests-passed", a.inc) a.update(results, "tests-passed", a.inc)
else
end end
end end
return display_results(results, ("[" .. mod_name .. "]")) return display_results(results, ("[" .. mod_name .. "]"))
else
return nil
end end
end end
v_0_0 = run0 _2amodule_2a["run"] = run
_0_["run"] = v_0_0 local function run_all()
v_0_ = v_0_0 local function _21_(totals, results)
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["run"] = v_0_
run = v_0_
end
local run_all
do
local v_0_
do
local v_0_0
local function run_all0()
local function _3_(totals, results)
for k, v in pairs(results) do for k, v in pairs(results) do
totals[k] = (v + totals[k]) totals[k] = (v + totals[k])
end end
return totals return totals
end end
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]") 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 end
v_0_0 = run_all0 _2amodule_2a["run-all"] = run_all
_0_["run-all"] = v_0_0 local function suite()
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 do
local sep = fs["path-sep"] local sep = fs["path-sep"]
local function _3_(path) local function _22_(path)
return require(string.gsub(string.match(path, ("^test" .. sep .. "fnl" .. sep .. "(.-).fnl$")), sep, ".")) return require(string.gsub(string.match(path, ("^test" .. sep .. "fnl" .. sep .. "(.-).fnl$")), sep, "."))
end end
a["run!"](_3_, nvim.fn.globpath(("test" .. sep .. "fnl"), "**/*-test.fnl", false, true)) a["run!"](_22_, nvim.fn.globpath(("test" .. sep .. "fnl"), "**/*-test.fnl", false, true))
end end
if ok_3f(run_all()) then if ok_3f(run_all()) then
return nvim.ex.q() return nvim.ex.q()
@ -224,12 +149,5 @@ do
return nvim.ex.cq() return nvim.ex.cq()
end end
end end
v_0_0 = suite0 _2amodule_2a["suite"] = suite
_0_["suite"] = v_0_0 return _2amodule_2a
v_0_ = v_0_0
end
local t_0_ = (_0_)["aniseed/locals"]
t_0_["suite"] = v_0_
suite = v_0_
end
return nil

View File

@ -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] = {}
_2amodule_2a = package.loaded[_2amodule_name_2a]
end
local _2amodule_locals_2a
do do
local v_0_0 _2amodule_2a["aniseed/locals"] = {}
local function _3_(...) _2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
return require("conjure-macroexpand.aniseed.deps.fennelview")(...)
end end
v_0_0 = _3_ local fnl = require("conjure-macroexpand.aniseed.fennel")
_0_["serialise"] = v_0_0 do end (_2amodule_locals_2a)["fnl"] = fnl
v_0_ = v_0_0 local function serialise(...)
return fnl.impl().view(...)
end end
local t_0_ = (_0_)["aniseed/locals"] _2amodule_2a["serialise"] = serialise
t_0_["serialise"] = v_0_ return _2amodule_2a
serialise = v_0_
end
return nil