add initial commands
This commit is contained in:
parent
ec39d6090d
commit
5ac385a063
2
Makefile
2
Makefile
@ -10,7 +10,7 @@ compile:
|
|||||||
deps/aniseed/scripts/compile.sh
|
deps/aniseed/scripts/compile.sh
|
||||||
|
|
||||||
# Remove this if you only want Aniseed at compile time.
|
# Remove this if you only want Aniseed at compile time.
|
||||||
deps/aniseed/scripts/embed.sh aniseed conjure-macroexpand
|
deps/aniseed/scripts/embed.sh aniseed conjure-macroreplace
|
||||||
|
|
||||||
test:
|
test:
|
||||||
rm -rf test/lua
|
rm -rf test/lua
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
(module conjure-macroexpand.main
|
|
||||||
{require {a aniseed.core
|
|
||||||
nvim aniseed.nvim
|
|
||||||
str aniseed.string
|
|
||||||
bridge conjure.bridge
|
|
||||||
client conjure.client
|
|
||||||
eval conjure.eval
|
|
||||||
extract conjure.extract
|
|
||||||
log conjure.log
|
|
||||||
mapping conjure.mapping}})
|
|
||||||
|
|
||||||
;; Adapted from conjure.eval/current-form
|
|
||||||
(defn- current-form []
|
|
||||||
(let [form (extract.form {})]
|
|
||||||
(when form
|
|
||||||
(let [{: content} form]
|
|
||||||
content))))
|
|
||||||
|
|
||||||
(defn- clj-client [f args]
|
|
||||||
(client.with-filetype "clojure" f args))
|
|
||||||
|
|
||||||
(defn- output-expanded [orig]
|
|
||||||
(fn [r]
|
|
||||||
(log.append (a.concat [(.. "; " orig)] (str.split r "\n")) {:break? true})))
|
|
||||||
|
|
||||||
(defn clj-macroexpand [expand-cmd]
|
|
||||||
(let [form (current-form)
|
|
||||||
me-form (.. "(" (or expand-cmd "clojure.walk/macroexpand-all") " '" form ")")]
|
|
||||||
(clj-client eval.eval-str
|
|
||||||
{:origin :conjure-macroexpand
|
|
||||||
:code me-form
|
|
||||||
:passive? true
|
|
||||||
: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 []
|
|
||||||
(mapping.buf :CljMacroexpand "cm" #(clj-macroexpand)
|
|
||||||
{:desc "Call macroexpand-all on the symbol under the cursor"})
|
|
||||||
(mapping.buf :CljMacroexpand0 "c0" #(clj-macroexpand "clojure.core/macroexpand")
|
|
||||||
{:desc "Call macroexpand on the symbol under the cursor"})
|
|
||||||
(mapping.buf :CljMacroexpand1 "c1" #(clj-macroexpand "clojure.core/macroexpand-1")
|
|
||||||
{: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 []
|
|
||||||
(when (or (not nvim.g.conjure_macroexpand_disable_mappings)
|
|
||||||
(= 0 nvim.g.conjure_macroexpand_disable_mappings))
|
|
||||||
(nvim.ex.autocmd
|
|
||||||
:FileType "clojure"
|
|
||||||
(bridge.viml->lua :conjure-macroexpand.main :add-buf-mappings))))
|
|
86
fnl/conjure-macroreplace/main.fnl
Normal file
86
fnl/conjure-macroreplace/main.fnl
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
(module conjure-macroreplace.main
|
||||||
|
{require {a aniseed.core
|
||||||
|
nvim aniseed.nvim
|
||||||
|
str aniseed.string
|
||||||
|
bridge conjure.bridge
|
||||||
|
client conjure.client
|
||||||
|
eval conjure.eval
|
||||||
|
extract conjure.extract
|
||||||
|
log conjure.log
|
||||||
|
mapping conjure.mapping
|
||||||
|
buffer conjure.buffer
|
||||||
|
editor conjure.editor}})
|
||||||
|
|
||||||
|
;; Adapted from conjure.eval/current-form
|
||||||
|
(defn- current-form []
|
||||||
|
(let [form (extract.form {})]
|
||||||
|
(when form
|
||||||
|
(let [{: content} form]
|
||||||
|
content))))
|
||||||
|
|
||||||
|
(defn- clj-client [f args]
|
||||||
|
(client.with-filetype "clojure" f args))
|
||||||
|
|
||||||
|
(defn- output-expanded [orig]
|
||||||
|
(fn [r]
|
||||||
|
(log.append (a.concat [(.. "; " orig)] (str.split r "\n")) {:break? true})))
|
||||||
|
|
||||||
|
(defn clj-macroexpand [expand-cmd]
|
||||||
|
(let [form (current-form)
|
||||||
|
me-form (.. "(" (or expand-cmd "clojure.walk/macroexpand-all") " '" form ")")]
|
||||||
|
(clj-client eval.eval-str
|
||||||
|
{:origin :conjure-macroexpand
|
||||||
|
:code me-form
|
||||||
|
:passive? true
|
||||||
|
:on-result (output-expanded me-form)})))
|
||||||
|
|
||||||
|
(defn- dir-word []
|
||||||
|
(let [{: content : range : node} (extract.word)]
|
||||||
|
(when (not (a.empty? content))
|
||||||
|
(let [dir-code (.. "(clojure.repl/dir " content ")")]
|
||||||
|
(clj-client eval.eval-str
|
||||||
|
{:code dir-code
|
||||||
|
:range range
|
||||||
|
:node node
|
||||||
|
:origin :word})))))
|
||||||
|
|
||||||
|
(defn- replace-with-expanded-form []
|
||||||
|
(let [form (extract.form {})]
|
||||||
|
(when form
|
||||||
|
(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 ")")]
|
||||||
|
(clj-client eval.eval-str
|
||||||
|
{:origin :conjure-macroreplace
|
||||||
|
:code me-form
|
||||||
|
:passive? true
|
||||||
|
:on-result
|
||||||
|
(fn [result]
|
||||||
|
(buffer.replace-range
|
||||||
|
buf
|
||||||
|
range result)
|
||||||
|
(editor.go-to
|
||||||
|
win
|
||||||
|
(a.get-in range [:start 1])
|
||||||
|
(a.inc (a.get-in range [:start 2]))))})))))
|
||||||
|
|
||||||
|
|
||||||
|
(defn add-buf-mappings []
|
||||||
|
(mapping.buf :CljMacroexpand "cm" #(clj-macroexpand)
|
||||||
|
{:desc "Call macroexpand-all on the symbol under the cursor"})
|
||||||
|
(mapping.buf :CljMacroexpand0 "c0" #(clj-macroexpand "clojure.core/macroexpand")
|
||||||
|
{:desc "Call macroexpand on the symbol under the cursor"})
|
||||||
|
(mapping.buf :CljMacroexpand1 "c1" #(clj-macroexpand "clojure.core/macroexpand-1")
|
||||||
|
{:desc "Call macroexpand-1 on the symbol under the cursor"})
|
||||||
|
(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"}))
|
||||||
|
|
||||||
|
(defn init []
|
||||||
|
(when (or (not nvim.g.conjure_macroexpand_disable_mappings)
|
||||||
|
(= 0 nvim.g.conjure_macroexpand_disable_mappings))
|
||||||
|
(nvim.ex.autocmd
|
||||||
|
:FileType "clojure"
|
||||||
|
(bridge.viml->lua :conjure-macroreplace.main :add-buf-mappings))))
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/autoload.fnl"
|
local _2afile_2a = "fnl/aniseed/autoload.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.autoload"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.autoload"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/compile.fnl"
|
local _2afile_2a = "fnl/aniseed/compile.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.compile"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.compile"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,14 +10,14 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
local autoload = (require("conjure-macroreplace.aniseed.autoload")).autoload
|
||||||
local a, fennel, fs, nvim = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.fennel"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim")
|
local a, fennel, fs, nvim = autoload("conjure-macroreplace.aniseed.core"), autoload("conjure-macroreplace.aniseed.fennel"), autoload("conjure-macroreplace.aniseed.fs"), autoload("conjure-macroreplace.aniseed.nvim")
|
||||||
do end (_2amodule_locals_2a)["a"] = a
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
_2amodule_locals_2a["fennel"] = fennel
|
_2amodule_locals_2a["fennel"] = fennel
|
||||||
_2amodule_locals_2a["fs"] = fs
|
_2amodule_locals_2a["fs"] = fs
|
||||||
_2amodule_locals_2a["nvim"] = nvim
|
_2amodule_locals_2a["nvim"] = nvim
|
||||||
local function wrap_macros(code, opts)
|
local function wrap_macros(code, opts)
|
||||||
local macros_module = "conjure-macroexpand.aniseed.macros"
|
local macros_module = "conjure-macroreplace.aniseed.macros"
|
||||||
local filename
|
local filename
|
||||||
do
|
do
|
||||||
local _1_ = a.get(opts, "filename")
|
local _1_ = a.get(opts, "filename")
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/core.fnl"
|
local _2afile_2a = "fnl/aniseed/core.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.core"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.core"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,8 +10,8 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
local autoload = (require("conjure-macroreplace.aniseed.autoload")).autoload
|
||||||
local view = autoload("conjure-macroexpand.aniseed.view")
|
local view = autoload("conjure-macroreplace.aniseed.view")
|
||||||
do end (_2amodule_locals_2a)["view"] = view
|
do end (_2amodule_locals_2a)["view"] = view
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
local function rand(n)
|
local function rand(n)
|
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/env.fnl"
|
local _2afile_2a = "fnl/aniseed/env.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.env"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.env"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,8 +10,8 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
local autoload = (require("conjure-macroreplace.aniseed.autoload")).autoload
|
||||||
local compile, fennel, fs, nvim = autoload("conjure-macroexpand.aniseed.compile"), autoload("conjure-macroexpand.aniseed.fennel"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim")
|
local compile, fennel, fs, nvim = autoload("conjure-macroreplace.aniseed.compile"), autoload("conjure-macroreplace.aniseed.fennel"), autoload("conjure-macroreplace.aniseed.fs"), autoload("conjure-macroreplace.aniseed.nvim")
|
||||||
do end (_2amodule_locals_2a)["compile"] = compile
|
do end (_2amodule_locals_2a)["compile"] = compile
|
||||||
_2amodule_locals_2a["fennel"] = fennel
|
_2amodule_locals_2a["fennel"] = fennel
|
||||||
_2amodule_locals_2a["fs"] = fs
|
_2amodule_locals_2a["fs"] = fs
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/eval.fnl"
|
local _2afile_2a = "fnl/aniseed/eval.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.eval"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.eval"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,8 +10,8 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
local autoload = (require("conjure-macroreplace.aniseed.autoload")).autoload
|
||||||
local a, compile, fennel, fs, nvim = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.compile"), autoload("conjure-macroexpand.aniseed.fennel"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim")
|
local a, compile, fennel, fs, nvim = autoload("conjure-macroreplace.aniseed.core"), autoload("conjure-macroreplace.aniseed.compile"), autoload("conjure-macroreplace.aniseed.fennel"), autoload("conjure-macroreplace.aniseed.fs"), autoload("conjure-macroreplace.aniseed.nvim")
|
||||||
do end (_2amodule_locals_2a)["a"] = a
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
_2amodule_locals_2a["compile"] = compile
|
_2amodule_locals_2a["compile"] = compile
|
||||||
_2amodule_locals_2a["fennel"] = fennel
|
_2amodule_locals_2a["fennel"] = fennel
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/fennel.fnl"
|
local _2afile_2a = "fnl/aniseed/fennel.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.fennel"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.fennel"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,8 +10,8 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
local autoload = (require("conjure-macroreplace.aniseed.autoload")).autoload
|
||||||
local a, fs, nvim, str = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim"), autoload("conjure-macroexpand.aniseed.string")
|
local a, fs, nvim, str = autoload("conjure-macroreplace.aniseed.core"), autoload("conjure-macroreplace.aniseed.fs"), autoload("conjure-macroreplace.aniseed.nvim"), autoload("conjure-macroreplace.aniseed.string")
|
||||||
do end (_2amodule_locals_2a)["a"] = a
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
_2amodule_locals_2a["fs"] = fs
|
_2amodule_locals_2a["fs"] = fs
|
||||||
_2amodule_locals_2a["nvim"] = nvim
|
_2amodule_locals_2a["nvim"] = nvim
|
||||||
@ -37,7 +37,7 @@ _2amodule_2a["sync-rtp"] = sync_rtp
|
|||||||
local state = {["compiler-loaded?"] = false}
|
local state = {["compiler-loaded?"] = false}
|
||||||
_2amodule_locals_2a["state"] = state
|
_2amodule_locals_2a["state"] = state
|
||||||
local function impl()
|
local function impl()
|
||||||
local compiler = require("conjure-macroexpand.aniseed.deps.fennel")
|
local compiler = require("conjure-macroreplace.aniseed.deps.fennel")
|
||||||
if not state["compiler-loaded?"] then
|
if not state["compiler-loaded?"] then
|
||||||
state["compiler-loaded?"] = true
|
state["compiler-loaded?"] = true
|
||||||
sync_rtp(compiler)
|
sync_rtp(compiler)
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/fs.fnl"
|
local _2afile_2a = "fnl/aniseed/fs.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.fs"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.fs"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,8 +10,8 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
local autoload = (require("conjure-macroreplace.aniseed.autoload")).autoload
|
||||||
local a, nvim = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.nvim")
|
local a, nvim = autoload("conjure-macroreplace.aniseed.core"), autoload("conjure-macroreplace.aniseed.nvim")
|
||||||
do end (_2amodule_locals_2a)["a"] = a
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
_2amodule_locals_2a["nvim"] = nvim
|
_2amodule_locals_2a["nvim"] = nvim
|
||||||
local function basename(path)
|
local function basename(path)
|
@ -136,7 +136,7 @@
|
|||||||
|
|
||||||
;; Only require autoload if it's used.
|
;; Only require autoload if it's used.
|
||||||
(when (contains? mod-fns autoload-sym)
|
(when (contains? mod-fns autoload-sym)
|
||||||
(table.insert result `(local ,autoload-sym (. (require "conjure-macroexpand.aniseed.autoload") :autoload)))))
|
(table.insert result `(local ,autoload-sym (. (require "conjure-macroreplace.aniseed.autoload") :autoload)))))
|
||||||
|
|
||||||
;; When we have some keys insert the key/vals pairs locals.
|
;; When we have some keys insert the key/vals pairs locals.
|
||||||
;; If this is empty we end up generating invalid Lua.
|
;; If this is empty we end up generating invalid Lua.
|
@ -1,8 +1,8 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/nvim.fnl"
|
local _2afile_2a = "fnl/aniseed/nvim.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.nvim"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.nvim"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = require("conjure-macroexpand.aniseed.deps.nvim")
|
package.loaded[_2amodule_name_2a] = require("conjure-macroreplace.aniseed.deps.nvim")
|
||||||
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
_2amodule_2a = package.loaded[_2amodule_name_2a]
|
||||||
end
|
end
|
||||||
local _2amodule_locals_2a
|
local _2amodule_locals_2a
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/nvim/util.fnl"
|
local _2afile_2a = "fnl/aniseed/nvim/util.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.nvim.util"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.nvim.util"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,8 +10,8 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
local autoload = (require("conjure-macroreplace.aniseed.autoload")).autoload
|
||||||
local nvim = autoload("conjure-macroexpand.aniseed.nvim")
|
local nvim = autoload("conjure-macroreplace.aniseed.nvim")
|
||||||
do end (_2amodule_locals_2a)["nvim"] = nvim
|
do end (_2amodule_locals_2a)["nvim"] = nvim
|
||||||
local function normal(keys)
|
local function normal(keys)
|
||||||
return nvim.ex.silent(("exe \"normal! " .. keys .. "\""))
|
return nvim.ex.silent(("exe \"normal! " .. keys .. "\""))
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/setup.fnl"
|
local _2afile_2a = "fnl/aniseed/setup.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.setup"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.setup"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,8 +10,8 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
local autoload = (require("conjure-macroreplace.aniseed.autoload")).autoload
|
||||||
local a, env, eval, nvim = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.env"), autoload("conjure-macroexpand.aniseed.eval"), autoload("conjure-macroexpand.aniseed.nvim")
|
local a, env, eval, nvim = autoload("conjure-macroreplace.aniseed.core"), autoload("conjure-macroreplace.aniseed.env"), autoload("conjure-macroreplace.aniseed.eval"), autoload("conjure-macroreplace.aniseed.nvim")
|
||||||
do end (_2amodule_locals_2a)["a"] = a
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
_2amodule_locals_2a["env"] = env
|
_2amodule_locals_2a["env"] = env
|
||||||
_2amodule_locals_2a["eval"] = eval
|
_2amodule_locals_2a["eval"] = eval
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/string.fnl"
|
local _2afile_2a = "fnl/aniseed/string.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.string"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.string"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,8 +10,8 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
local autoload = (require("conjure-macroreplace.aniseed.autoload")).autoload
|
||||||
local a = autoload("conjure-macroexpand.aniseed.core")
|
local a = autoload("conjure-macroreplace.aniseed.core")
|
||||||
do end (_2amodule_locals_2a)["a"] = a
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
local function join(...)
|
local function join(...)
|
||||||
local args = {...}
|
local args = {...}
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/test.fnl"
|
local _2afile_2a = "fnl/aniseed/test.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.test"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.test"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,8 +10,8 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local autoload = (require("conjure-macroexpand.aniseed.autoload")).autoload
|
local autoload = (require("conjure-macroreplace.aniseed.autoload")).autoload
|
||||||
local a, fs, nvim, str = autoload("conjure-macroexpand.aniseed.core"), autoload("conjure-macroexpand.aniseed.fs"), autoload("conjure-macroexpand.aniseed.nvim"), autoload("conjure-macroexpand.aniseed.string")
|
local a, fs, nvim, str = autoload("conjure-macroreplace.aniseed.core"), autoload("conjure-macroreplace.aniseed.fs"), autoload("conjure-macroreplace.aniseed.nvim"), autoload("conjure-macroreplace.aniseed.string")
|
||||||
do end (_2amodule_locals_2a)["a"] = a
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
_2amodule_locals_2a["fs"] = fs
|
_2amodule_locals_2a["fs"] = fs
|
||||||
_2amodule_locals_2a["nvim"] = nvim
|
_2amodule_locals_2a["nvim"] = nvim
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/aniseed/view.fnl"
|
local _2afile_2a = "fnl/aniseed/view.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.aniseed.view"
|
local _2amodule_name_2a = "conjure-macroreplace.aniseed.view"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,7 +10,7 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local fnl = require("conjure-macroexpand.aniseed.fennel")
|
local fnl = require("conjure-macroreplace.aniseed.fennel")
|
||||||
do end (_2amodule_locals_2a)["fnl"] = fnl
|
do end (_2amodule_locals_2a)["fnl"] = fnl
|
||||||
local function serialise(...)
|
local function serialise(...)
|
||||||
return fnl.impl().view(...)
|
return fnl.impl().view(...)
|
@ -1,5 +1,5 @@
|
|||||||
local _2afile_2a = "fnl/conjure-macroexpand/main.fnl"
|
local _2afile_2a = "fnl/conjure-macroreplace/main.fnl"
|
||||||
local _2amodule_name_2a = "conjure-macroexpand.main"
|
local _2amodule_name_2a = "conjure-macroreplace.main"
|
||||||
local _2amodule_2a
|
local _2amodule_2a
|
||||||
do
|
do
|
||||||
package.loaded[_2amodule_name_2a] = {}
|
package.loaded[_2amodule_name_2a] = {}
|
||||||
@ -10,10 +10,12 @@ do
|
|||||||
_2amodule_2a["aniseed/locals"] = {}
|
_2amodule_2a["aniseed/locals"] = {}
|
||||||
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
_2amodule_locals_2a = (_2amodule_2a)["aniseed/locals"]
|
||||||
end
|
end
|
||||||
local a, bridge, client, eval, extract, log, mapping, nvim, str = require("conjure-macroexpand.aniseed.core"), require("conjure.bridge"), require("conjure.client"), require("conjure.eval"), require("conjure.extract"), require("conjure.log"), require("conjure.mapping"), require("conjure-macroexpand.aniseed.nvim"), require("conjure-macroexpand.aniseed.string")
|
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
|
do end (_2amodule_locals_2a)["a"] = a
|
||||||
_2amodule_locals_2a["bridge"] = bridge
|
_2amodule_locals_2a["bridge"] = bridge
|
||||||
|
_2amodule_locals_2a["buffer"] = buffer
|
||||||
_2amodule_locals_2a["client"] = client
|
_2amodule_locals_2a["client"] = client
|
||||||
|
_2amodule_locals_2a["editor"] = editor
|
||||||
_2amodule_locals_2a["eval"] = eval
|
_2amodule_locals_2a["eval"] = eval
|
||||||
_2amodule_locals_2a["extract"] = extract
|
_2amodule_locals_2a["extract"] = extract
|
||||||
_2amodule_locals_2a["log"] = log
|
_2amodule_locals_2a["log"] = log
|
||||||
@ -48,73 +50,64 @@ 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 function dir_word()
|
||||||
local _let_5_ = extract.word()
|
local _let_4_ = extract.word()
|
||||||
local content = _let_5_["content"]
|
local content = _let_4_["content"]
|
||||||
local range = _let_5_["range"]
|
local range = _let_4_["range"]
|
||||||
local node = _let_5_["node"]
|
local node = _let_4_["node"]
|
||||||
if not core["empty?"](content) then
|
if not a["empty?"](content) then
|
||||||
return dir_str({code = content, range = range, node = node, origin = "word"})
|
local dir_code = ("(clojure.repl/dir " .. content .. ")")
|
||||||
|
return clj_client(eval["eval-str"], {code = dir_code, range = range, node = node, origin = "word"})
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
_2amodule_2a["dir-word"] = dir_word
|
_2amodule_locals_2a["dir-word"] = dir_word
|
||||||
local function replace_form()
|
local function replace_with_expanded_form()
|
||||||
local buf = vim.api.nvim_win_get_buf(0)
|
|
||||||
local win = vim.api.nvim_tabpage_get_win(0)
|
|
||||||
local form = extract.form({})
|
local form = extract.form({})
|
||||||
if form then
|
if form then
|
||||||
local _let_7_ = form
|
local _let_6_ = form
|
||||||
local content = _let_7_["content"]
|
local content = _let_6_["content"]
|
||||||
local range = _let_7_["range"]
|
local range = _let_6_["range"]
|
||||||
local node = _let_7_["node"]
|
local buf = vim.api.nvim_win_get_buf(0)
|
||||||
local function _8_(result)
|
local win = vim.api.nvim_tabpage_get_win(0)
|
||||||
buffer.replacerange(buf, range, result)
|
local me_form = ("(" .. (__fnl_global__expand_2dcmd or "clojure.walk/macroexpand-all") .. " '" .. content .. ")")
|
||||||
return editor["go-to"](win, core["get-in"](range, {"start", 1}), core.inc(core["get-in"](range, {"start", 2})))
|
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
|
end
|
||||||
__fnl_global__eval_2dstr({code = content, range = range, node = node, origin = "replace-form", ["suppress-hud?"] = true, ["on-result"] = _8_})
|
return clj_client(eval["eval-str"], {origin = "conjure-macroreplace", code = me_form, ["passive?"] = true, ["on-result"] = _7_})
|
||||||
return ("(clojure.core/macroexpand1 " .. form .. ")")
|
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
_2amodule_2a["replace-form"] = replace_form
|
_2amodule_locals_2a["replace-with-expanded-form"] = replace_with_expanded_form
|
||||||
local function add_buf_mappings()
|
local function add_buf_mappings()
|
||||||
local function _10_()
|
local function _9_()
|
||||||
return clj_macroexpand()
|
return clj_macroexpand()
|
||||||
end
|
end
|
||||||
mapping.buf("CljMacroexpand", "cm", _10_, {desc = "Call macroexpand-all on the symbol under the cursor"})
|
mapping.buf("CljMacroexpand", "cm", _9_, {desc = "Call macroexpand-all on the symbol under the cursor"})
|
||||||
local function _11_()
|
local function _10_()
|
||||||
return clj_macroexpand("clojure.core/macroexpand")
|
return clj_macroexpand("clojure.core/macroexpand")
|
||||||
end
|
end
|
||||||
mapping.buf("CljMacroexpand0", "c0", _11_, {desc = "Call macroexpand on the symbol under the cursor"})
|
mapping.buf("CljMacroexpand0", "c0", _10_, {desc = "Call macroexpand on the symbol under the cursor"})
|
||||||
local function _12_()
|
local function _11_()
|
||||||
return clj_macroexpand("clojure.core/macroexpand-1")
|
return clj_macroexpand("clojure.core/macroexpand-1")
|
||||||
end
|
end
|
||||||
mapping.buf("CljMacroexpand1", "c1", _12_, {desc = "Call macroexpand-1 on the symbol under the cursor"})
|
mapping.buf("CljMacroexpand1", "c1", _11_, {desc = "Call macroexpand-1 on the symbol under the cursor"})
|
||||||
local function _13_()
|
local function _12_()
|
||||||
return replace_form()
|
return replace_with_expanded_form()
|
||||||
end
|
end
|
||||||
mapping.buf("CljMacroexpandReplace", "em!", _13_, {desc = "Call macroexpand-1 on the symbol under the cursor then replace that src with the expansion"})
|
mapping.buf("CljMacroexpandReplace", "mr", _12_, {desc = "Call macroexpand-1 on the symbol under the cursor then replace that src with the expansion"})
|
||||||
local function _14_()
|
local function _13_()
|
||||||
return dir_word()
|
return dir_word()
|
||||||
end
|
end
|
||||||
return mapping.buf("CljDirWord", "em!", _14_, {desc = "Calls (clojure.repl/dir ,,,) for the namespace under the cursor"})
|
return mapping.buf("CljDirWord", "dw", _13_, {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()
|
||||||
if (not nvim.g.conjure_macroexpand_disable_mappings or (0 == nvim.g.conjure_macroexpand_disable_mappings)) then
|
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-macroexpand.main", "add-buf-mappings"))
|
return nvim.ex.autocmd("FileType", "clojure", bridge["viml->lua"]("conjure-macroreplace.main", "add-buf-mappings"))
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
@ -1,3 +0,0 @@
|
|||||||
if has("nvim")
|
|
||||||
lua require("conjure-macroexpand.main").init()
|
|
||||||
endif
|
|
3
plugin/conjure-macroreplace.vim
Normal file
3
plugin/conjure-macroreplace.vim
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
if has("nvim")
|
||||||
|
lua require("conjure-macroreplace.main").init()
|
||||||
|
endif
|
@ -1,4 +1,4 @@
|
|||||||
(module conjure-macroexpand.main-test)
|
(module conjure-macroreplace.main-test)
|
||||||
|
|
||||||
(deftest something-simple
|
(deftest something-simple
|
||||||
(t.= 1 1 "1 should equal 1, I hope!"))
|
(t.= 1 1 "1 should equal 1, I hope!"))
|
Loading…
x
Reference in New Issue
Block a user