Skip to content

Multiple Configs

Multiple Configurationsλ︎

Many Neovim configurations can be installed in $HOME/.config/ using unique directory names, e.g. AstroNvim, cajus, lazyvim, kickstart.

Set NVIM_APPNAME to a configuration directory name (relative to $HOME/.config/`) to run Neovim with that specific config.

Run AstroNvim config in $HOME/.config/astronvim/

NVIM_APPNAME=astronvim nvim

The configuration directory name is used to save local share, state and cache files for that specific configuration.

Community Configuration Projects
  • kickstart.nvim a highly documented starter configuration to effectively build your own
  • LazyVim lazy & mason configuration
  • Magit Kit fennel configuration from the author of Conjure
  • cajus-nvim inspiration for practicalli/neovim-config-redux

Configure shell aliasλ︎

Create a Shell alias for each configuration that will be used, to avoid setting the NVIM_APPNAME variable each time.

Add alias to .bashrc for Bash shell or .zshrc for Zsh

Define Shell Aliases to run each configuration

alias astro="NVIM_APPNAME=nvim-astro nvim"
alias lazy="NVIM_APPNAME=nvim-lazyvim nvim"
alias cajus="NVIM_APPNAME=nvim-cajus nvim"

shell-aliases for bash and zshλ︎

Create a .config/shell-aliases file containing all shell aliases when often switching between different shells, avoiding the need to define aliases twice

Source the .config/shell-aliases file from within .bashrc or .zshrc

.zshrc
# Shell Aliases
[[ ! -f ~/.config/shell-aliases ]] || source ~/.config/shell-aliases
.bashrc
# Shell Aliases
if [ -f ~/.config/shell-aliases ]; then
    . ~/.config/shell-aliases
fi

Neovim config selectorλ︎

Create a shell function to popup a menu with the list of available Neovim configurations, defined in ~/.config where the configuration directories are prefixed with nvim-, e.g. ~/.config/nvim-astro/

Neovim Config Fuzy Selector

Neovim Config Fuzzy Finder

.local/bin/nvim-fuzy-find
nvim-fuzy-find() {
  # All config paths are prefixed with ~/.config/nvim-
  local config=$(fdfind --max-depth 1 --glob 'nvim-*' ~/.config | fzf --prompt="Neovim Configs > " --height=15% --layout=reverse --border --exit-0)

  [[ -z $config ]] && echo "No config selected, Neovim not starting" && return

  # Open Neovim with selected config
  NVIM_APPNAME=$(basename $config) nvim $@
}
Neovim Config simple Selector

Add the Neovim config directory names from ~/.config/

.local/bin/nvim-selector
 nvim-selector() {
  select config in nvim-astro nvim-astronvim-template nvim-lazyvim nvim-kickstart
  do NVIM_APPNAME=nvim-$config nvim $@; break; done
}