`nvim -u` for modular config

Hi there!

I have an nvim config which I manage with home-manager. To avoid having to wait for a home-manager switch every time I make a tiny change to my nvim config, I use nvim -u path/to/nix/config/nvim/init.lua for testing configuration changes.

I recently decided I wanted to try splitting up my giant init.lua into modules. However, it seems like nvim -u doesn’t know how to load modules require-d by init.lua (at least when they’re relative to that init.lua), so I get errors like module 'options' not found.

How can I get around this?

Another option would be copy or rename within the $HOME/.config directory. Though I think the cleanest would be symlinks because it does not involve touching the various config directories. And with symlinks it’s easy to have as many alternate configs as you want.

1 Like

That’s a great idea, thanks. It’s slightly more unwieldy, since you have to put everything back afterwards, but might be more convenient if I script it.

I have a pretty complex setup but rerunning home-manager switch on every change was out of the question. I have the generated init.lua (https://github.com/teto/home/blob/3dbe7c5e9e960b54a304c540d3e678cf6b582776/hosts/desktop/teto/neovim.nix#L196) require init.manual.lua https://github.com/teto/home/blob/main/config/nvim/lua/init-manual.lua that I can change without rebuilding.

1 Like

You might be interested in this commit: $NVIM_APPNAME

2 Likes

Oh that looks perfect, thanks

1 Like