Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Ronald Record edited this page Jul 13, 2023 · 11 revisions

Neovim Configuration Fuzzy Selector

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.

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.

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
#
# Bob neovim version manager path
[ -d ${HOME}/.local/share/bob/nvim-bin ] && {
 export PATH="${HOME}/.local/share/bob/nvim-bin${PATH:+:${PATH}}"
}
# Aliases for lsd, tldr, and bat if they exist
command -v lsd > /dev/null && alias ls='lsd --group-dirs first' && \
	alias tree='lsd --tree' && alias lss='lsd --group-dirs first'
command -v tldr > /dev/null && {
 command -v fzf > /dev/null && {
 alias tldrf='tldr --list | fzf --preview "tldr {1} --color=always" --preview-window=right:70% | xargs tldr --color=always'
 }
}
command -v bat > /dev/null && alias less='bat'
command -v batcat > /dev/null && \
	alias bat='batcat' && \
	alias less='batcat'
# To use Vim
command -v vim > /dev/null && alias vi='vim'
# To use Neovim
command -v nvim > /dev/null && {
 alias vi='nvim'
 # Uncomment this line to use Neovim even when you type vim
 # Leave commented to use vim as a backup editor if nvim not found
 # alias vim='nvim'
 alias nvims='source ~/.config/nvim-Lazyman/.lazymanrc; nvimselect'
 alias neovides='source ~/.config/nvim-Lazyman/.lazymanrc; neovselect'
 items=()
 ndirs=()
 [ -d ${HOME}/.config/nvim ] && {
 alias nvim-default="NVIM_APPNAME=nvim nvim"
 }
 # Add all previously installed Neovim configurations
 if [ -f ${HOME}/.config/nvim-Lazyman/.nvimdirs ]
 then
 while IFS= read -r ndir
 do
 [ -d ${HOME}/.config/${ndir} ] && {
 alias ${ndir}="NVIM_APPNAME=${ndir} nvim"
 entry=$(echo ${ndir} | sed -e "s/nvim-//")
 items+=("${entry}")
 ndirs+=("${ndir}")
 }
 done < "${HOME}/.config/nvim-Lazyman/.nvimdirs"
 else
 # Add any supported config we find
 [ -d ${HOME}/.config/nvim-Lazyman ] && {
 alias nvim-lazy="NVIM_APPNAME=nvim-Lazyman nvim"
 items+=("Lazyman")
 ndirs+=("nvim-Lazyman")
 }
 [ -d ${HOME}/.config/nvim-LazyVim ] && {
 alias nvim-lvim="NVIM_APPNAME=nvim-LazyVim nvim"
 items+=("LazyVim")
 ndirs+=("nvim-LazyVim")
 }
 [ -d ${HOME}/.config/nvim-Kickstart ] && {
 alias nvim-kick="NVIM_APPNAME=nvim-Kickstart nvim"
 items+=("Kickstart")
 ndirs+=("nvim-Kickstart")
 }
 [ -d ${HOME}/.config/nvim-NvChad ] && {
 alias nvim-chad="NVIM_APPNAME=nvim-NvChad nvim"
 items+=("NvChad")
 ndirs+=("nvim-NvChad")
 }
 [ -d ${HOME}/.config/nvim-AstroNvimPlus ] && {
 alias nvim-astro="NVIM_APPNAME=nvim-AstroNvimPlus nvim"
 items+=("AstroNvimPlus")
 ndirs+=("nvim-AstroNvimPlus")
 }
 [ -d ${HOME}/.config/nvim-Ecovim ] && {
 alias nvim-eco="NVIM_APPNAME=nvim-Ecovim nvim"
 items+=("Ecovim")
 ndirs+=("nvim-Ecovim")
 }
 [ -d ${HOME}/.config/nvim-LunarVim ] && {
 alias nvim-lunar="NVIM_APPNAME=nvim-LunarVim nvim"
 items+=("LunarVim")
 ndirs+=("nvim-LunarVim")
 }
 [ -d ${HOME}/.config/nvim-MultiVim ] && {
 alias nvim-multi="NVIM_APPNAME=nvim-MultiVim nvim"
 items+=("MultiVim")
 ndirs+=("nvim-MultiVim")
 }
 [ -d ${HOME}/.config/nvim-SpaceVim ] && {
 alias nvim-space="NVIM_APPNAME=nvim-SpaceVim nvim"
 items+=("SpaceVim")
 ndirs+=("nvim-SpaceVim")
 }
 fi
 function runconfig() {
 cfg="1ドル"
 neo="2ドル"
 shift
 comm="nvim"
 [ "${neo}" ] && [ "${neo}" == "neovide" ] && {
 comm='neovide --'
 shift
 }
 [ -d "${HOME}/.config/${cfg}" ] || {
 [ -d "${HOME}/.config/nvim-${cfg}" ] && cfg="nvim-${cfg}"
 }
 # Use a file tree explorer for configurations without a dashboard
 case ${cfg} in
 nvim-BasicLsp|nvim-BasicMason|nvim-Enrique|nvim-Extralight|nvim-LspCmp|nvim-Minimal|nvim-Simple)
 NVIM_APPNAME="${cfg}" ${comm} -c 'Lexplore' $@
 ;;
 nvim-Kabin|nvim-Lamia|nvim-Kickstart|nvim-Maddison|nvim-Rafi|nvim-SingleFile|nvim-Slydragonn)
 NVIM_APPNAME="${cfg}" ${comm} -c 'Neotree' $@
 ;;
 nvim-Cosmic|nvim-Fennel|nvim-Opinion|nvim-Optixal|nvim-Xiao)
 NVIM_APPNAME="${cfg}" ${comm} -c 'NvimTreeOpen' $@
 ;;
 nvim-Basic|nvim-Go|nvim-Metis|nvim-Modular|nvim-Python|nvim-Rust|nvim-Scratch|nvim-StartLsp|nvim-StartMason)
 NVIM_APPNAME="${cfg}" ${comm} -c 'NvimTreeToggle' $@
 ;;
 nvim-3rd)
 NVIM_APPNAME="${cfg}" ${comm} -c 'lua local api = require("nvim-tree.api") local tree = require("nvim-tree") api.tree.toggle(true)' $@
 ;;
 *)
 NVIM_APPNAME="${cfg}" ${comm} $@
 ;;
 esac
 }
 function nvimselect() {
 action="Open"
 remove=
 if [[ "1ドル" == "-r" ]]
 then
 action="Remove"
 remove=1
 for i in "${!items[@]}"; do
 if [[ ${items[i]} = "Lazyman" ]]; then
 unset 'items[i]'
 fi
 done
 for i in "${!items[@]}"; do
 new_items+=( "${items[i]}" )
 done
 items=("${new_items[@]}")
 unset new_items
 shift
 fi
 filter="1ドル"
 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
 if [ "${filter}" ]
 then
 config=$(printf "%s\n" "${items[@]}" | grep -i ${filter} | fzf --prompt="${action} Neovim Config  " --height=${height}% --layout=reverse --border --exit-0)
 else
 config=$(printf "%s\n" "${items[@]}" | fzf --prompt="${action} Neovim Config  " --height=${height}% --layout=reverse --border --exit-0)
 fi
 fi
 if [[ -z ${config} ]]; then
 echo "Nothing selected"
 return 0
 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
 if [ "${remove}" ]
 then
 lazyman -R -N ${config}
 else
 runconfig "${config}" $@
 fi
 }
 function neovselect() {
 action="Open"
 remove=
 if [[ "1ドル" == "-r" ]]
 then
 action="Remove"
 remove=1
 shift
 fi
 filter="1ドル"
 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
 if [ "${filter}" ]
 then
 config=$(printf "%s\n" "${items[@]}" | grep -i ${filter} | fzf --prompt="${action} Neovim Config  " --height=${height}% --layout=reverse --border --exit-0)
 else
 config=$(printf "%s\n" "${items[@]}" | fzf --prompt="${action} Neovim Config  " --height=${height}% --layout=reverse --border --exit-0)
 fi
 fi
 if [[ -z ${config} ]]; then
 echo "Nothing selected"
 return 0
 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
 if [ "${remove}" ]
 then
 lazyman -R -N ${config}
 else
 runconfig "${config}" "neovide" $@
 fi
 }
}
# Add ~/.local/bin to PATH if it exists
[ -d $HOME/.local/bin ] && {
 [[ ":$PATH:" == *":$HOME/.local/bin:"* ]] || {
 export PATH="$PATH:$HOME/.local/bin"
 }
}
# Add ~/.cargo/bin to PATH if it exists
[ -d $HOME/.cargo/bin ] && {
 [[ ":$PATH:" == *":$HOME/.cargo/bin:"* ]] || {
 export PATH="$PATH:$HOME/.cargo/bin"
 }
}
# Add ~/.luarocks/bin to PATH if it exists
[ -d $HOME/.luarocks/bin ] && {
 [[ ":$PATH:" == *":$HOME/.luarocks/bin:"* ]] || {
 export PATH="$PATH:$HOME/.luarocks/bin"
 }
}

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /