From bcb32777fbd30068639802ddea0f22ca1cd30d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fr=C3=B3es=20Franco?= Date: Thu, 14 May 2026 15:00:57 +0000 Subject: [PATCH] chore(dev): always rebuild release binary in start scripts ensure_binary used to short-circuit whenever bin/nuwiki-ls existed, which left vim/nvim running an outdated LSP after every source change. Now always invoke cargo build (incremental, so a no-op when nothing changed) and refresh the symlink + log the build timestamp. Add NUWIKI_DEV_SKIP_BUILD=1 for the rare opt-out. Co-Authored-By: Claude Opus 4.7 (1M context) --- start-nvim.sh | 17 ++++++++++++++--- start-vim.sh | 19 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/start-nvim.sh b/start-nvim.sh index c174fa3..be143ac 100755 --- a/start-nvim.sh +++ b/start-nvim.sh @@ -14,6 +14,12 @@ # ./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 +# NUWIKI_DEV_SKIP_BUILD=1 ./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 @@ -34,14 +40,19 @@ 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 + if [[ "${NUWIKI_DEV_SKIP_BUILD:-0}" == "1" ]]; then + if [[ ! -x "$bin" ]]; then + log "NUWIKI_DEV_SKIP_BUILD=1 but $bin is missing — building anyway" + else + log "NUWIKI_DEV_SKIP_BUILD=1 — using existing $bin" + return + fi 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" + log "binary ready: $bin (built $(date -r "$built" '+%Y-%m-%d %H:%M:%S'))" } seed_wiki() { diff --git a/start-vim.sh b/start-vim.sh index 815929d..dd59973 100755 --- a/start-vim.sh +++ b/start-vim.sh @@ -11,7 +11,13 @@ # ./start-vim.sh # open the scratch wiki's index # ./start-vim.sh path/to/note.wiki # open a specific file # NUWIKI_DEV_WIKI=/tmp/foo ./start-vim.sh -# NUWIKI_DEV_NO_LSP=1 ./start-vim.sh # skip vim-lsp setup +# NUWIKI_DEV_NO_LSP=1 ./start-vim.sh # skip vim-lsp setup +# NUWIKI_DEV_SKIP_BUILD=1 ./start-vim.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 Vim 9.1+. State (viminfo/sessions) lives under # $XDG_CACHE_HOME/nuwiki-dev/ so your real Vim install stays untouched. @@ -31,14 +37,19 @@ 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 + if [[ "${NUWIKI_DEV_SKIP_BUILD:-0}" == "1" ]]; then + if [[ ! -x "$bin" ]]; then + log "NUWIKI_DEV_SKIP_BUILD=1 but $bin is missing — building anyway" + else + log "NUWIKI_DEV_SKIP_BUILD=1 — using existing $bin" + return + fi 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" + log "binary ready: $bin (built $(date -r "$built" '+%Y-%m-%d %H:%M:%S'))" } clone_if_missing() {