I only started using Lua when I started using Neovim v0.5 nightly releases, and I didn’t find the language entirely to my taste. However, I am quite a big fan of Lisp and Lisp-like languages, and I found that I enjoyed writing Fennel more than plain Lua, at least until I got more acclimated to the “Lua way” of doing things.
One of Fennel’s features is that it itself is a pure Lua module. And moreover, it ships with its own package searcher that can be used to
require() Fennel source files as if they were Lua source files.
What this means is that, with the right configuration magic, I can drop Fennel files anywhere in my runtime path and use them from Neovim scripts. My current setup is configured to look for them under
fennel/*.fnl, but of course they can be anywhere, even intermingled with Lua files under
lua/*.fnl if you want!
Yes, this is going to be slower at load time than pre-compiling to plain Lua, but Fennel + LuaJIT is fast enough that it’s not noticeable for the small stuff I’ve written so far.
If this sounds as exciting to you as it did to me, here is my Lua script that I use to get this setup working:
lua/fennel-init.lua. This file lives under
~/.config/nvim. In order to activate this Fennel integration, just add
:lua require('fennel-init') to
Hopefully this is useful to some other people!
Note that this setup is incompatible with plugins that intend to use the Aniseed framework, because they ship with
fennel/*.fnl files that are not meant to be loaded directly, but instead loaded by the Aniseed system. I love the idea of Aniseed (and frankly I think its innovations should be merged upstream into Fennel itself), but I don’t currently use it, so this isn’t a problem for me. If you wanted to eliminate this incompatibility, you can adjust the
fennel/*.fnl path in my config to be anything else, perhaps
lua/*.fnl as I mentioned above.
Also note that my dotfiles are published under the MIT License; see here for full license terms.
TL,DR? Put this file in
~/.config/nvim/lua/fennel-init.lua, then you can
require Fennel files from Neovim as if they were plain Lua files.