main/modules/40-nvim.sh

34 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# 40-nvim — clone your nvim-minimal config from gitea to ~/.config/nvim.
step_name="nvim"
step_desc="clone g.mk.fo/bootstrap/nvim-minimal -> ~/.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="${XDG_CONFIG_HOME:-$HOME/.config}/nvim"
if [[ -d "$target/.git" ]]; then
log "existing nvim config is a git repo — pulling"
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)"
mv "$target" "$bak"
warn "backed up existing $target -> $bak"
fi
if git clone "$NVIM_REPO_URL" "$target"; then
ok "nvim config cloned to $target"
else
err "failed to clone $NVIM_REPO_URL"
return 1
fi
}