#!/usr/bin/env bash # # development/tests/test-config-vim.sh — Vim counterpart of test-config.sh. # # Runs development/tests/test-config-vim.vim under headless Vim, which dumps # the Vim client's `initialization_options` payload (nuwiki#lsp#settings()) # as `key=value` lines, then diffs against the shared golden # config-expected.txt. Matching the same golden the Neovim harness uses is # what proves Vim/Neovim config parity. # # Exit code: 0 when the payload matches the golden, 1 otherwise. Skips # (exit 0) when vim is not installed. set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" log() { printf '\033[1;34m[config-vim]\033[0m %s\n' "$*"; } if ! command -v vim >/dev/null 2>&1; then log 'vim not installed — skipping' exit 0 fi TMP="$(mktemp -d -t nuwiki-config-vim-test-XXXXXX)" trap 'rm -rf "$TMP"' EXIT GOLDEN="$REPO_ROOT/development/tests/config-expected.txt" OUT="$TMP/vim-config.txt" VIMRC="$TMP/vimrc" cat > "$VIMRC" <"$TMP/vim.log" 2>&1 || true if [[ ! -f "$OUT" ]]; then echo 'config harness produced no output' >&2 echo '--- vim log ---' >&2 cat "$TMP/vim.log" >&2 || true exit 1 fi if diff -u "$GOLDEN" "$OUT"; then log 'Vim config payload matches golden ✓' exit 0 fi echo 'Vim config payload DIVERGED from golden (see diff above)' >&2 exit 1