dev: start-* launchers always start from a clean setup
CI / cargo fmt --check (push) Successful in 18s
CI / cargo clippy (push) Successful in 31s
CI / cargo test (push) Successful in 27s
CI / editor keymaps (push) Successful in 1m24s

The launchers reused whatever was left under $XDG_CACHE_HOME/nuwiki-dev
between runs — seed_wiki() skipped reseeding when index.wiki already
existed, so stale edits from a previous session leaked into the next, and
old swap/viminfo/coc state carried over.

Each launch now starts clean:
- seed_wiki() reseeds the managed scratch wiki from a pristine copy every
  run (rm -rf + write_sample_wiki). A user-pointed NUWIKI_DEV_WIKI is never
  wiped — it's seeded only when empty, so a real wiki is never clobbered.
  NUWIKI_DEV_NO_SEED still bypasses seeding entirely.
- new reset_dirs() helper wipes + recreates each launcher's owned state dirs
  (vim viminfo/swap/undo, coc data, nvim XDG state/data/config) before launch.

Cached plugin clones (vim-lsp, async.vim, coc.nvim) are kept — only the
wiki and editor state are reset. Header docs updated to describe the
fresh-each-launch behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 15:07:15 +00:00
parent 6983daa637
commit 39692ba99f
4 changed files with 47 additions and 6 deletions
+6 -1
View File
@@ -22,6 +22,11 @@
# so this is a fast no-op when nothing changed. Set
# NUWIKI_DEV_SKIP_BUILD=1 to skip the build step entirely.
#
# Each launch starts clean: the scratch wiki is reseeded from a pristine
# copy and the editor state (cache/data/config) is wiped, so stale edits
# never carry over. A wiki you point at with NUWIKI_DEV_WIKI is never wiped
# (seeded only if empty).
#
# Tested with Neovim 0.10+. State (cache/data/config) lives under
# $XDG_CACHE_HOME/nuwiki-dev/ so your real Neovim install stays
# untouched.
@@ -78,7 +83,7 @@ main() {
ensure_binary
seed_wiki
write_init
mkdir -p "$STATE_DIR" "$DATA_DIR" "$CONFIG_DIR"
reset_dirs "$STATE_DIR" "$DATA_DIR" "$CONFIG_DIR"
log "launching: nvim --clean -u $INIT_FILE"
if [[ $# -gt 0 ]]; then