init commit
This commit is contained in:
parent
ebeff7b1e4
commit
9c34381aa5
@ -32,13 +32,58 @@
|
|||||||
:passive? true
|
:passive? true
|
||||||
:on-result (output-expanded me-form)})))
|
:on-result (output-expanded me-form)})))
|
||||||
|
|
||||||
|
(defn wrap-emit [name f]
|
||||||
|
(fn [...]
|
||||||
|
(event.emit name)
|
||||||
|
(f ...)))
|
||||||
|
|
||||||
|
(local dir-str (wrap-emit
|
||||||
|
:doc
|
||||||
|
(client-exec-fn :doc :doc-str)))
|
||||||
|
|
||||||
|
(defn dir-word []
|
||||||
|
(let [{: content : range : node} (extract.word)]
|
||||||
|
(when (not (core.empty? content))
|
||||||
|
(dir-str
|
||||||
|
{:code content
|
||||||
|
:range range
|
||||||
|
:node node
|
||||||
|
:origin :word}))))
|
||||||
|
|
||||||
|
(defn replace-form []
|
||||||
|
(let [buf (vim.api.nvim_win_get_buf 0)
|
||||||
|
win (vim.api.nvim_tabpage_get_win 0)
|
||||||
|
form (extract.form {})]
|
||||||
|
(when form
|
||||||
|
(let [{: content : range : node} form]
|
||||||
|
(eval-str
|
||||||
|
{:code content
|
||||||
|
:range range
|
||||||
|
:node node
|
||||||
|
:origin :replace-form
|
||||||
|
:suppress-hud? true
|
||||||
|
:on-result
|
||||||
|
(fn [result]
|
||||||
|
(buffer.replacerange
|
||||||
|
buf
|
||||||
|
range result)
|
||||||
|
(editor.go-to
|
||||||
|
win
|
||||||
|
(core.get-in range [:start 1])
|
||||||
|
(core.inc (core.get-in range [:start 2]))))})
|
||||||
|
(.. "(clojure.core/macroexpand1 " form ")")))))
|
||||||
|
|
||||||
(defn add-buf-mappings []
|
(defn add-buf-mappings []
|
||||||
(mapping.buf :CljMacroexpand "cm" #(clj-macroexpand)
|
(mapping.buf :CljMacroexpand "cm" #(clj-macroexpand)
|
||||||
{:desc "Call macroexpand-all on the symbol under the cursor"})
|
{:desc "Call macroexpand-all on the symbol under the cursor"})
|
||||||
(mapping.buf :CljMacroexpand0 "c0" #(clj-macroexpand "clojure.core/macroexpand")
|
(mapping.buf :CljMacroexpand0 "c0" #(clj-macroexpand "clojure.core/macroexpand")
|
||||||
{:desc "Call macroexpand on the symbol under the cursor"})
|
{:desc "Call macroexpand on the symbol under the cursor"})
|
||||||
(mapping.buf :CljMacroexpand1 "c1" #(clj-macroexpand "clojure.core/macroexpand-1")
|
(mapping.buf :CljMacroexpand1 "c1" #(clj-macroexpand "clojure.core/macroexpand-1")
|
||||||
{:desc "Call macroexpand-1 on the symbol under the cursor"}))
|
{:desc "Call macroexpand-1 on the symbol under the cursor"})
|
||||||
|
(mapping.buf :CljMacroexpandReplace "em!" #(replace-form)
|
||||||
|
{:desc "Call macroexpand-1 on the symbol under the cursor then replace that src with the expansion"})
|
||||||
|
(mapping.buf :CljDirWord "em!" #(dir-word)
|
||||||
|
{:desc "Calls (clojure.repl/dir ,,,) for the namespace 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)
|
||||||
|
@ -47,7 +47,7 @@ local function str(code, opts)
|
|||||||
ANISEED_STATIC_MODULES = (true == a.get(opts, "static?"))
|
ANISEED_STATIC_MODULES = (true == a.get(opts, "static?"))
|
||||||
local fnl = fennel.impl()
|
local fnl = fennel.impl()
|
||||||
local function _4_()
|
local function _4_()
|
||||||
return string.gsub(string.gsub(fnl.compileString(wrap_macros(code, opts), a["merge!"]({allowedGlobals = false, compilerEnv = _G}, opts)), (delete_marker_pat .. "\n"), "\n"), (delete_marker_pat .. "$"), "")
|
return string.gsub(string.gsub(fnl.compileString(wrap_macros(code, opts), a["merge!"]({compilerEnv = _G, allowedGlobals = false}, opts)), (delete_marker_pat .. "\n"), "\n"), (delete_marker_pat .. "$"), "")
|
||||||
end
|
end
|
||||||
return xpcall(_4_, fnl.traceback)
|
return xpcall(_4_, fnl.traceback)
|
||||||
end
|
end
|
||||||
|
@ -150,33 +150,44 @@ local function run_21(f, xs)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
_2amodule_2a["run!"] = run_21
|
_2amodule_2a["run!"] = run_21
|
||||||
|
local function complement(f)
|
||||||
|
local function _11_(...)
|
||||||
|
return not f(...)
|
||||||
|
end
|
||||||
|
return _11_
|
||||||
|
end
|
||||||
|
_2amodule_2a["complement"] = complement
|
||||||
local function filter(f, xs)
|
local function filter(f, xs)
|
||||||
local result = {}
|
local result = {}
|
||||||
local function _11_(x)
|
local function _12_(x)
|
||||||
if f(x) then
|
if f(x) then
|
||||||
return table.insert(result, x)
|
return table.insert(result, x)
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
run_21(_11_, xs)
|
run_21(_12_, xs)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
_2amodule_2a["filter"] = filter
|
_2amodule_2a["filter"] = filter
|
||||||
|
local function remove(f, xs)
|
||||||
|
return filter(complement(f), xs)
|
||||||
|
end
|
||||||
|
_2amodule_2a["remove"] = remove
|
||||||
local function map(f, xs)
|
local function map(f, xs)
|
||||||
local result = {}
|
local result = {}
|
||||||
local function _13_(x)
|
local function _14_(x)
|
||||||
local mapped = f(x)
|
local mapped = f(x)
|
||||||
local function _14_()
|
local function _15_()
|
||||||
if (0 == select("#", mapped)) then
|
if (0 == select("#", mapped)) then
|
||||||
return nil
|
return nil
|
||||||
else
|
else
|
||||||
return mapped
|
return mapped
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return table.insert(result, _14_())
|
return table.insert(result, _15_())
|
||||||
end
|
end
|
||||||
run_21(_13_, xs)
|
run_21(_14_, xs)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
_2amodule_2a["map"] = map
|
_2amodule_2a["map"] = map
|
||||||
@ -190,11 +201,11 @@ end
|
|||||||
_2amodule_2a["identity"] = identity
|
_2amodule_2a["identity"] = identity
|
||||||
local function reduce(f, init, xs)
|
local function reduce(f, init, xs)
|
||||||
local result = init
|
local result = init
|
||||||
local function _15_(x)
|
local function _16_(x)
|
||||||
result = f(result, x)
|
result = f(result, x)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
run_21(_15_, xs)
|
run_21(_16_, xs)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
_2amodule_2a["reduce"] = reduce
|
_2amodule_2a["reduce"] = reduce
|
||||||
@ -214,34 +225,34 @@ end
|
|||||||
_2amodule_2a["some"] = some
|
_2amodule_2a["some"] = some
|
||||||
local function butlast(xs)
|
local function butlast(xs)
|
||||||
local total = count(xs)
|
local total = count(xs)
|
||||||
local function _19_(_17_)
|
local function _20_(_18_)
|
||||||
local _arg_18_ = _17_
|
local _arg_19_ = _18_
|
||||||
local n = _arg_18_[1]
|
local n = _arg_19_[1]
|
||||||
local v = _arg_18_[2]
|
local v = _arg_19_[2]
|
||||||
return (n ~= total)
|
return (n ~= total)
|
||||||
end
|
end
|
||||||
return map(second, filter(_19_, kv_pairs(xs)))
|
return map(second, filter(_20_, kv_pairs(xs)))
|
||||||
end
|
end
|
||||||
_2amodule_2a["butlast"] = butlast
|
_2amodule_2a["butlast"] = butlast
|
||||||
local function rest(xs)
|
local function rest(xs)
|
||||||
local function _22_(_20_)
|
local function _23_(_21_)
|
||||||
local _arg_21_ = _20_
|
local _arg_22_ = _21_
|
||||||
local n = _arg_21_[1]
|
local n = _arg_22_[1]
|
||||||
local v = _arg_21_[2]
|
local v = _arg_22_[2]
|
||||||
return (n ~= 1)
|
return (n ~= 1)
|
||||||
end
|
end
|
||||||
return map(second, filter(_22_, kv_pairs(xs)))
|
return map(second, filter(_23_, kv_pairs(xs)))
|
||||||
end
|
end
|
||||||
_2amodule_2a["rest"] = rest
|
_2amodule_2a["rest"] = rest
|
||||||
local function concat(...)
|
local function concat(...)
|
||||||
local result = {}
|
local result = {}
|
||||||
local function _23_(xs)
|
local function _24_(xs)
|
||||||
local function _24_(x)
|
local function _25_(x)
|
||||||
return table.insert(result, x)
|
return table.insert(result, x)
|
||||||
end
|
end
|
||||||
return run_21(_24_, xs)
|
return run_21(_25_, xs)
|
||||||
end
|
end
|
||||||
run_21(_23_, {...})
|
run_21(_24_, {...})
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
_2amodule_2a["concat"] = concat
|
_2amodule_2a["concat"] = concat
|
||||||
@ -251,10 +262,10 @@ end
|
|||||||
_2amodule_2a["mapcat"] = mapcat
|
_2amodule_2a["mapcat"] = mapcat
|
||||||
local function pr_str(...)
|
local function pr_str(...)
|
||||||
local s
|
local s
|
||||||
local function _25_(x)
|
local function _26_(x)
|
||||||
return view.serialise(x, {["one-line"] = true})
|
return view.serialise(x, {["one-line"] = true})
|
||||||
end
|
end
|
||||||
s = table.concat(map(_25_, {...}), " ")
|
s = table.concat(map(_26_, {...}), " ")
|
||||||
if (nil_3f(s) or ("" == s)) then
|
if (nil_3f(s) or ("" == s)) then
|
||||||
return "nil"
|
return "nil"
|
||||||
else
|
else
|
||||||
@ -263,41 +274,41 @@ local function pr_str(...)
|
|||||||
end
|
end
|
||||||
_2amodule_2a["pr-str"] = pr_str
|
_2amodule_2a["pr-str"] = pr_str
|
||||||
local function str(...)
|
local function str(...)
|
||||||
local function _27_(acc, s)
|
local function _28_(acc, s)
|
||||||
return (acc .. s)
|
return (acc .. s)
|
||||||
end
|
end
|
||||||
local function _28_(s)
|
local function _29_(s)
|
||||||
if string_3f(s) then
|
if string_3f(s) then
|
||||||
return s
|
return s
|
||||||
else
|
else
|
||||||
return pr_str(s)
|
return pr_str(s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return reduce(_27_, "", map(_28_, {...}))
|
return reduce(_28_, "", map(_29_, {...}))
|
||||||
end
|
end
|
||||||
_2amodule_2a["str"] = str
|
_2amodule_2a["str"] = str
|
||||||
local function println(...)
|
local function println(...)
|
||||||
local function _30_(acc, s)
|
local function _31_(acc, s)
|
||||||
return (acc .. s)
|
return (acc .. s)
|
||||||
end
|
end
|
||||||
local function _33_(_31_)
|
local function _34_(_32_)
|
||||||
local _arg_32_ = _31_
|
local _arg_33_ = _32_
|
||||||
local i = _arg_32_[1]
|
local i = _arg_33_[1]
|
||||||
local s = _arg_32_[2]
|
local s = _arg_33_[2]
|
||||||
if (1 == i) then
|
if (1 == i) then
|
||||||
return s
|
return s
|
||||||
else
|
else
|
||||||
return (" " .. s)
|
return (" " .. s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function _35_(s)
|
local function _36_(s)
|
||||||
if string_3f(s) then
|
if string_3f(s) then
|
||||||
return s
|
return s
|
||||||
else
|
else
|
||||||
return pr_str(s)
|
return pr_str(s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return print(reduce(_30_, "", map_indexed(_33_, map(_35_, {...}))))
|
return print(reduce(_31_, "", map_indexed(_34_, map(_36_, {...}))))
|
||||||
end
|
end
|
||||||
_2amodule_2a["println"] = println
|
_2amodule_2a["println"] = println
|
||||||
local function pr(...)
|
local function pr(...)
|
||||||
@ -305,12 +316,12 @@ local function pr(...)
|
|||||||
end
|
end
|
||||||
_2amodule_2a["pr"] = pr
|
_2amodule_2a["pr"] = pr
|
||||||
local function slurp(path, silent_3f)
|
local function slurp(path, silent_3f)
|
||||||
local _37_, _38_ = io.open(path, "r")
|
local _38_, _39_ = io.open(path, "r")
|
||||||
if ((_37_ == nil) and (nil ~= _38_)) then
|
if ((_38_ == nil) and (nil ~= _39_)) then
|
||||||
local msg = _38_
|
local msg = _39_
|
||||||
return nil
|
return nil
|
||||||
elseif (nil ~= _37_) then
|
elseif (nil ~= _38_) then
|
||||||
local f = _37_
|
local f = _38_
|
||||||
local content = f:read("*all")
|
local content = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
return content
|
return content
|
||||||
@ -320,12 +331,12 @@ local function slurp(path, silent_3f)
|
|||||||
end
|
end
|
||||||
_2amodule_2a["slurp"] = slurp
|
_2amodule_2a["slurp"] = slurp
|
||||||
local function spit(path, content)
|
local function spit(path, content)
|
||||||
local _40_, _41_ = io.open(path, "w")
|
local _41_, _42_ = io.open(path, "w")
|
||||||
if ((_40_ == nil) and (nil ~= _41_)) then
|
if ((_41_ == nil) and (nil ~= _42_)) then
|
||||||
local msg = _41_
|
local msg = _42_
|
||||||
return error(("Could not open file: " .. msg))
|
return error(("Could not open file: " .. msg))
|
||||||
elseif (nil ~= _40_) then
|
elseif (nil ~= _41_) then
|
||||||
local f = _40_
|
local f = _41_
|
||||||
f:write(content)
|
f:write(content)
|
||||||
f:close()
|
f:close()
|
||||||
return nil
|
return nil
|
||||||
@ -335,7 +346,7 @@ local function spit(path, content)
|
|||||||
end
|
end
|
||||||
_2amodule_2a["spit"] = spit
|
_2amodule_2a["spit"] = spit
|
||||||
local function merge_21(base, ...)
|
local function merge_21(base, ...)
|
||||||
local function _43_(acc, m)
|
local function _44_(acc, m)
|
||||||
if m then
|
if m then
|
||||||
for k, v in pairs(m) do
|
for k, v in pairs(m) do
|
||||||
acc[k] = v
|
acc[k] = v
|
||||||
@ -344,7 +355,7 @@ local function merge_21(base, ...)
|
|||||||
end
|
end
|
||||||
return acc
|
return acc
|
||||||
end
|
end
|
||||||
return reduce(_43_, (base or {}), {...})
|
return reduce(_44_, (base or {}), {...})
|
||||||
end
|
end
|
||||||
_2amodule_2a["merge!"] = merge_21
|
_2amodule_2a["merge!"] = merge_21
|
||||||
local function merge(...)
|
local function merge(...)
|
||||||
@ -353,14 +364,14 @@ end
|
|||||||
_2amodule_2a["merge"] = merge
|
_2amodule_2a["merge"] = merge
|
||||||
local function select_keys(t, ks)
|
local function select_keys(t, ks)
|
||||||
if (t and ks) then
|
if (t and ks) then
|
||||||
local function _45_(acc, k)
|
local function _46_(acc, k)
|
||||||
if k then
|
if k then
|
||||||
acc[k] = t[k]
|
acc[k] = t[k]
|
||||||
else
|
else
|
||||||
end
|
end
|
||||||
return acc
|
return acc
|
||||||
end
|
end
|
||||||
return reduce(_45_, {}, ks)
|
return reduce(_46_, {}, ks)
|
||||||
else
|
else
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
@ -387,14 +398,14 @@ end
|
|||||||
_2amodule_2a["get"] = get
|
_2amodule_2a["get"] = get
|
||||||
local function get_in(t, ks, d)
|
local function get_in(t, ks, d)
|
||||||
local res
|
local res
|
||||||
local function _51_(acc, k)
|
local function _52_(acc, k)
|
||||||
if table_3f(acc) then
|
if table_3f(acc) then
|
||||||
return get(acc, k)
|
return get(acc, k)
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
res = reduce(_51_, t, ks)
|
res = reduce(_52_, t, ks)
|
||||||
if nil_3f(res) then
|
if nil_3f(res) then
|
||||||
return d
|
return d
|
||||||
else
|
else
|
||||||
@ -403,10 +414,10 @@ local function get_in(t, ks, d)
|
|||||||
end
|
end
|
||||||
_2amodule_2a["get-in"] = get_in
|
_2amodule_2a["get-in"] = get_in
|
||||||
local function assoc(t, ...)
|
local function assoc(t, ...)
|
||||||
local _let_54_ = {...}
|
local _let_55_ = {...}
|
||||||
local k = _let_54_[1]
|
local k = _let_55_[1]
|
||||||
local v = _let_54_[2]
|
local v = _let_55_[2]
|
||||||
local xs = (function (t, k) local mt = getmetatable(t) if "table" == type(mt) and mt.__fennelrest then return mt.__fennelrest(t, k) else return {(table.unpack or unpack)(t, k)} end end)(_let_54_, 3)
|
local xs = (function (t, k, e) local mt = getmetatable(t) if 'table' == type(mt) and mt.__fennelrest then return mt.__fennelrest(t, k) elseif e then local rest = {} for k, v in pairs(t) do if not e[k] then rest[k] = v end end return rest else return {(table.unpack or unpack)(t, k)} end end)(_let_55_, 3)
|
||||||
local rem = count(xs)
|
local rem = count(xs)
|
||||||
local t0 = (t or {})
|
local t0 = (t or {})
|
||||||
if odd_3f(rem) then
|
if odd_3f(rem) then
|
||||||
@ -428,7 +439,7 @@ local function assoc_in(t, ks, v)
|
|||||||
local path = butlast(ks)
|
local path = butlast(ks)
|
||||||
local final = last(ks)
|
local final = last(ks)
|
||||||
local t0 = (t or {})
|
local t0 = (t or {})
|
||||||
local function _58_(acc, k)
|
local function _59_(acc, k)
|
||||||
local step = get(acc, k)
|
local step = get(acc, k)
|
||||||
if nil_3f(step) then
|
if nil_3f(step) then
|
||||||
return get(assoc(acc, k, {}), k)
|
return get(assoc(acc, k, {}), k)
|
||||||
@ -436,7 +447,7 @@ local function assoc_in(t, ks, v)
|
|||||||
return step
|
return step
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assoc(reduce(_58_, t0, path), final, v)
|
assoc(reduce(_59_, t0, path), final, v)
|
||||||
return t0
|
return t0
|
||||||
end
|
end
|
||||||
_2amodule_2a["assoc-in"] = assoc_in
|
_2amodule_2a["assoc-in"] = assoc_in
|
||||||
@ -449,10 +460,10 @@ local function update_in(t, ks, f)
|
|||||||
end
|
end
|
||||||
_2amodule_2a["update-in"] = update_in
|
_2amodule_2a["update-in"] = update_in
|
||||||
local function constantly(v)
|
local function constantly(v)
|
||||||
local function _60_()
|
local function _61_()
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
return _60_
|
return _61_
|
||||||
end
|
end
|
||||||
_2amodule_2a["constantly"] = constantly
|
_2amodule_2a["constantly"] = constantly
|
||||||
return _2amodule_2a
|
return _2amodule_2a
|
||||||
|
File diff suppressed because one or more lines are too long
@ -4,175 +4,257 @@ local api = vim.api
|
|||||||
local inspect = vim.inspect
|
local inspect = vim.inspect
|
||||||
|
|
||||||
local function extend(t, o)
|
local function extend(t, o)
|
||||||
local mt = getmetatable(t)
|
local mt = getmetatable(t)
|
||||||
for k, v in pairs(o) do
|
for k, v in pairs(o) do
|
||||||
rawset(mt, k, v)
|
rawset(mt, k, v)
|
||||||
end
|
end
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Equivalent to `echo vim.inspect(...)`
|
-- Equivalent to `echo vim.inspect(...)`
|
||||||
local function nvim_print(...)
|
local function nvim_print(...)
|
||||||
if select("#", ...) == 1 then
|
if select("#", ...) == 1 then
|
||||||
api.nvim_out_write(inspect((...)))
|
api.nvim_out_write(inspect((...)))
|
||||||
else
|
else
|
||||||
api.nvim_out_write(inspect {...})
|
api.nvim_out_write(inspect({ ... }))
|
||||||
end
|
end
|
||||||
api.nvim_out_write("\n")
|
api.nvim_out_write("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Equivalent to `echo` EX command
|
--- Equivalent to `echo` EX command
|
||||||
local function nvim_echo(...)
|
local function nvim_echo(...)
|
||||||
for i = 1, select("#", ...) do
|
for i = 1, select("#", ...) do
|
||||||
local part = select(i, ...)
|
local part = select(i, ...)
|
||||||
api.nvim_out_write(tostring(part))
|
api.nvim_out_write(tostring(part))
|
||||||
-- vim.api.nvim_out_write("\n")
|
-- vim.api.nvim_out_write("\n")
|
||||||
api.nvim_out_write(" ")
|
api.nvim_out_write(" ")
|
||||||
end
|
end
|
||||||
api.nvim_out_write("\n")
|
api.nvim_out_write("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
local window_options = {
|
local window_options = {
|
||||||
arab = true; arabic = true; breakindent = true; breakindentopt = true;
|
arab = true,
|
||||||
bri = true; briopt = true; cc = true; cocu = true;
|
arabic = true,
|
||||||
cole = true; colorcolumn = true; concealcursor = true; conceallevel = true;
|
breakindent = true,
|
||||||
crb = true; cuc = true; cul = true; cursorbind = true;
|
breakindentopt = true,
|
||||||
cursorcolumn = true; cursorline = true; diff = true; fcs = true;
|
bri = true,
|
||||||
fdc = true; fde = true; fdi = true; fdl = true;
|
briopt = true,
|
||||||
fdm = true; fdn = true; fdt = true; fen = true;
|
cc = true,
|
||||||
fillchars = true; fml = true; fmr = true; foldcolumn = true;
|
cocu = true,
|
||||||
foldenable = true; foldexpr = true; foldignore = true; foldlevel = true;
|
cole = true,
|
||||||
foldmarker = true; foldmethod = true; foldminlines = true; foldnestmax = true;
|
colorcolumn = true,
|
||||||
foldtext = true; lbr = true; lcs = true; linebreak = true;
|
concealcursor = true,
|
||||||
list = true; listchars = true; nu = true; number = true;
|
conceallevel = true,
|
||||||
numberwidth = true; nuw = true; previewwindow = true; pvw = true;
|
crb = true,
|
||||||
relativenumber = true; rightleft = true; rightleftcmd = true; rl = true;
|
cuc = true,
|
||||||
rlc = true; rnu = true; scb = true; scl = true;
|
cul = true,
|
||||||
scr = true; scroll = true; scrollbind = true; signcolumn = true;
|
cursorbind = true,
|
||||||
spell = true; statusline = true; stl = true; wfh = true;
|
cursorcolumn = true,
|
||||||
wfw = true; winbl = true; winblend = true; winfixheight = true;
|
cursorline = true,
|
||||||
winfixwidth = true; winhighlight = true; winhl = true; wrap = true;
|
diff = true,
|
||||||
|
fcs = true,
|
||||||
|
fdc = true,
|
||||||
|
fde = true,
|
||||||
|
fdi = true,
|
||||||
|
fdl = true,
|
||||||
|
fdm = true,
|
||||||
|
fdn = true,
|
||||||
|
fdt = true,
|
||||||
|
fen = true,
|
||||||
|
fillchars = true,
|
||||||
|
fml = true,
|
||||||
|
fmr = true,
|
||||||
|
foldcolumn = true,
|
||||||
|
foldenable = true,
|
||||||
|
foldexpr = true,
|
||||||
|
foldignore = true,
|
||||||
|
foldlevel = true,
|
||||||
|
foldmarker = true,
|
||||||
|
foldmethod = true,
|
||||||
|
foldminlines = true,
|
||||||
|
foldnestmax = true,
|
||||||
|
foldtext = true,
|
||||||
|
lbr = true,
|
||||||
|
lcs = true,
|
||||||
|
linebreak = true,
|
||||||
|
list = true,
|
||||||
|
listchars = true,
|
||||||
|
nu = true,
|
||||||
|
number = true,
|
||||||
|
numberwidth = true,
|
||||||
|
nuw = true,
|
||||||
|
previewwindow = true,
|
||||||
|
pvw = true,
|
||||||
|
relativenumber = true,
|
||||||
|
rightleft = true,
|
||||||
|
rightleftcmd = true,
|
||||||
|
rl = true,
|
||||||
|
rlc = true,
|
||||||
|
rnu = true,
|
||||||
|
scb = true,
|
||||||
|
scl = true,
|
||||||
|
scr = true,
|
||||||
|
scroll = true,
|
||||||
|
scrollbind = true,
|
||||||
|
signcolumn = true,
|
||||||
|
spell = true,
|
||||||
|
statusline = true,
|
||||||
|
stl = true,
|
||||||
|
wfh = true,
|
||||||
|
wfw = true,
|
||||||
|
winbl = true,
|
||||||
|
winblend = true,
|
||||||
|
winfixheight = true,
|
||||||
|
winfixwidth = true,
|
||||||
|
winhighlight = true,
|
||||||
|
winhl = true,
|
||||||
|
wrap = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function validate(conf)
|
local function validate(conf)
|
||||||
assert(type(conf) == 'table')
|
assert(type(conf) == "table")
|
||||||
local type_names = {
|
local type_names = {
|
||||||
t='table', s='string', n='number', b='boolean', f='function', c='callable',
|
t = "table",
|
||||||
['table']='table', ['string']='string', ['number']='number',
|
s = "string",
|
||||||
['boolean']='boolean', ['function']='function', ['callable']='callable',
|
n = "number",
|
||||||
['nil']='nil', ['thread']='thread', ['userdata']='userdata',
|
b = "boolean",
|
||||||
}
|
f = "function",
|
||||||
for k, v in pairs(conf) do
|
c = "callable",
|
||||||
if not (v[3] and v[1] == nil) and type(v[1]) ~= type_names[v[2]] then
|
["table"] = "table",
|
||||||
error(string.format("validation_failed: %q: expected %s, received %s", k, type_names[v[2]], type(v[1])))
|
["string"] = "string",
|
||||||
end
|
["number"] = "number",
|
||||||
end
|
["boolean"] = "boolean",
|
||||||
return true
|
["function"] = "function",
|
||||||
|
["callable"] = "callable",
|
||||||
|
["nil"] = "nil",
|
||||||
|
["thread"] = "thread",
|
||||||
|
["userdata"] = "userdata",
|
||||||
|
}
|
||||||
|
for k, v in pairs(conf) do
|
||||||
|
if not (v[3] and v[1] == nil) and type(v[1]) ~= type_names[v[2]] then
|
||||||
|
error(string.format("validation_failed: %q: expected %s, received %s", k, type_names[v[2]], type(v[1])))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function make_meta_accessor(get, set, del)
|
local function make_meta_accessor(get, set, del)
|
||||||
validate {
|
validate({
|
||||||
get = {get, 'f'};
|
get = { get, "f" },
|
||||||
set = {set, 'f'};
|
set = { set, "f" },
|
||||||
del = {del, 'f', true};
|
del = { del, "f", true },
|
||||||
}
|
})
|
||||||
local mt = {}
|
local mt = {}
|
||||||
if del then
|
if del then
|
||||||
function mt:__newindex(k, v)
|
function mt:__newindex(k, v)
|
||||||
if v == nil then
|
if v == nil then
|
||||||
return del(k)
|
return del(k)
|
||||||
end
|
end
|
||||||
return set(k, v)
|
return set(k, v)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
function mt:__newindex(k, v)
|
function mt:__newindex(k, v)
|
||||||
return set(k, v)
|
return set(k, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function mt:__index(k)
|
function mt:__index(k)
|
||||||
return get(k)
|
return get(k)
|
||||||
end
|
end
|
||||||
return setmetatable({}, mt)
|
return setmetatable({}, mt)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function pcall_ret(status, ...)
|
local function pcall_ret(status, ...)
|
||||||
if status then return ... end
|
if status then
|
||||||
|
return ...
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function nil_wrap(fn)
|
local function nil_wrap(fn)
|
||||||
return function(...)
|
return function(...)
|
||||||
return pcall_ret(pcall(fn, ...))
|
return pcall_ret(pcall(fn, ...))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local fn = setmetatable({}, {
|
local fn = setmetatable({}, {
|
||||||
__index = function(t, k)
|
__index = function(t, k)
|
||||||
local f = function(...) return api.nvim_call_function(k, {...}) end
|
local f = function(...)
|
||||||
rawset(t, k, f)
|
return api.nvim_call_function(k, { ... })
|
||||||
return f
|
end
|
||||||
end
|
rawset(t, k, f)
|
||||||
|
return f
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local function getenv(k)
|
local function getenv(k)
|
||||||
local v = fn.getenv(k)
|
local v = fn.getenv(k)
|
||||||
if v == vim.NIL then
|
if v == vim.NIL then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
local function new_win_accessor(winnr)
|
local function new_win_accessor(winnr)
|
||||||
local function get(k)
|
local function get(k)
|
||||||
if winnr == nil and type(k) == 'number' then
|
if winnr == nil and type(k) == "number" then
|
||||||
return new_win_accessor(k)
|
return new_win_accessor(k)
|
||||||
end
|
end
|
||||||
return api.nvim_win_get_var(winnr or 0, k)
|
return api.nvim_win_get_var(winnr or 0, k)
|
||||||
end
|
end
|
||||||
local function set(k, v) return api.nvim_win_set_var(winnr or 0, k, v) end
|
local function set(k, v)
|
||||||
local function del(k) return api.nvim_win_del_var(winnr or 0, k) end
|
return api.nvim_win_set_var(winnr or 0, k, v)
|
||||||
return make_meta_accessor(nil_wrap(get), set, del)
|
end
|
||||||
|
local function del(k)
|
||||||
|
return api.nvim_win_del_var(winnr or 0, k)
|
||||||
|
end
|
||||||
|
return make_meta_accessor(nil_wrap(get), set, del)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function new_win_opt_accessor(winnr)
|
local function new_win_opt_accessor(winnr)
|
||||||
local function get(k)
|
local function get(k)
|
||||||
if winnr == nil and type(k) == 'number' then
|
if winnr == nil and type(k) == "number" then
|
||||||
return new_win_opt_accessor(k)
|
return new_win_opt_accessor(k)
|
||||||
end
|
end
|
||||||
return api.nvim_win_get_option(winnr or 0, k)
|
return api.nvim_win_get_option(winnr or 0, k)
|
||||||
end
|
end
|
||||||
local function set(k, v) return api.nvim_win_set_option(winnr or 0, k, v) end
|
local function set(k, v)
|
||||||
return make_meta_accessor(nil_wrap(get), set)
|
return api.nvim_win_set_option(winnr or 0, k, v)
|
||||||
|
end
|
||||||
|
return make_meta_accessor(nil_wrap(get), set)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function new_buf_accessor(bufnr)
|
local function new_buf_accessor(bufnr)
|
||||||
local function get(k)
|
local function get(k)
|
||||||
if bufnr == nil and type(k) == 'number' then
|
if bufnr == nil and type(k) == "number" then
|
||||||
return new_buf_accessor(k)
|
return new_buf_accessor(k)
|
||||||
end
|
end
|
||||||
return api.nvim_buf_get_var(bufnr or 0, k)
|
return api.nvim_buf_get_var(bufnr or 0, k)
|
||||||
end
|
end
|
||||||
local function set(k, v) return api.nvim_buf_set_var(bufnr or 0, k, v) end
|
local function set(k, v)
|
||||||
local function del(k) return api.nvim_buf_del_var(bufnr or 0, k) end
|
return api.nvim_buf_set_var(bufnr or 0, k, v)
|
||||||
return make_meta_accessor(nil_wrap(get), set, del)
|
end
|
||||||
|
local function del(k)
|
||||||
|
return api.nvim_buf_del_var(bufnr or 0, k)
|
||||||
|
end
|
||||||
|
return make_meta_accessor(nil_wrap(get), set, del)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function new_buf_opt_accessor(bufnr)
|
local function new_buf_opt_accessor(bufnr)
|
||||||
local function get(k)
|
local function get(k)
|
||||||
if window_options[k] then
|
if window_options[k] then
|
||||||
return api.nvim_err_writeln(k.." is a window option, not a buffer option")
|
return api.nvim_err_writeln(k .. " is a window option, not a buffer option")
|
||||||
end
|
end
|
||||||
if bufnr == nil and type(k) == 'number' then
|
if bufnr == nil and type(k) == "number" then
|
||||||
return new_buf_opt_accessor(k)
|
return new_buf_opt_accessor(k)
|
||||||
end
|
end
|
||||||
return api.nvim_buf_get_option(bufnr or 0, k)
|
return api.nvim_buf_get_option(bufnr or 0, k)
|
||||||
end
|
end
|
||||||
local function set(k, v)
|
local function set(k, v)
|
||||||
if window_options[k] then
|
if window_options[k] then
|
||||||
return api.nvim_err_writeln(k.." is a window option, not a buffer option")
|
return api.nvim_err_writeln(k .. " is a window option, not a buffer option")
|
||||||
end
|
end
|
||||||
return api.nvim_buf_set_option(bufnr or 0, k, v)
|
return api.nvim_buf_set_option(bufnr or 0, k, v)
|
||||||
end
|
end
|
||||||
return make_meta_accessor(nil_wrap(get), set)
|
return make_meta_accessor(nil_wrap(get), set)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- `nvim.$method(...)` redirects to `nvim.api.nvim_$method(...)`
|
-- `nvim.$method(...)` redirects to `nvim.api.nvim_$method(...)`
|
||||||
@ -182,39 +264,45 @@ end
|
|||||||
-- `nvim.echo(...)` is approximately `echo table.concat({...}, '\n')`
|
-- `nvim.echo(...)` is approximately `echo table.concat({...}, '\n')`
|
||||||
-- Both methods cache the inital lookup in the metatable, but there is api small overhead regardless.
|
-- Both methods cache the inital lookup in the metatable, but there is api small overhead regardless.
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
print = nvim_print;
|
print = nvim_print,
|
||||||
echo = nvim_echo;
|
echo = nvim_echo,
|
||||||
fn = rawget(vim, "fn") or fn;
|
fn = rawget(vim, "fn") or fn,
|
||||||
validate = validate;
|
validate = validate,
|
||||||
g = rawget(vim, 'g') or make_meta_accessor(nil_wrap(api.nvim_get_var), api.nvim_set_var, api.nvim_del_var);
|
g = rawget(vim, "g") or make_meta_accessor(nil_wrap(api.nvim_get_var), api.nvim_set_var, api.nvim_del_var),
|
||||||
v = rawget(vim, 'v') or make_meta_accessor(nil_wrap(api.nvim_get_vvar), api.nvim_set_vvar);
|
v = rawget(vim, "v") or make_meta_accessor(nil_wrap(api.nvim_get_vvar), api.nvim_set_vvar),
|
||||||
o = rawget(vim, 'o') or make_meta_accessor(api.nvim_get_option, api.nvim_set_option);
|
o = rawget(vim, "o") or make_meta_accessor(api.nvim_get_option, api.nvim_set_option),
|
||||||
w = new_win_accessor(nil);
|
w = new_win_accessor(nil),
|
||||||
b = new_buf_accessor(nil);
|
b = new_buf_accessor(nil),
|
||||||
env = rawget(vim, "env") or make_meta_accessor(getenv, fn.setenv);
|
env = rawget(vim, "env") or make_meta_accessor(getenv, fn.setenv),
|
||||||
wo = rawget(vim, "wo") or new_win_opt_accessor(nil);
|
wo = rawget(vim, "wo") or new_win_opt_accessor(nil),
|
||||||
bo = rawget(vim, "bo") or new_buf_opt_accessor(nil);
|
bo = rawget(vim, "bo") or new_buf_opt_accessor(nil),
|
||||||
buf = {
|
buf = {
|
||||||
line = api.nvim_get_current_line;
|
line = api.nvim_get_current_line,
|
||||||
nr = api.nvim_get_current_buf;
|
nr = api.nvim_get_current_buf,
|
||||||
};
|
},
|
||||||
ex = setmetatable({}, {
|
ex = setmetatable({}, {
|
||||||
__index = function(t, k)
|
__index = function(t, k)
|
||||||
local command = k:gsub("_$", "!")
|
local command = k:gsub("_$", "!")
|
||||||
local f = function(...)
|
local f = function(...)
|
||||||
return api.nvim_command(table.concat(vim.tbl_flatten {command, ...}, " "))
|
local flattened = nil
|
||||||
end
|
if vim.iter then
|
||||||
rawset(t, k, f)
|
flattened = vim.iter({ command, ... }):flatten():totable()
|
||||||
return f
|
else
|
||||||
end
|
flattened = vim.tbl_flatten({ command, ... })
|
||||||
});
|
end
|
||||||
|
return api.nvim_command(table.concat(flattened, " "))
|
||||||
|
end
|
||||||
|
rawset(t, k, f)
|
||||||
|
return f
|
||||||
|
end,
|
||||||
|
}),
|
||||||
}, {
|
}, {
|
||||||
__index = function(t, k)
|
__index = function(t, k)
|
||||||
local f = api['nvim_'..k]
|
local f = api["nvim_" .. k]
|
||||||
if f then
|
if f then
|
||||||
rawset(t, k, f)
|
rawset(t, k, f)
|
||||||
end
|
end
|
||||||
return f
|
return f
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
-- vim:et ts=2 sw=2
|
-- vim:et ts=2 sw=2
|
||||||
|
@ -41,10 +41,6 @@ local function glob_dir_newer_3f(a_dir, b_dir, expr, b_dir_path_fn)
|
|||||||
return newer_3f
|
return newer_3f
|
||||||
end
|
end
|
||||||
_2amodule_2a["glob-dir-newer?"] = glob_dir_newer_3f
|
_2amodule_2a["glob-dir-newer?"] = glob_dir_newer_3f
|
||||||
local function macro_file_path_3f(path)
|
|
||||||
return a["string?"](string.match(path, "macros?.fnl$"))
|
|
||||||
end
|
|
||||||
_2amodule_2a["macro-file-path?"] = macro_file_path_3f
|
|
||||||
local path_sep
|
local path_sep
|
||||||
do
|
do
|
||||||
local os = string.lower(jit.os)
|
local os = string.lower(jit.os)
|
||||||
@ -55,4 +51,8 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
_2amodule_2a["path-sep"] = path_sep
|
_2amodule_2a["path-sep"] = path_sep
|
||||||
|
local function macro_file_path_3f(path)
|
||||||
|
return (a["string?"](string.match(path, "macros?.fnl$")) or a["string?"](string.match(path, (path_sep .. "macros?" .. path_sep))))
|
||||||
|
end
|
||||||
|
_2amodule_2a["macro-file-path?"] = macro_file_path_3f
|
||||||
return _2amodule_2a
|
return _2amodule_2a
|
||||||
|
@ -117,10 +117,17 @@
|
|||||||
(fn [mod-fn args]
|
(fn [mod-fn args]
|
||||||
(if (seq? args)
|
(if (seq? args)
|
||||||
;; If it's sequential, we execute the fn for side effects.
|
;; If it's sequential, we execute the fn for side effects.
|
||||||
|
;; Works for (require-macros :name) (deprecated in Fennel 0.4.0).
|
||||||
(each [_ arg (ipairs args)]
|
(each [_ arg (ipairs args)]
|
||||||
(=> (sym :_) `(,mod-fn ,(tostring arg))))
|
;; When arg is ALSO sequential it means we're sending multiple args for side effects.
|
||||||
|
;; This works well for (import-macros bind :name)
|
||||||
|
(=> (sym :_)
|
||||||
|
(if (seq? arg)
|
||||||
|
`(,mod-fn ,(unpack arg))
|
||||||
|
`(,mod-fn ,(tostring arg)))))
|
||||||
|
|
||||||
;; Otherwise we need to bind the execution to a name.
|
;; Otherwise we need to bind the execution to a name.
|
||||||
|
;; Works for simple (require :name) calls, binding the result.
|
||||||
(sorted-each
|
(sorted-each
|
||||||
(fn [bind arg]
|
(fn [bind arg]
|
||||||
(=> (ensure-sym bind) `(,mod-fn ,(tostring arg))))
|
(=> (ensure-sym bind) `(,mod-fn ,(tostring arg))))
|
||||||
|
27
lua/conjure-macroexpand/aniseed/macros/autocmds.fnl
Normal file
27
lua/conjure-macroexpand/aniseed/macros/autocmds.fnl
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
(fn autocmd [event opt]
|
||||||
|
`(vim.api.nvim_create_autocmd
|
||||||
|
,event ,opt))
|
||||||
|
|
||||||
|
(fn autocmds [...]
|
||||||
|
(var form `(do))
|
||||||
|
(each [_ v (ipairs [...])]
|
||||||
|
(table.insert form (autocmd (unpack v))))
|
||||||
|
(table.insert form 'nil)
|
||||||
|
form)
|
||||||
|
|
||||||
|
(fn augroup [name ...]
|
||||||
|
(var cmds `(do))
|
||||||
|
(var group (sym :group))
|
||||||
|
(each [_ v (ipairs [...])]
|
||||||
|
(let [(event opt) (unpack v)]
|
||||||
|
(tset opt :group group)
|
||||||
|
(table.insert cmds (autocmd event opt))))
|
||||||
|
(table.insert cmds 'nil)
|
||||||
|
`(let [,group
|
||||||
|
(vim.api.nvim_create_augroup ,name {:clear true})]
|
||||||
|
,cmds
|
||||||
|
,group))
|
||||||
|
|
||||||
|
{:autocmd autocmd
|
||||||
|
:autocmds autocmds
|
||||||
|
:augroup augroup}
|
@ -132,16 +132,20 @@ local function run_all()
|
|||||||
end
|
end
|
||||||
return totals
|
return totals
|
||||||
end
|
end
|
||||||
return display_results(a.reduce(_21_, {tests = 0, ["tests-passed"] = 0, assertions = 0, ["assertions-passed"] = 0}, a.filter(a["table?"], a.map(run, a.keys(_G.package.loaded)))), "[total]")
|
local function _22_(mod_name)
|
||||||
|
local mod = a.get(_G.package.loaded, mod_name)
|
||||||
|
return (not a["table?"](mod) or getmetatable(mod))
|
||||||
|
end
|
||||||
|
return display_results(a.reduce(_21_, {tests = 0, ["tests-passed"] = 0, assertions = 0, ["assertions-passed"] = 0}, a.filter(a["table?"], a.map(run, a.remove(_22_, a.keys(_G.package.loaded))))), "[total]")
|
||||||
end
|
end
|
||||||
_2amodule_2a["run-all"] = run_all
|
_2amodule_2a["run-all"] = run_all
|
||||||
local function suite()
|
local function suite()
|
||||||
do
|
do
|
||||||
local sep = fs["path-sep"]
|
local sep = fs["path-sep"]
|
||||||
local function _22_(path)
|
local function _23_(path)
|
||||||
return require(string.gsub(string.match(path, ("^test" .. sep .. "fnl" .. sep .. "(.-).fnl$")), sep, "."))
|
return require(string.gsub(string.match(path, ("^test" .. sep .. "fnl" .. sep .. "(.-).fnl$")), sep, "."))
|
||||||
end
|
end
|
||||||
a["run!"](_22_, nvim.fn.globpath(("test" .. sep .. "fnl"), "**/*-test.fnl", false, true))
|
a["run!"](_23_, nvim.fn.globpath(("test" .. sep .. "fnl"), "**/*-test.fnl", false, true))
|
||||||
end
|
end
|
||||||
if ok_3f(run_all()) then
|
if ok_3f(run_all()) then
|
||||||
return nvim.ex.q()
|
return nvim.ex.q()
|
||||||
|
@ -48,19 +48,68 @@ local function clj_macroexpand(expand_cmd)
|
|||||||
return clj_client(eval["eval-str"], {origin = "conjure-macroexpand", code = me_form, ["passive?"] = true, ["on-result"] = output_expanded(me_form)})
|
return clj_client(eval["eval-str"], {origin = "conjure-macroexpand", code = me_form, ["passive?"] = true, ["on-result"] = output_expanded(me_form)})
|
||||||
end
|
end
|
||||||
_2amodule_2a["clj-macroexpand"] = clj_macroexpand
|
_2amodule_2a["clj-macroexpand"] = clj_macroexpand
|
||||||
|
local function wrap_emit(name, f)
|
||||||
|
local function _4_(...)
|
||||||
|
event.emit(name)
|
||||||
|
return f(...)
|
||||||
|
end
|
||||||
|
return _4_
|
||||||
|
end
|
||||||
|
_2amodule_2a["wrap-emit"] = wrap_emit
|
||||||
|
local dir_str = wrap_emit("doc", __fnl_global__client_2dexec_2dfn("doc", "doc-str"))
|
||||||
|
local function dir_word()
|
||||||
|
local _let_5_ = extract.word()
|
||||||
|
local content = _let_5_["content"]
|
||||||
|
local range = _let_5_["range"]
|
||||||
|
local node = _let_5_["node"]
|
||||||
|
if not core["empty?"](content) then
|
||||||
|
return dir_str({code = content, range = range, node = node, origin = "word"})
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_2amodule_2a["dir-word"] = dir_word
|
||||||
|
local function replace_form()
|
||||||
|
local buf = vim.api.nvim_win_get_buf(0)
|
||||||
|
local win = vim.api.nvim_tabpage_get_win(0)
|
||||||
|
local form = extract.form({})
|
||||||
|
if form then
|
||||||
|
local _let_7_ = form
|
||||||
|
local content = _let_7_["content"]
|
||||||
|
local range = _let_7_["range"]
|
||||||
|
local node = _let_7_["node"]
|
||||||
|
local function _8_(result)
|
||||||
|
buffer.replacerange(buf, range, result)
|
||||||
|
return editor["go-to"](win, core["get-in"](range, {"start", 1}), core.inc(core["get-in"](range, {"start", 2})))
|
||||||
|
end
|
||||||
|
__fnl_global__eval_2dstr({code = content, range = range, node = node, origin = "replace-form", ["suppress-hud?"] = true, ["on-result"] = _8_})
|
||||||
|
return ("(clojure.core/macroexpand1 " .. form .. ")")
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_2amodule_2a["replace-form"] = replace_form
|
||||||
local function add_buf_mappings()
|
local function add_buf_mappings()
|
||||||
local function _4_()
|
local function _10_()
|
||||||
return clj_macroexpand()
|
return clj_macroexpand()
|
||||||
end
|
end
|
||||||
mapping.buf("CljMacroexpand", "cm", _4_, {desc = "Call macroexpand-all on the symbol under the cursor"})
|
mapping.buf("CljMacroexpand", "cm", _10_, {desc = "Call macroexpand-all on the symbol under the cursor"})
|
||||||
local function _5_()
|
local function _11_()
|
||||||
return clj_macroexpand("clojure.core/macroexpand")
|
return clj_macroexpand("clojure.core/macroexpand")
|
||||||
end
|
end
|
||||||
mapping.buf("CljMacroexpand0", "c0", _5_, {desc = "Call macroexpand on the symbol under the cursor"})
|
mapping.buf("CljMacroexpand0", "c0", _11_, {desc = "Call macroexpand on the symbol under the cursor"})
|
||||||
local function _6_()
|
local function _12_()
|
||||||
return clj_macroexpand("clojure.core/macroexpand-1")
|
return clj_macroexpand("clojure.core/macroexpand-1")
|
||||||
end
|
end
|
||||||
return mapping.buf("CljMacroexpand1", "c1", _6_, {desc = "Call macroexpand-1 on the symbol under the cursor"})
|
mapping.buf("CljMacroexpand1", "c1", _12_, {desc = "Call macroexpand-1 on the symbol under the cursor"})
|
||||||
|
local function _13_()
|
||||||
|
return replace_form()
|
||||||
|
end
|
||||||
|
mapping.buf("CljMacroexpandReplace", "em!", _13_, {desc = "Call macroexpand-1 on the symbol under the cursor then replace that src with the expansion"})
|
||||||
|
local function _14_()
|
||||||
|
return dir_word()
|
||||||
|
end
|
||||||
|
return mapping.buf("CljDirWord", "em!", _14_, {desc = "Calls (clojure.repl/dir ,,,) for the namespace 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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user