#!/bin/sh
set -eu

PKG="nvim-autopairs"

if nvim --headless \
  +"lua require('$PKG').setup {}" \
  +'qa!'; then
  echo "OK $PKG loaded without errors"
else
  echo "ERROR $PKG failed to load"
  exit 1
fi

if nvim --headless \
  +"silent! help $PKG" \
  +"if &buftype ==# 'help' | qa! | else | cquit 1 | endif"; then
  echo "OK :help $PKG exists"
else
  echo "ERROR :help $PKG not found"
  exit 1
fi

if nvim --headless \
  +"silent! help $PKG-rules" \
  +"if &buftype ==# 'help' | qa! | else | cquit 1 | endif"; then
  echo "OK :help $PKG-rules exists"
else
  echo "ERROR :help $PKG-rules not found"
  exit 1
fi
