How to Use Multiple Neovim Distributions on macOS

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.

  1. 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.

  2. Edit ~/.config/nvim to ~/.config/AstroNvim . Here's the full command to copy and run

     git clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/AstroNvim
    
  3. 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

  4. Source your zshrc file.

     source ~/.zshrc
    
  5. In your terminal, type nvims to select Neovim distro of your choice

  6. As 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> .

  7. To install any other Neovim distro, you have to follow the same order.

  8. Let's say you want to install NormalNvim, which even I don't have on my system.

  9. First, I will visit the page and copy the download link which is

     git clone https://github.com/NormalNvim/NormalNvim.git ~/.config/nvim
    
  10. 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
    
  11. 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
    
  12. Source your .zshrc file and run nvims in your terminal. You will have the option to select NormalNvim.

  13. 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