nix-community / kickstart-nix.nvim

❄️ A dead simple Nix flake template repository for Neovim derivations [maintainer=@mrcjkb]
GNU General Public License v2.0
231 stars 10 forks source link

How could I debug nvim config easily? #10

Closed qlibp closed 7 months ago

qlibp commented 7 months ago

if I modify the github repo's lua configuration locally, the behavior won't change, and it's sure a good thing. But is there a way to quickly write & evaluate the nvim configuration by just modifying the config directly?

Should I re-build flake every time when I change sth to see what happens?

mrcjkb commented 7 months ago

Hey :wave:

My workflow is usually

Although it is a slightly slower feedback loop, I find it beneficial, because if something breaks severely, I can still use my unmodified config to fix things.

If you're working on something where you need a faster feedback loop, you can copy the module you're working on to your $XDG_CONFIG_HOME/$NVIM_APPNAME/... directory and work on it there. Then copy it back when you're done. Make sure to filter out the module you've copied over from the derivation, so that it doesn't conflict.

qlibp commented 7 months ago

working on to your $XDG_CONFIG_HOME/$NVIM_APPNAME/... directory and work on it there

I try this one just now, but nvim seems to not load my script.

I place a init.lua in ~/.config/nvim, and nvim don't load this script at all. Check with :scriptnames

mrcjkb commented 7 months ago

I place a init.lua in ~/.config/nvim, and nvim don't load this script at all. Check with :scriptnames

It won't source an init.lua, because the neovim derivation has a wrapper which calls nvim -u /path/to/generated-init.lua. You can run nvim -u /path/to/init.lua, but then it'll ignore the generated init.lua.

An alternative might be to put your script in ~/.config/nvim/plugin. But in this case, it'll be sourced after the generated init.lua.

qlibp commented 7 months ago

This practice should be documented in README for those like me who's not so farmiliar with nix

qlibp commented 7 months ago

One more question, if I newly add a nvim config file, maybe nvim/plugin/lspconfig.lua, and then run nix run .#nvim, will this file get loaded?

Concretely, when I try to introduce pylsp into the configuration, the above procedure don't work. I then add the line require('lspconfig').pylsp.setup {} into init.lua, then all works fine. Therefore, I suspect that the newly added files is not loaded.

Correct me if I'm wrong.

mrcjkb commented 7 months ago

With nix flakes, only files that have been staged (git add) or committed will be added to the derivation.