From 1ef72b14ccd05fdbdb01d253b91a74c4760ae655 Mon Sep 17 00:00:00 2001 From: Greg Fisher Date: Sat, 13 Mar 2021 22:08:29 -0500 Subject: [PATCH] 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. --- bin/tagpreview.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/tagpreview.sh b/bin/tagpreview.sh index c1303d5..e07f87d 100755 --- a/bin/tagpreview.sh +++ b/bin/tagpreview.sh @@ -20,7 +20,17 @@ if [ ! -r "$FILE" ]; then exit 1 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 "${EXCMD}" \ -c 'let l=line(".") | new | put =l | print | qa!')" || return