practicalli-johnny / neovim-config-archive

Neovim 9.x Fennel config with lazy package manager, Conjure & LSP support for Clojure development
Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

Neovim config switcher #2

Closed practicalli-johnny closed 1 year ago

practicalli-johnny commented 1 year ago

Neovim nightly includes an NVIM_APPNAME variable that can be set to define the location of the configuration, so different configs can be quickly evaluated

Adding aliases to the shell (.zshrc .bashrc) provides a simple way to run specific config.

alias nvim-lazy="NVIM_APPNAME=LazyVim nvim"
alias nvim-kick="NVIM_APPNAME=kickstart nvim"
alias nvim-chad="NVIM_APPNAME=NvChad nvim"
alias nvim-astro="NVIM_APPNAME=AstroNvim nvim"

An example zsh function provides a selection popup for choosing a config

function nvim-selector() {
  items=("default" "kickstart" "LazyVim" "NvChad" "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 $@
}

Create a key bindings to launch the nvim-selector command

bindkey -s ^a "nvim-selector\n"

Reference

https://gist.github.com/elijahmanor/b279553c0132bfad7eae23e34ceb593b

https://youtube.com/watch?v=LkHjJlSgKZY

practicalli-johnny commented 1 year ago

Published to https://practical.li/neovim/install/configuration/