Neovim 0.12.6 segfaulted on the way out after a finished Lazy! sync (report CD-P8RUBS), and the update step failed though the plugins were up to date. If nvim dies from a signal, run the sync once more; it fails if Neovim crashes again, and an ordinary failure isn't retried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.9 KiB
Bash
Executable File
48 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Only the plugins are updated; the kickstart.nvim config itself is the user's to edit.
|
|
LAZY_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lazy"
|
|
PLUGIN_BACKUPS="${XDG_STATE_HOME:-$HOME/.local/state}/coredesktop/nvim-plugins"
|
|
|
|
is_installed() {
|
|
command -v nvim &>/dev/null && [ -d "$LAZY_DIR/lazy.nvim" ]
|
|
}
|
|
|
|
# lazy.nvim won't update a plugin whose tracked files differ from its checkout
|
|
# (it checks with `git ls-files -d -m`). An interrupted update can leave a
|
|
# plugin like that, along with leftovers git won't overwrite, such as new files
|
|
# and half-cloned submodules (LuaSnip, 2026-10-20). Move such a plugin out of
|
|
# the way, so `Lazy! sync` installs it afresh; any edits made to it are in the
|
|
# copy. So is a plugin an earlier version of this step only stashed.
|
|
set_aside_broken_plugins() {
|
|
local dir name dest
|
|
for dir in "$LAZY_DIR"/*/; do
|
|
dir="${dir%/}"
|
|
[ -d "$dir/.git" ] || continue
|
|
if [ -z "$(git -C "$dir" ls-files -d -m 2> /dev/null)" ] \
|
|
&& ! git -C "$dir" stash list 2> /dev/null | grep -q "Stashed by CoreDesktop's update"; then
|
|
continue
|
|
fi
|
|
name="$(basename "$dir")"
|
|
dest="$PLUGIN_BACKUPS/$name-$(date +%Y-%m-%d-%H%M%S)"
|
|
mkdir -p "$PLUGIN_BACKUPS" && mv "$dir" "$dest" \
|
|
&& echo " $name's files didn't match its version, so it will be installed again. The old copy is in $dest"
|
|
done
|
|
}
|
|
|
|
run_update() {
|
|
echo "Updating Neovim plugins..."
|
|
set_aside_broken_plugins
|
|
# Neovim has crashed on the way out after a finished sync (a segfault on
|
|
# 0.12.6, report CD-P8RUBS, 2026-11-11). If it dies from a signal, sync once
|
|
# more: that finishes anything left over, and fails if it crashes again.
|
|
local status=0
|
|
nvim --headless "+Lazy! sync" +qa || status=$?
|
|
if [ "$status" -gt 128 ]; then
|
|
echo " Neovim crashed (signal $((status - 128))), so syncing the plugins once more..."
|
|
nvim --headless "+Lazy! sync" +qa
|
|
return
|
|
fi
|
|
return "$status"
|
|
}
|