hotpot.nvim
hotpot.nvim copied to clipboard
Use cljlib-fennel with Hotpot?
I'm wondering how to use cljlib
with hotpot. I clone the lib inside fnl
folder, however Hotpot compiler results in an error saying module not found.
Likely cljlib/init-macros.fnl#858 calling trying to require
a macro-file instead of import-macros
which hits the module loader (because its requesting a module not a macro) which uses non-macro compiler settings (because its for modules, not macros).
Also cljlib requires 1.2.0 which isn't released yet: https://lists.sr.ht/~technomancy/fennel/%3C874jy5wid1.fsf%40gmail.com%3E
Unsure what the correct behaviour is, perhaps this is a change in 1.2.0 that will "just work" once its released, probably there is some under the hood changes needed in hotpot to match the behaviour of "are we in a macro? should we require or eval this?" but honestly that sounds pretty gross, how do I know if I'm supposed to require a "macro module" or some just-lua lib?
Needs more investigation once 1.2.0 is out.
Thank you so much, hopefully the prob would be sorted out when v1.2.0 released.
I think if you use this fork https://github.com/rktjmp/fennel-cljlib/ cljlib should now work?
The install instructions have changed since this was opened, you how have to set the package.path
.
Internally it makes a direct (require :lazy-seq)
call, so you must update the package path as instructed. For me that was:
(let [root (vim.fn.stdpath :config)
path (.. root :/fnl/cljlib)]
(set package.path (string.format "%s;%s;%s"
(.. path "/?/init.lua")
;; readme doesn't say to add this one but it's idiomatic to include both the `?.lua` and `?/init.lua` paths.
(.. path "/?.lua")
package.path)))
(local clj (require :cljlib))
(import-macros cljm :cljlib)
(print (clj.add 1 2 3))
(cljm.time (do
(for [i 1 10000000] i)))
I just cloned it into .config/nvim/fnl/cljlib
(and got the submodules) which effectively puts it in the main cljlib package in "neovims lua package root" if you want to call it that. If you put it in some nested subdir you might have to muck around with package.path
a bit more.
Hopefully the patch can be up streamed, have to check with Andrey if he has opinions on the change.
https://github.com/rktjmp/fennel-cljlib/commit/8b58117962c51f72da211ea0c06e4c0aea3f74e9
Many thanks, I can confirm it worked!