Learning how to configure Neovim can be overwhelming. One way to get started is to install a few pre-built configurations (like LazyVim, NvChad, AstroNvim, LunarVim or the official Neovim Kickstart) and see what you like.
Most installation instructions will tell you to replace everything in your ~/.config/nvim
directory with the new configuration. But once you do, you lose the ability to launch Neovim with your previous config.
With that approach, you can only have one Neovim config installed at a time.
But what if you want to compare two configs? Or maintain different configs for different purposes (e.g. one for work and one for personal projects)?
Install each config in its own directory
To be able to use more than one config, youβll need to make a couple changes to your setup:
- Instead of installing a new configuration in
~/.config/nvim
, install it in a custom~/.config
subdirectory - Each time you open Neovim, specify which config you want by setting the
NVIM_APPNAME
environment variable in your launch command
For example, assuming youβve installed LazyVim in ~/.config/nvim-lazyvim
, youβd launch it with this command:
Neovim uses NVIM_APPNAME
to determine which config directory to load. If you donβt include it (or set it to an invalid value), Neovim will use the default config in ~/.config/nvim
.
Switching configs using alias
, select
or fzf
Lets assume your ~/.config
directory includes these subdirectories:
To quickly open Neovim using each config, you could create an alias
for each launch command:
Or use select
to list your configs so you can choose one:
Which would produce a menu like this:
Or you could get fancy and use a fuzzy finder like fzf to do the same thing:
Hereβs what that fzf
menu would look like:
Conclusion
Configuring Neovim can be daunting, but being able to install a few configs and compare them is a great way to gather inspiration for your own custom config.
Good luck!
Further Reading
- NVIM_APPNAME β’ Neovim docs π
- Neovim Config Switcher β’ Elijah Manor πΊ
- Neovim Switcher Gist β’ Elijah Manor π©βπ»
- Lazyman: Neovim Configuration Manager β’ Ronald Record π οΈ
- You Should Use a Neovim Distro If You Are New β’ ThePrimeagen πΊ