#!/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" 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`), which an interrupted update can leave # behind. Stash those changes, so the plugin updates and they can still be # recovered with `git stash pop` in its folder, and put its submodules back. restore_plugins() { local dir for dir in "$LAZY_DIR"/*/; do [ -d "$dir/.git" ] || continue [ -n "$(git -C "$dir" ls-files -d -m 2> /dev/null)" ] || continue echo " $(basename "$dir") had local changes; stashing them so it can update." git -C "$dir" stash push -q -m "Stashed by CoreDesktop's update" \ && git -C "$dir" submodule update -q --init --recursive --force done } run_update() { echo "Updating Neovim plugins..." restore_plugins nvim --headless "+Lazy! sync" +qa }