local _2afile_2a = "fnl/conjure-macroreplace/main.fnl" local _2amodule_name_2a = "conjure-macroreplace.main" 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 a, bridge, buffer, client, editor, eval, extract, log, mapping, nvim, str = require("conjure-macroreplace.aniseed.core"), require("conjure.bridge"), require("conjure.buffer"), require("conjure.client"), require("conjure.editor"), require("conjure.eval"), require("conjure.extract"), require("conjure.log"), require("conjure.mapping"), require("conjure-macroreplace.aniseed.nvim"), require("conjure-macroreplace.aniseed.string") do end (_2amodule_locals_2a)["a"] = a _2amodule_locals_2a["bridge"] = bridge _2amodule_locals_2a["buffer"] = buffer _2amodule_locals_2a["client"] = client _2amodule_locals_2a["editor"] = editor _2amodule_locals_2a["eval"] = eval _2amodule_locals_2a["extract"] = extract _2amodule_locals_2a["log"] = log _2amodule_locals_2a["mapping"] = mapping _2amodule_locals_2a["nvim"] = nvim _2amodule_locals_2a["str"] = str local function current_form() local form = extract.form({}) if form then local _let_1_ = form local content = _let_1_["content"] return content else return nil end end _2amodule_locals_2a["current-form"] = current_form local function clj_client(f, args) return client["with-filetype"]("clojure", f, args) end _2amodule_locals_2a["clj-client"] = clj_client local function output_expanded(orig) local function _3_(r) return log.append(a.concat({("; " .. orig)}, str.split(r, "\n")), {["break?"] = true}) end return _3_ end _2amodule_locals_2a["output-expanded"] = output_expanded local function clj_macroexpand(expand_cmd) local form = current_form() local me_form = ("(" .. (expand_cmd or "clojure.walk/macroexpand-all") .. " '" .. form .. ")") return clj_client(eval["eval-str"], {origin = "conjure-macroexpand", code = me_form, ["passive?"] = true, ["on-result"] = output_expanded(me_form)}) end _2amodule_2a["clj-macroexpand"] = clj_macroexpand local function dir_word() local _let_4_ = extract.word() local content = _let_4_["content"] local range = _let_4_["range"] local node = _let_4_["node"] if not a["empty?"](content) then local dir_code = ("(clojure.repl/dir " .. content .. ")") return clj_client(eval["eval-str"], {code = dir_code, range = range, node = node, origin = "word"}) else return nil end end _2amodule_locals_2a["dir-word"] = dir_word local function replace_with_expanded_form() local form = extract.form({}) if form then local _let_6_ = form local content = _let_6_["content"] local range = _let_6_["range"] local buf = vim.api.nvim_win_get_buf(0) local win = vim.api.nvim_tabpage_get_win(0) local me_form = ("(" .. (__fnl_global__expand_2dcmd or "clojure.walk/macroexpand-all") .. " '" .. content .. ")") local function _7_(result) buffer["replace-range"](buf, range, result) return editor["go-to"](win, a["get-in"](range, {"start", 1}), a.inc(a["get-in"](range, {"start", 2}))) end return clj_client(eval["eval-str"], {origin = "conjure-macroreplace", code = me_form, ["passive?"] = true, ["on-result"] = _7_}) else return nil end end _2amodule_locals_2a["replace-with-expanded-form"] = replace_with_expanded_form local function add_buf_mappings() local function _9_() return clj_macroexpand() end mapping.buf("CljMacroexpand", "cm", _9_, {desc = "Call macroexpand-all on the symbol under the cursor"}) local function _10_() return clj_macroexpand("clojure.core/macroexpand") end mapping.buf("CljMacroexpand0", "c0", _10_, {desc = "Call macroexpand on the symbol under the cursor"}) local function _11_() return clj_macroexpand("clojure.core/macroexpand-1") end mapping.buf("CljMacroexpand1", "c1", _11_, {desc = "Call macroexpand-1 on the symbol under the cursor"}) local function _12_() return replace_with_expanded_form() end mapping.buf("CljMacroexpandReplace", "mr", _12_, {desc = "Call macroexpand-1 on the symbol under the cursor then replace that src with the expansion"}) local function _13_() return dir_word() end return mapping.buf("CljDirWord", "dw", _13_, {desc = "Calls (clojure.repl/dir ,,,) for the namespace under the cursor"}) end _2amodule_2a["add-buf-mappings"] = add_buf_mappings local function init() if (not nvim.g.conjure_macroexpand_disable_mappings or (0 == nvim.g.conjure_macroexpand_disable_mappings)) then return nvim.ex.autocmd("FileType", "clojure", bridge["viml->lua"]("conjure-macroreplace.main", "add-buf-mappings")) else return nil end end _2amodule_2a["init"] = init return _2amodule_2a