Use nvim if vim not installed (#1262)

The `tagpreview.sh` script is hardcoded to the `vim` binary. For users that only
have  Neovim installed an error is displayed and no preview is rendered.

This change addresses this by falling back to the `nvim` binary if the `vim`
binary isn't present.
This commit is contained in:
Greg Fisher
2021-03-13 22:08:29 -05:00
committed by GitHub
parent 711fb41e39
commit 1ef72b14cc

View File

@@ -20,7 +20,17 @@ if [ ! -r "$FILE" ]; then
exit 1 exit 1
fi fi
CENTER="$(vim -i NONE -u NONE -e -m -s "${FILE}" \ # If users aren't using vim, they are probably using neovim
if command -v vim > /dev/null; then
VIMNAME="vim"
elif command -v nvim > /dev/null; then
VIMNAME="nvim"
else
echo "Cannot preview tag: vim or nvim unavailable"
exit 1
fi
CENTER="$("${VIMNAME}" -i NONE -u NONE -e -m -s "${FILE}" \
-c "set nomagic" \ -c "set nomagic" \
-c "${EXCMD}" \ -c "${EXCMD}" \
-c 'let l=line(".") | new | put =l | print | qa!')" || return -c 'let l=line(".") | new | put =l | print | qa!')" || return