Skip to content

Compilation Functions

Matt Kelly edited this page Oct 6, 2022 · 6 revisions
require("moonwalk").add_loader("fnl", function(src, path)
    -- Pass the path to compileString to get better stack traces
    return require("fennel").compileString(src, { filename = path })
end)
require("moonwalk").add_loader("tl", function(src, path)
    local tl = require("tl")
    local errs = {}
    local _, program = tl.parse_program(tl.lex(src), errs)
    if #errs > 0 then
        error(path .. ":" .. errs[1].y .. ":" .. errs[1].x .. ": " .. errs[1].msg, 0)
    end
    return tl.pretty_print_ast(program)
end)

Requires LPEG in your Neovim package.path.

require("moonwalk").add_loader("moon", function(src)
    return require("moonscript.base").to_lua(src)
end)
require("moonwalk").add_loader("yue", function(src, path)
    return vim.fn.system {"yue", "-p", path}
end)
Clone this wiki locally