bomberpac/wrap.fnl

36 lines
1 KiB
Plaintext
Raw Normal View History

2021-02-07 21:56:19 +00:00
(local editor (require :editor))
(local game (require :game))
(local util (require :lib.util))
(local lume (require :lib.lume))
(local core (require :core))
(local command (require :core.command))
(local keymap (require :core.keymap))
(local translate (require :core.doc.translate))
2022-04-03 03:37:19 +00:00
(fn get-modname []
(-> core.active_view.doc.filename
(: :gsub "%.%a+$" "")
(: :gsub "/" ".")
(: :gsub "^data%." "")
(: :gsub "%.init$" "")))
2021-02-07 21:56:19 +00:00
(command.add "core.docview" {
"lume:hotswap" (fn []
2022-04-03 03:37:19 +00:00
(local modname (get-modname))
2021-02-07 21:56:19 +00:00
(core.log (.. "Hotswapping " modname))
(local (mod err) (util.hotswap modname))
(when (not= err nil) (print err) (error err)))
2022-04-03 03:37:19 +00:00
"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")))))
2021-02-07 21:56:19 +00:00
})
(keymap.add {
"alt+r" "lume:hotswap"
2022-04-03 03:37:19 +00:00
"alt+u" "fennel:unload-macro"
2021-02-07 21:56:19 +00:00
})
{}