#!/usr/bin/env bash # # scripts/test-keymaps-vim.sh — Vim counterpart of test-keymaps.sh. # # Pure-VimL portion only. The LSP-roundtrip keymaps (``, # `=`, `-`, …) talk to the server via vim-lsp's timer-driven async # layer, which doesn't fire reliably inside `vim -e -s`. Those have # Neovim coverage in scripts/test-keymaps.lua, exercising the same # Lua command layer + server binary. set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" TMP="$(mktemp -d -t nuwiki-keymap-vim-test-XXXXXX)" trap 'rm -rf "$TMP"' EXIT log() { printf '\033[1;34m[keymap-vim]\033[0m %s\n' "$*"; } if ! command -v vim >/dev/null 2>&1; then log 'vim not installed — skipping' exit 0 fi # Don't need the LSP binary for the pure-VimL cases, but make sure # the autoload file `expand('')` resolves correctly when the # script-load-time plugin_root capture runs. mkdir -p "$TMP/wiki" SEED="$TMP/wiki/index.wiki" echo "= seed =" > "$SEED" VIMRC="$TMP/vimrc" cat > "$VIMRC" <"$TMP/vim.log" 2>&1 || true if [[ ! -f "$RESULTS" ]]; then echo 'keymap test harness produced no output' >&2 echo '--- vim log ---' >&2 cat "$TMP/vim.log" >&2 || true exit 1 fi cat "$RESULTS" if grep -qE '^SUMMARY: [0-9]+ passed, 0 failed' "$RESULTS"; then exit 0 fi exit 1