From cf94f99d3c7d1ff1edb8db9d8393db2b985c2010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fr=C3=B3es=20Franco?= Date: Mon, 11 May 2026 22:04:11 +0000 Subject: [PATCH] dev: minimal-config launchers for nvim/vim plugin testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two scripts at the repo root that spin up an isolated editor session against this checkout, so changes to the plugin or LSP can be smoke- tested without polluting the user's real (n)vim install: - start-nvim.sh — builds nuwiki-ls in release mode, symlinks it into `bin/`, seeds a scratch wiki under `$XDG_CACHE_HOME/nuwiki-dev/wiki`, generates a minimal `init.lua` that prepends this repo to `runtimepath`, points `vim.env.XDG_*` at the dev cache so the host's Neovim state is untouched, and execs `nvim --clean -u `. - start-vim.sh — same shape for Vim. Clones vim-lsp + async.vim into the dev cache on first run so the LSP path is actually exercisable (the plugin's autoload layer prefers vim-lsp). Opt-out via `NUWIKI_DEV_NO_LSP=1` for syntax-only testing. Both scripts: - Are idempotent (skip cargo build / git clone / wiki seed when their outputs are already in place). - Pass through extra args to the editor; default to opening the scratch wiki's index page. - Accept `NUWIKI_DEV_WIKI=` to point at a custom sandbox. - Seed `index.wiki` + `Notes.wiki` with smoke-test content covering wikilinks, anchors, checkboxes, tags, and the `:Vimwiki*` command surface. Co-Authored-By: Claude Opus 4.7 (1M context) --- start-nvim.sh | 147 +++++++++++++++++++++++++++++++++++++++++ start-vim.sh | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 327 insertions(+) create mode 100755 start-nvim.sh create mode 100755 start-vim.sh diff --git a/start-nvim.sh b/start-nvim.sh new file mode 100755 index 0000000..c174fa3 --- /dev/null +++ b/start-nvim.sh @@ -0,0 +1,147 @@ +#!/usr/bin/env bash +# +# start-nvim.sh — launch Neovim with a minimal config that loads nuwiki. +# +# Builds the language server (release mode), symlinks it into `bin/` so +# the plugin's default install path resolves, then spawns Neovim with +# `--clean` and a generated `init.lua` that: +# * adds this repo to `runtimepath` +# * configures wiki_root to a scratch directory under +# $XDG_CACHE_HOME/nuwiki-dev/wiki +# * calls `require('nuwiki').setup({...})` +# +# Usage: ./start-nvim.sh [extra args...] +# ./start-nvim.sh # open the scratch wiki's index +# ./start-nvim.sh path/to/note.wiki # open a specific file +# NUWIKI_DEV_WIKI=/tmp/foo ./start-nvim.sh +# +# Tested with Neovim 0.10+. State (cache/data/config) lives under +# $XDG_CACHE_HOME/nuwiki-dev/ so your real Neovim install stays +# untouched. + +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +DEV_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/nuwiki-dev" +WIKI_DIR="${NUWIKI_DEV_WIKI:-$DEV_DIR/wiki}" +INIT_FILE="$DEV_DIR/init.lua" +STATE_DIR="$DEV_DIR/nvim-state" +DATA_DIR="$DEV_DIR/nvim-data" +CONFIG_DIR="$DEV_DIR/nvim-config" + +log() { printf '\033[1;34m[nuwiki-dev]\033[0m %s\n' "$*"; } + +ensure_binary() { + local bin="$REPO_ROOT/bin/nuwiki-ls" + local built="$REPO_ROOT/target/release/nuwiki-ls" + if [[ -x "$bin" ]]; then + return + fi + log "building nuwiki-ls (release)…" + cargo build --release -p nuwiki-ls --manifest-path "$REPO_ROOT/Cargo.toml" + mkdir -p "$REPO_ROOT/bin" + ln -sf "$built" "$bin" + log "binary ready: $bin" +} + +seed_wiki() { + mkdir -p "$WIKI_DIR" "$WIKI_DIR/diary" + if [[ ! -f "$WIKI_DIR/index.wiki" ]]; then + cat > "$WIKI_DIR/index.wiki" <<'EOF' += Welcome to nuwiki = + +This is a scratch wiki created by start-nvim.sh. Edit, run commands, +or jump to the linked pages to test the plugin. + +== Smoke test == + +- [[Notes]] +- [[diary/]] +- [ ] Toggle me with +- [ ] Or with :VimwikiToggleListItem + +== Commands to try == + +- :VimwikiTOC +- :VimwikiGenerateLinks +- :VimwikiCheckLinks +- :VimwikiMakeDiaryNote +- :Vimwiki2HTMLBrowse + +== Tags == + +:smoke-test:sandbox: + +== Links == + +* [[Notes]] +* [[Notes#section-one]] +* https://example.com +EOF + fi + if [[ ! -f "$WIKI_DIR/Notes.wiki" ]]; then + cat > "$WIKI_DIR/Notes.wiki" <<'EOF' += Notes = + +A second page so [[index]] has somewhere to point. + +== Section one == + +Anchor target for :checkhealth-style smoke tests. +EOF + fi +} + +write_init() { + mkdir -p "$DEV_DIR" + cat > "$INIT_FILE" </dev/null 2>&1; then + log "git not found — skipping $repo_url" + return 1 + fi + log "cloning $repo_url → $dest" + git clone --depth 1 "$repo_url" "$dest" >/dev/null 2>&1 +} + +ensure_vim_lsp() { + if [[ "${NUWIKI_DEV_NO_LSP:-0}" == "1" ]]; then + log "NUWIKI_DEV_NO_LSP=1 — skipping vim-lsp setup" + return + fi + mkdir -p "$DEV_DIR" + clone_if_missing https://github.com/prabirshrestha/vim-lsp.git "$VIM_LSP_DIR" || true + clone_if_missing https://github.com/prabirshrestha/async.vim.git "$ASYNC_DIR" || true +} + +seed_wiki() { + mkdir -p "$WIKI_DIR" "$WIKI_DIR/diary" + if [[ ! -f "$WIKI_DIR/index.wiki" ]]; then + cat > "$WIKI_DIR/index.wiki" <<'EOF' += Welcome to nuwiki = + +This is a scratch wiki created by start-vim.sh. Edit, run commands, +or jump to the linked pages to test the plugin. + +== Smoke test == + +- [[Notes]] +- [[diary/]] +- [ ] Toggle me with :VimwikiToggleListItem +- [ ] Inspect the LSP via :LspStatus + +== Commands to try == + +- :VimwikiTOC +- :VimwikiGenerateLinks +- :VimwikiCheckLinks +- :VimwikiMakeDiaryNote + +== Tags == + +:smoke-test:sandbox: +EOF + fi + if [[ ! -f "$WIKI_DIR/Notes.wiki" ]]; then + cat > "$WIKI_DIR/Notes.wiki" <<'EOF' += Notes = + +A second page so [[index]] has somewhere to point. + +== Section one == + +Anchor target for cross-page link follows. +EOF + fi +} + +write_vimrc() { + mkdir -p "$DEV_DIR" + cat > "$VIMRC" <