#!/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: ./development/start-nvim.sh [extra args...] # ./development/start-nvim.sh # open the scratch wiki's index # ./development/start-nvim.sh path/to/note.wiki # open a specific file # NUWIKI_DEV_WIKI=/tmp/foo ./development/start-nvim.sh # NUWIKI_DEV_NO_SEED=1 ./development/start-nvim.sh # use WIKI_DIR as-is (no scratch seeding) # NUWIKI_DEV_SKIP_BUILD=1 ./development/start-nvim.sh # reuse the cached binary # # The release binary is rebuilt on every launch so source changes # always reach the running LSP. `cargo build --release` is incremental, # so this is a fast no-op when nothing changed. Set # NUWIKI_DEV_SKIP_BUILD=1 to skip the build step entirely. # # 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 # Shared paths + helpers (log, ensure_binary, write_sample_wiki, seed_wiki). source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_common.sh" INIT_FILE="$DEV_DIR/init.lua" STATE_DIR="$DEV_DIR/nvim-state" DATA_DIR="$DEV_DIR/nvim-data" CONFIG_DIR="$DEV_DIR/nvim-config" write_init() { mkdir -p "$DEV_DIR" cat > "$INIT_FILE" <