Closed russtoku closed 1 year ago
That looks correct to me! The only time it shouldn't write the file is if there was a compilation error. In that case you should see the error in your :messages
or in a nvim-notify floating window if you have the plugin installed. I'll maybe add a message when it compiles successfully or a debug flag of some kind so we can see what's going on here 🤔
And I guess it worked at least once since you have some compiled Lua output.
If you can reproduce this, please let me know how. I tried to break the plugin but it compiled just fine even when my Neovim was in the wrong working directory etc.
As long as the autocmds are setup at FileType time then it should work fine. nfnl builds autocmds for the specific paths with the local project config in the Lua closure.
So once the autocmds are set up that directory has all the magic associated with it. I could see this breaking if you move/rename the parent directories while Neovim is still open though. Then you'll need to :e
inside your Fennel buffers again for the autocmds to be recreated under the new path.
In my example above, I manually compiled the Fennel file with:
:lua require('nfnl')['compile-all-files']()
When I start Neovim, here are no autocmds for nfnl
associated with the fennel filetype:
:au * fennel
--- Autocommands ---
lspconfig FileType
fennel <Lua 57: ~/.local/share/nvim/site/pack/packer/start/nvim-lspconfig/lua/lspconfig/configs.lua:106> [Checks whether server fennel_language_server should start a new instance or attach to an existing
conjure_init_filetypes FileType
fennel lua require('conjure.mapping')['on-filetype']()
sexp_filetypes FileType
fennel call s:sexp_create_mappings()
sexp_mappings_for_regular_people FileType
fennel call s:sexp_mappings()
My ~/.config/nvim/fnl/magic/init.fnl
file has this:
(plugin.use
:Olical/aniseed {}
:Olical/conjure {:mod :conjure}
:Olical/nfnl {}
...
After I call setup
like so:
:lua require('nfnl')['setup']()
I see that this autocmd is created:
:au nfnl-setup
--- Autocommands ---
nfnl-setup FileType
fennel <Lua 263: ~/.local/share/nvim/site/pack/packer/start/nfnl/lua/nfnl/callback.lua:15>
Then I see that when I save a .fnl
file it is compiled.
If I change my ~/.config/nvim/fnl/magic/init.fnl
file to call the setup
function of nfnl
like so:
(plugin.use
:Olical/aniseed {}
:Olical/conjure {:mod :conjure}
:Olical/nfnl {:mod :nfnl}
...
and ~/.config/nvim/fnl/magic/plugin/nfnl.fnl
to have:
(module magic.plugin.nfnl)
(let [(ok? aplugin) (pcall #(require :nfnl))]
(when ok?
(aplugin.setup)))
then the autocmd for the nfnl-setup
augroup is created when Neovim starts up and Fennel files are automatically compiled after being saved.
Ah! So the nfnl
module is just not being loaded! Which plugin manager are you using? I think I need to adapt it to work more out of the box with things other than lazy.nvim. I guess lazy automatically requires things in a way other plugins don't.
Added a plugin/nfnl.vim
that contains lua require('nfnl')
, should be enough to ensure nfnl.init
is loaded by all plugin managers.
Yes!! That works!
I'm using Packer as my plugin manager. Now, I can just have :Olical/nfnl {}
in my init.fnl.
Thanks!
This works! So much easier to use than
Aniseed
but I discovered that saving a.fnl
file doesn't compile it to.lua
.I have this set-up:
With this in
.nfnl.fnl
:After saving
main.fnl
, I noticed that it wasn't compiled.Did I miss something?