-
-
Notifications
You must be signed in to change notification settings - Fork 18
Nvims
The lazyman installation and configuration automatically configures
convenience aliases and an nvims shell function for the installed
Lazyman Neovim configurations. See ~/.config/nvim-Lazyman/.lazymanrc.
View the .lazymanrc shell aliases and zsh nvims function
# $HOME/.config/nvim-Lazyman/.lazymanrc
# This file should be sourced from the shell initialization file
# e.g. $HOME/.bashrc or $HOME/.zshrc
#
# To use Vim
command -v vim > /dev/null && alias vi='vim'
# To use NeoVim
command -v nvim > /dev/null && {
alias vi='nvim'
items=()
[ -d ${HOME}/.config/nvim ] && {
alias nvim-default="NVIM_APPNAME=nvim nvim"
items+=("default")
}
# Add all previously installed Neovim configurations
if [ -f ${HOME}/.config/nvim-Lazyman/.nvimdirs ]
then
cat ${HOME}/.config/nvim-Lazyman/.nvimdirs | while read nvimdir
do
[ -d ${HOME}/.config/${nvimdir} ] && {
alias ${nvimdir}="NVIM_APPNAME=${nvimdir} nvim"
entry=$(echo ${nvimdir} | sed -e "s/nvim-//")
items+=("${entry}")
}
done
else
# Add any supported config we find
[ -d ${HOME}/.config/nvim-Lazyman ] && {
alias nvim-lazy="NVIM_APPNAME=nvim-Lazyman nvim"
items+=("Lazyman")
}
[ -d ${HOME}/.config/nvim-LazyVim ] && {
alias nvim-lazy="NVIM_APPNAME=nvim-LazyVim nvim"
items+=("LazyVim")
}
[ -d ${HOME}/.config/nvim-Kickstart ] && {
alias nvim-kick="NVIM_APPNAME=nvim-Kickstart nvim"
items+=("Kickstart")
}
[ -d ${HOME}/.config/nvim-NvChad ] && {
alias nvim-chad="NVIM_APPNAME=nvim-NvChad nvim"
items+=("NvChad")
}
[ -d ${HOME}/.config/nvim-AstroNvim ] && {
alias nvim-astro="NVIM_APPNAME=nvim-AstroNvim nvim"
items+=("AstroNvim")
}
[ -d ${HOME}/.config/nvim-Allaman ] && {
alias nvim-aman="NVIM_APPNAME=nvim-Allaman nvim"
items+=("Allaman")
}
[ -d ${HOME}/.config/nvim-LunarVim ] && {
alias nvim-lunar="NVIM_APPNAME=nvim-LunarVim nvim"
items+=("LunarVim")
}
[ -d ${HOME}/.config/nvim-MultiVim ] && {
alias nvim-multi="NVIM_APPNAME=nvim-MultiVim nvim"
items+=("MultiVim")
}
[ -d ${HOME}/.config/nvim-SpaceVim ] && {
alias nvim-space="NVIM_APPNAME=nvim-SpaceVim nvim"
items+=("SpaceVim")
}
fi
function nvims() {
numitems=${#items[@]}
if [ ${numitems} -eq 1 ]
then
config="${items[@]:0:1}"
else
height=$((numitems * 6))
[ ${height} -gt 100 ] && height=100
[ ${height} -lt 20 ] && height=20
config=$(printf "%s\n" "${items[@]}" | fzf --prompt=" Neovim Config " --height=${height}% --layout=reverse --border --exit-0)
fi
if [[ -z $config ]]; then
echo "Nothing selected"
return 0
elif [[ $config == "default" ]]; then
config="nvim"
else
if [ -d ${HOME}/.config/nvim-${config} ]
then
config="nvim-${config}"
else
[ -d ${HOME}/.config/${config} ] || {
echo "Cannot locate ${config} Neovim configuration directory"
return 0
}
fi
fi
NVIM_APPNAME=$config nvim $@
}
if [ -n "$($SHELL -c 'echo $ZSH_VERSION')" ]; then
bindkey -s ^n "nvims\n"
elif [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then
bind -x '"\C-n": nvims'
else
bindkey -s ^n "nvims\n"
fi
}The nvims shell function, when executed, presents a fuzzy searchable menu
of the lazyman installed Neovim configurations. The lazyman installed
Neovim configurations are maintained in the file
~/.config/nvim-Lazyman/.nvimdirs. Entries in this file are what nvims
uses for its fuzzy selection menu. When Neovim configurations are installed
or removed with lazyman this file is updated accordingly.
Note also that a convenience key binding has been created to launch
nvims with ctrl-n.
The nvims Neovim configuration switching shell function was created by
Elijah Manor. He created an excellent
Neovim Config Switcher video in which
he provides details on use and customization of the nvims shell function.
Lazyman has incorporated and adapted the nvims shell function for use
with the Lazyman installed Neovim configurations. The nvims shell
function is automatically configured during lazyman installation.