#!/bin/sh
#
# Copyright (c) 2026 neoche contributors
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#

set -e

if [ -d "$HOME/.config/nvim" ]; then
  echo "[INFO] existing nvim config found, skipping distro bootstrap"
  exit 0
fi

case "$NVIM_DISTRO" in
  lazyvim)
    echo "[INFO] bootstrapping LazyVim"
    git clone https://github.com/LazyVim/starter "$HOME/.config/nvim"
    ;;
  astrovim)
    echo "[INFO] bootstrapping AstroVim"
    git clone https://github.com/AstroNvim/template "$HOME/.config/nvim"
    ;;
  nvchad)
    echo "[INFO] bootstrapping NvChad"
    git clone https://github.com/NvChad/starter "$HOME/.config/nvim"
    ;;
  kickstart)
    echo "[INFO] bootstrapping kickstart.nvim"
    git clone https://github.com/nvim-lua/kickstart.nvim "$HOME/.config/nvim"
    ;;
  *)
    echo "[WARN] unknown NVIM_DISTRO: $NVIM_DISTRO"
    exit 0
    ;;
esac

rm -rf "$HOME/.config/nvim/.git"
echo "[INFO] $NVIM_DISTRO bootstrapped to $HOME/.config/nvim"
