-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
require-macros hook #398
base: main
Are you sure you want to change the base?
require-macros hook #398
Conversation
I love this idea, thanks for bringing it up. I think it's a great idea to allow plugins to track dependencies between modules and the macros they load.
Different hooks call for different conventions. I would say that all hooks called from special forms ought to pass For the tense, I think Please consider implementing this plugin in such a way that it can be used standalone without the rest of Hotpot! I think it could be useful in many other contexts. |
a6ddb01
to
1f84666
Compare
1f84666
to
a8eb154
Compare
Took a long time to get back to this. I added a test, which is pretty basic, there wasn't an explicit hooks test that I could see. Can rename stuff to be more appropriate with guidance. Passing the AST through, I am only ever seeing It does makes sense that the filename might be ; In my plugin for :require-macros ([ast scope]) ...
fennel.view ast =>
(import-macros "astre.macros.settings")
vim.inspect ast =>
{ { "import-macros",
filename = "src/fennel/macros.fnl",
line = 327,
quoted = true,
<metatable> = { "SYMBOL",
__eq = <function 1>,
__fennelview = <function 2>,
__lt = <function 3>,
__tostring = <function 2>
}
}, "astre.macros.settings",
bytestart = 13118,
filename = "src/fennel/macros.fnl",
line = 327,
<metatable> = { "LIST",
__fennelview = <function 4>,
__tostring = <function 4>
}
} One thing I thought about was naming it
Maybe the hook should be |
Try grepping the test dir for
This is because of an implementation quirk of The way Normally the The test you've added is a start, but it would be better if the test could check for something other than "the function in the plugin actually ran or not". Could it be expanded to check that it's able to have some kind of effect on the code which ran, or check that the arguments have at least some connection to the macros in question? |
Hotpot tracks "macro files" as dependencies for regular Fennel code, so if a macro is edited, any files that
import-macro
'd that file are also re-compiled.It does this by a custom macro searcher, and a small patch to Fennel itself that disabled the
macro-loaded
cache, so that the searcher is always called (so every import passes through the searcher).rktjmp/hotpot.nvim@f9a4c29
This PR adds an new hook
required-macro
that passes themodname
, which would let Hotpot use a compiler plugin instead and remove the need to patch Fennel.I aware this:
ast
orscope
), thoughdestructure
doesn't either. Perhaps it could passast scope modname
.Would something like this ever make it into Fennel or is it a bit too off the mark for what the compiler plugins are intended for?