How to Use Multiple Neovim Distributions on macOS
What if you want to install multiple Neovim distributions like NvChad, LunarVim, AstroNvim, LazyVim, etc. while also keeping your custom Neovim config on you system. There's two ways to do that.
Method #1
This method is by Elijah Manor.
Make sure you have the latest Neovim version as well as Nerd Font installed. I suppose you have your custom Neovim config at ~/.config/nvim
. Now, let's say you want to install AstroNvim along with your custom config.
Visit AstroNvim and copy the command to clone the repo which is
git clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/nvim
NOTE: Don't run this command yet.
If you run this command, it will overwrite your custom Neovim config.
Edit
~/.config/nvim
to~/.config/AstroNvim
. Here's the full command to copy and rungit clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/AstroNvim
Open your
.zshrc
file and paste the following.# Start: Run multiple Neovim distros alias nvim-astro="NVIM_APPNAME=AstroNvim nvim" function nvims() { items=("default" "AstroNvim") config=$(printf "%s\n" "${items[@]}" | fzf --prompt=" Neovim Config " --height=~50% --layout=reverse --border --exit-0) if [[ -z $config ]]; then echo "Nothing selected" return 0 elif [[ $config == "default" ]]; then config="" fi NVIM_APPNAME=$config nvim $@ } # End: Run multiple Neovim distros
In the above code, if you have a Nerd font installed
will look like
Source your
zshrc
file.source ~/.zshrc
In your terminal, type
nvims
to select Neovim distro of your choiceAs you can see in the above image, I have multiple Neovim distros installed on my system. You can either type to search or browse using
<Ctrl-n>
and<Ctrl-p>
.To install any other Neovim distro, you have to follow the same order.
Let's say you want to install NormalNvim, which even I don't have on my system.
First, I will visit the page and copy the download link which is
git clone https://github.com/NormalNvim/NormalNvim.git ~/.config/nvim
Now, I will edit the above command to suit my preference. Here's the edited command to run
git clone https://github.com/NormalNvim/NormalNvim.git ~/.config/NormalNvim
It's time to edit
.zshrc
file to add NormalNvim to the array as well as an alias for it.# Start: Run multiple Neovim distros alias nvim-astro="NVIM_APPNAME=AstroNvim nvim" alias nvim-normal="NVIM_APPNAME=NormalNvim nvim" function nvims() { items=("default" "AstroNvim NormalNvim") config=$(printf "%s\n" "${items[@]}" | fzf --prompt=" Neovim Config " --height=~50% --layout=reverse --border --exit-0) if [[ -z $config ]]; then echo "Nothing selected" return 0 elif [[ $config == "default" ]]; then config="" fi NVIM_APPNAME=$config nvim $@ } # End: Run multiple Neovim distros
Source your
.zshrc
file and runnvims
in your terminal. You will have the option to select NormalNvim.You can also run NormalNvim directly by typing the alias
nvim-normal
in your terminal.
Method #2
Using Lazyman you can install more than 100 Neovim distros on your system.
... to be continued
Subscribe to my newsletter
Read articles from Shailesh Kumar Sundram directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Shailesh Kumar Sundram
Shailesh Kumar Sundram
Terminal & Vim aficionado