dev/runs/nvim

55 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# NAME: Setup Neovim configuration
# REQUIRES: interactive
set -euo pipefail
# Source common functions
source "$(dirname "$0")/../common.sh" || {
echo "[ERROR] Could not source common.sh" >&2
exit 1
}
readonly NVIM_REPO="https://github.com/marianozunino/nvim.git"
readonly NVIM_CONFIG_DIR="$HOME/.config/nvim"
check_requirements() {
if ! command_exists git; then
log_error "git is required but not installed"
exit 1
fi
}
setup_neovim_config() {
log_info "Setting up Neovim configuration"
if [[ -d "$NVIM_CONFIG_DIR" ]]; then
local backup_dir="$NVIM_CONFIG_DIR.backup.$(date +%Y%m%d_%H%M%S)"
log_info "Backing up existing Neovim config to $backup_dir"
mv "$NVIM_CONFIG_DIR" "$backup_dir"
fi
log_info "Cloning Neovim config to $NVIM_CONFIG_DIR"
git clone "$NVIM_REPO" "$NVIM_CONFIG_DIR"
cd "$NVIM_CONFIG_DIR"
if [[ -d ".githooks" ]]; then
git config core.hooksPath .githooks
chmod +x .githooks/* 2>/dev/null || true
log_info "Git hooks configured"
fi
}
main() {
init_script
check_requirements
setup_neovim_config
log_info "Neovim configuration: $NVIM_CONFIG_DIR"
finish_script 0
}
main "$@"