Add lite command to unload macros

This commit is contained in:
Jeremy Penner 2022-04-02 23:37:19 -04:00
parent 926d808a92
commit f33b0cd695

View file

@ -7,22 +7,31 @@
(local keymap (require :core.keymap))
(local translate (require :core.doc.translate))
(command.add "core.docview" {
"fennel:eval" #(editor.inline-eval #(fv (fennel.eval $1 {:env _G :compiler-env _G}) {}))
"lume:hotswap" (fn []
(local modname
(fn get-modname []
(-> core.active_view.doc.filename
(: :gsub "%.%a+$" "")
(: :gsub "/" ".")
(: :gsub "^data%." "")
(: :gsub "%.init$" "")))
(command.add "core.docview" {
"fennel:eval" #(editor.inline-eval #(fv (fennel.eval $1 {:env _G :compiler-env _G}) {}))
"lume:hotswap" (fn []
(local modname (get-modname))
(core.log (.. "Hotswapping " modname))
(local (mod err) (util.hotswap modname))
(when (not= err nil) (print err) (error err)))
"fennel:unload-macro" (fn []
(let [modname (get-modname)]
(if (. fennel.macro-loaded modname)
(do (core.log (.. "Unloading macro module " modname))
(tset fennel.macro-loaded modname nil))
(core.log (.. modname " was not a loaded macro module")))))
})
(keymap.add {
"alt+e" "fennel:eval"
"alt+r" "lume:hotswap"
"alt+u" "fennel:unload-macro"
})
{}