fix module

This commit is contained in:
Adam Jeniski 2025-08-13 16:22:10 -09:00
parent 694569b5ec
commit a054e4bee8
2 changed files with 42 additions and 13 deletions

View File

@ -50,7 +50,7 @@
(let [{: content : range} form (let [{: content : range} form
buf (vim.api.nvim_win_get_buf 0) buf (vim.api.nvim_win_get_buf 0)
win (vim.api.nvim_tabpage_get_win 0) win (vim.api.nvim_tabpage_get_win 0)
me-form (.. "(" (or expand-cmd "clojure.walk/macroexpand-all") " '" content ")")] me-form (.. "(clojure.walk/macroexpand-all '" content ")")]
(clj-client eval.eval-str (clj-client eval.eval-str
{:origin :conjure-macroreplace {:origin :conjure-macroreplace
:code me-form :code me-form
@ -65,6 +65,16 @@
(a.get-in range [:start 1]) (a.get-in range [:start 1])
(a.inc (a.get-in range [:start 2]))))}))))) (a.inc (a.get-in range [:start 2]))))})))))
(defn tap-root []
(let [{: content : range : node} (extract.form {"root?" true})]
(when (not (a.empty? content))
(let [tap-code (.. "(tap> " content ")")]
(clj-client eval.eval-str
{:code tap-code
:range range
:node node
:origin :tap})))))
(defn add-buf-mappings [] (defn add-buf-mappings []
(mapping.buf :CljMacroexpand "cm" #(clj-macroexpand) (mapping.buf :CljMacroexpand "cm" #(clj-macroexpand)
@ -76,7 +86,9 @@
(mapping.buf :CljMacroexpandReplace "mr" #(replace-with-expanded-form) (mapping.buf :CljMacroexpandReplace "mr" #(replace-with-expanded-form)
{:desc "Call macroexpand-1 on the symbol under the cursor then replace that src with the expansion"}) {:desc "Call macroexpand-1 on the symbol under the cursor then replace that src with the expansion"})
(mapping.buf :CljDirWord "dw" #(dir-word) (mapping.buf :CljDirWord "dw" #(dir-word)
{:desc "Calls (clojure.repl/dir ,,,) for the namespace under the cursor"})) {:desc "Calls (clojure.repl/dir ,,,) for the namespace under the cursor"})
(mapping.buf :CljEvalTap "et" #(tap-root)
{:desc "Calls (tap> ,,,) for the root form under the cursor"}))
(defn init [] (defn init []
(when (or (not nvim.g.conjure_macroexpand_disable_mappings) (when (or (not nvim.g.conjure_macroexpand_disable_mappings)

View File

@ -71,7 +71,7 @@ local function replace_with_expanded_form()
local range = _let_6_["range"] local range = _let_6_["range"]
local buf = vim.api.nvim_win_get_buf(0) local buf = vim.api.nvim_win_get_buf(0)
local win = vim.api.nvim_tabpage_get_win(0) local win = vim.api.nvim_tabpage_get_win(0)
local me_form = ("(" .. (__fnl_global__expand_2dcmd or "clojure.walk/macroexpand-all") .. " '" .. content .. ")") local me_form = ("(clojure.walk/macroexpand-all '" .. content .. ")")
local function _7_(result) local function _7_(result)
buffer["replace-range"](buf, range, 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}))) return editor["go-to"](win, a["get-in"](range, {"start", 1}), a.inc(a["get-in"](range, {"start", 2})))
@ -82,27 +82,44 @@ local function replace_with_expanded_form()
end end
end end
_2amodule_locals_2a["replace-with-expanded-form"] = replace_with_expanded_form _2amodule_locals_2a["replace-with-expanded-form"] = replace_with_expanded_form
local function tap_root()
local _let_9_ = extract.form({["root?"] = true})
local content = _let_9_["content"]
local range = _let_9_["range"]
local node = _let_9_["node"]
if not a["empty?"](content) then
local tap_code = ("(tap> " .. content .. ")")
return clj_client(eval["eval-str"], {code = tap_code, range = range, node = node, origin = "tap"})
else
return nil
end
end
_2amodule_2a["tap-root"] = tap_root
local function add_buf_mappings() local function add_buf_mappings()
local function _9_() local function _11_()
return clj_macroexpand() return clj_macroexpand()
end end
mapping.buf("CljMacroexpand", "cm", _9_, {desc = "Call macroexpand-all on the symbol under the cursor"}) mapping.buf("CljMacroexpand", "cm", _11_, {desc = "Call macroexpand-all on the symbol under the cursor"})
local function _10_() local function _12_()
return clj_macroexpand("clojure.core/macroexpand") return clj_macroexpand("clojure.core/macroexpand")
end end
mapping.buf("CljMacroexpand0", "c0", _10_, {desc = "Call macroexpand on the symbol under the cursor"}) mapping.buf("CljMacroexpand0", "c0", _12_, {desc = "Call macroexpand on the symbol under the cursor"})
local function _11_() local function _13_()
return clj_macroexpand("clojure.core/macroexpand-1") return clj_macroexpand("clojure.core/macroexpand-1")
end end
mapping.buf("CljMacroexpand1", "c1", _11_, {desc = "Call macroexpand-1 on the symbol under the cursor"}) mapping.buf("CljMacroexpand1", "c1", _13_, {desc = "Call macroexpand-1 on the symbol under the cursor"})
local function _12_() local function _14_()
return replace_with_expanded_form() return replace_with_expanded_form()
end end
mapping.buf("CljMacroexpandReplace", "mr", _12_, {desc = "Call macroexpand-1 on the symbol under the cursor then replace that src with the expansion"}) mapping.buf("CljMacroexpandReplace", "mr", _14_, {desc = "Call macroexpand-1 on the symbol under the cursor then replace that src with the expansion"})
local function _13_() local function _15_()
return dir_word() return dir_word()
end end
return mapping.buf("CljDirWord", "dw", _13_, {desc = "Calls (clojure.repl/dir ,,,) for the namespace under the cursor"}) mapping.buf("CljDirWord", "dw", _15_, {desc = "Calls (clojure.repl/dir ,,,) for the namespace under the cursor"})
local function _16_()
return tap_root()
end
return mapping.buf("CljEvalTap", "et", _16_, {desc = "Calls (tap> ,,,) for the root form under the cursor"})
end end
_2amodule_2a["add-buf-mappings"] = add_buf_mappings _2amodule_2a["add-buf-mappings"] = add_buf_mappings
local function init() local function init()