Neovim nfnl Directory Configuration
I’ve long wanted to figure out how to get nfnl's
directory-local configuration working,
but it took me until yesterday to figure it out —
mostly by opening a discussion and then realizing my mistakes. 🤡
First, exrc
needs to be enabled.
This will ultimately load the contents of the generated .nvim.lua
file,
as described in :help 'exrc'
Next, create an .nfnl.fnl
file in the directory.
I’ve been creating mine as:
;; .nfnl.fnl
{:source-file-patterns [:.nvim.fnl]}
… which means that nfnl
only needs to compile the .nvim.fnl
file into .nvim.lua
.
From there, I create a .nvim.fnl
file with my configuration.
Often this is to set up a particular project-local formatter or linter with conform or nvim-lint,
so it may look something like:
;; .nvim.fnl
(let [conform (require :conform)]
(set conform.formatters_by_ft.json [:prettier]))
With this I’ve been able to remove a few $WORK specific formatters.
Lastly, I’ve globally gitignored these files so they aren’t accidentally committed.
It’s possible to commit the .nvim.lua
files to share with other neovim users that have exrc
enabled,
but I doubt I’ll use that very often —
I’m still undecided on if I’ll commit these for my personal projects.
📁