6-nvim 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. # NAME: Setup Neovim configuration
  3. # REQUIRES: interactive
  4. set -euo pipefail
  5. # Source common functions
  6. source "$(dirname "$0")/../common.sh" || {
  7. echo "[ERROR] Could not source common.sh" >&2
  8. exit 1
  9. }
  10. readonly NVIM_REPO="https://github.com/marianozunino/nvim.git"
  11. readonly NVIM_CONFIG_DIR="$HOME/.config/nvim"
  12. check_requirements() {
  13. if ! command_exists git; then
  14. log_error "git is required but not installed"
  15. exit 1
  16. fi
  17. }
  18. setup_neovim_config() {
  19. log_info "Setting up Neovim configuration"
  20. if [[ -d "$NVIM_CONFIG_DIR" ]]; then
  21. local backup_dir="$NVIM_CONFIG_DIR.backup.$(date +%Y%m%d_%H%M%S)"
  22. log_info "Backing up existing Neovim config to $backup_dir"
  23. mv "$NVIM_CONFIG_DIR" "$backup_dir"
  24. fi
  25. log_info "Cloning Neovim config to $NVIM_CONFIG_DIR"
  26. git clone "$NVIM_REPO" "$NVIM_CONFIG_DIR"
  27. cd "$NVIM_CONFIG_DIR"
  28. if [[ -d ".githooks" ]]; then
  29. git config core.hooksPath .githooks
  30. chmod +x .githooks/* 2>/dev/null || true
  31. log_info "Git hooks configured"
  32. fi
  33. }
  34. main() {
  35. init_script
  36. check_requirements
  37. setup_neovim_config
  38. log_info "Neovim configuration: $NVIM_CONFIG_DIR"
  39. finish_script 0
  40. }
  41. main "$@"