fix module
This commit is contained in:
parent
694569b5ec
commit
a054e4bee8
@ -50,7 +50,7 @@
|
||||
(let [{: content : range} form
|
||||
buf (vim.api.nvim_win_get_buf 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
|
||||
{:origin :conjure-macroreplace
|
||||
:code me-form
|
||||
@ -65,6 +65,16 @@
|
||||
(a.get-in range [:start 1])
|
||||
(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 []
|
||||
(mapping.buf :CljMacroexpand "cm" #(clj-macroexpand)
|
||||
@ -76,7 +86,9 @@
|
||||
(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"})
|
||||
(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 []
|
||||
(when (or (not nvim.g.conjure_macroexpand_disable_mappings)
|
||||
|
@ -71,7 +71,7 @@ local function replace_with_expanded_form()
|
||||
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 me_form = ("(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})))
|
||||
@ -82,27 +82,44 @@ local function replace_with_expanded_form()
|
||||
end
|
||||
end
|
||||
_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 _9_()
|
||||
local function _11_()
|
||||
return clj_macroexpand()
|
||||
end
|
||||
mapping.buf("CljMacroexpand", "cm", _9_, {desc = "Call macroexpand-all on the symbol under the cursor"})
|
||||
local function _10_()
|
||||
mapping.buf("CljMacroexpand", "cm", _11_, {desc = "Call macroexpand-all on the symbol under the cursor"})
|
||||
local function _12_()
|
||||
return clj_macroexpand("clojure.core/macroexpand")
|
||||
end
|
||||
mapping.buf("CljMacroexpand0", "c0", _10_, {desc = "Call macroexpand on the symbol under the cursor"})
|
||||
local function _11_()
|
||||
mapping.buf("CljMacroexpand0", "c0", _12_, {desc = "Call macroexpand on the symbol under the cursor"})
|
||||
local function _13_()
|
||||
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_()
|
||||
mapping.buf("CljMacroexpand1", "c1", _13_, {desc = "Call macroexpand-1 on the symbol under the cursor"})
|
||||
local function _14_()
|
||||
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_()
|
||||
mapping.buf("CljMacroexpandReplace", "mr", _14_, {desc = "Call macroexpand-1 on the symbol under the cursor then replace that src with the expansion"})
|
||||
local function _15_()
|
||||
return dir_word()
|
||||
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
|
||||
_2amodule_2a["add-buf-mappings"] = add_buf_mappings
|
||||
local function init()
|
||||
|
Loading…
x
Reference in New Issue
Block a user