feat(config): vimwiki drop-in config + global per-wiki defaults
Two related config-ergonomics features for vimwiki migrants, sharing the
same scalar-global machinery.
1. Upstream g:vimwiki_* drop-in (Vim client). When nuwiki isn't configured
natively, the Vim client reads g:vimwiki_list + g:vimwiki_* globals and
translates them into nuwiki's schema: per-wiki path->root,
path_html->html_path, template_*, css_name, auto_export/auto_toc,
syntax, ext->file_extension, index, diary_*, name. g:nuwiki_* always
wins. Lets a vimwiki user drop in nuwiki without rewriting config.
2. Global per-wiki defaults (both clients). A display/generation setting
given once at the top level — g:nuwiki_<key> / setup({<key>=…}) /
g:vimwiki_<key> — is folded into every wiki as a default; a per-wiki
value overrides it (vimwiki's model). Covers toc_header(_level),
toc_link_format, links_header(_level), tags_header(_level),
html_header_numbering(_sym), links_space_char, list_margin, listsyms,
listsym_rejected, and the auto_* toggles. Only values the user
explicitly set fold — built-in defaults don't (added config.user
tracking on the Lua side so a default toc_header_level=1 isn't pushed
onto every wiki). User config tables are never mutated.
Both clients kept in lock-step (config-parity golden enforces identical
payloads). New harnesses test-vimwiki-compat-vim (18) and
test-global-shorthand (8), wired into CI. Server test
vimwiki_compat_payload_sets_toc_level_per_wiki. Docs in README +
known-issues.md (drop-in is currently Vim-only). Rust 573 passed, clippy
clean, all harnesses green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# development/tests/test-vimwiki-compat-vim.sh — upstream-vimwiki config
|
||||
# drop-in compatibility for the Vim client.
|
||||
#
|
||||
# Runs test-vimwiki-compat-vim.vim under headless Vim; that script sets an
|
||||
# upstream `g:vimwiki_list` + `g:vimwiki_*` config and asserts
|
||||
# nuwiki#lsp#settings() translates it into the server's schema (per-wiki key
|
||||
# remap + global scalar settings folded into each wiki). Also checks that
|
||||
# nuwiki-native config takes precedence.
|
||||
#
|
||||
# Exit code: 0 when every check passes, 1 on any FAIL or missing output.
|
||||
# Skips (exit 0) when vim is not installed.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
|
||||
log() { printf '\033[1;34m[vimwiki-compat]\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-vwc-test-XXXXXX)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
OUT="$TMP/vwc.out"
|
||||
|
||||
VIMRC="$TMP/vimrc"
|
||||
cat > "$VIMRC" <<EOF
|
||||
set nocompatible
|
||||
let &runtimepath = '$REPO_ROOT' . ',' . &runtimepath
|
||||
EOF
|
||||
|
||||
log 'running Vim vimwiki-compat harness…'
|
||||
NUWIKI_VWC_OUT="$OUT" \
|
||||
timeout 30 vim -e -s -u "$VIMRC" \
|
||||
-c "source $REPO_ROOT/development/tests/test-vimwiki-compat-vim.vim" \
|
||||
</dev/null >"$TMP/vim.log" 2>&1 || true
|
||||
|
||||
if [[ ! -f "$OUT" ]]; then
|
||||
echo 'vimwiki-compat harness produced no output' >&2
|
||||
echo '--- vim log ---' >&2
|
||||
cat "$TMP/vim.log" >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat "$OUT"
|
||||
PASSED="$(grep -c '^PASS ' "$OUT" || true)"
|
||||
FAILED="$(grep -c '^FAIL ' "$OUT" || true)"
|
||||
echo "SUMMARY: ${PASSED} passed, ${FAILED} failed"
|
||||
|
||||
if [[ "$FAILED" -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
log 'vimwiki config compat OK ✓'
|
||||
exit 0
|
||||
Reference in New Issue
Block a user