Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657vim.api.nvim_create_augroup("moonwalk", { clear = true })vim.api.nvim_create_autocmd("BufWritePost", { pattern = vim.fn.stdpath("config") .. "/*.fnl", group = "moonwalk", callback = function(args) require("moonwalk").compile(args.match) end,})vim.api.nvim_create_autocmd("SourceCmd", { pattern = "*.fnl", group = "moonwalk", callback = function(args) local out = require("moonwalk").compile(vim.fs.abspath(args.file)) if out then vim.api.nvim_cmd({ cmd = "source", args = { out } }, {}) else vim.notify("moonwalk: not compiled: " .. args.file, vim.log.levels.WARN) end end,})
local marker = vim.fn.stdpath("state") .. "/moonwalk"
local function moonwalk() local loader_enabled = vim.loader.enabled vim.loader.enable(false)
local walk = require("moonwalk").walk
-- Clean existing files walk(vim.fn.stdpath("data") .. "/site", "lua", function(path) if vim.fn.fnamemodify(path, ":t") == "fennel.lua" then return end os.remove(path) end)
walk(vim.fn.stdpath("config"), "fnl", require("moonwalk").compile) local f = assert(io.open(marker, "w")) f:write("") f:close()
-- Reset runtimepath cache so new Lua files are discovered vim.o.runtimepath = vim.o.runtimepath
if loader_enabled then vim.schedule(vim.loader.enable) endend
vim.api.nvim_create_user_command("Moonwalk", moonwalk, { desc = "Compile all Fennel runtime files to Lua" })
-- Using a filesystem marker to do this seems hacky, but I don't now of a better wayif not vim.uv.fs_stat(marker) then moonwalk()end