#!/usr/bin/env bash # 40-nvim — clone your nvim-minimal config from gitea to ~$TARGET_USER/.config/nvim. step_name="nvim" step_desc="clone g.mk.fo/bootstrap/nvim-minimal -> ~$TARGET_USER/.config/nvim" step_run="run_nvim" NVIM_REPO_URL="${NVIM_REPO_URL:-https://g.mk.fo/bootstrap/nvim-minimal.git}" run_nvim() { log "installing nvim config" command -v nvim >/dev/null 2>&1 || warn "nvim binary not found — install the packages step first" local target="$TARGET_HOME/.config/nvim" if [[ -d "$target/.git" ]]; then log "existing nvim config is a git repo — pulling" as_user git -C "$target" pull --ff-only || warn "could not pull existing nvim config" ok "nvim config updated at $target" return fi if [[ -e "$target" ]]; then local bak="${target}.bak.$(date +%Y%m%d-%H%M%S)" as_user mv "$target" "$bak" 2>/dev/null || sudo_ mv "$target" "$bak" warn "backed up existing $target -> $bak" fi as_user git clone "$NVIM_REPO_URL" "$target" && ok "nvim config cloned to $target" \ || { err "failed to clone $NVIM_REPO_URL"; sudo_ git clone "$NVIM_REPO_URL" "$target" \ && chown -R "$TARGET_USER:$(id -gn "$TARGET_USER" 2>/dev/null || echo "$TARGET_USER")" "$target" \ && ok "nvim config cloned to $target (as root, then chowned)"; } }