#!/bin/sh

check_deps(){
which nvim
if [ $? -eq 1 ]; then
    clear
    echo "Please install neovim and try again"
    exit 1
fi
which git
if [ $? -eq 1 ]; then
    clear
    echo "Please install git to and try again"
    exit 1
fi
which gcc
if [ $? -eq 1 ]; then
    clear
    echo "Please install gcc and try again"
    exit 1
fi
}
install() {
    git clone --depth 1 https://github.com/justinlime/dotfiles
    cd dotfiles
    # Backup old dirs
    mv ~/.config/nvim ~/.config/nvim.old
    mv ~/.local/share/nvim ~/.local/share/nvim.old
    mv ~/.local/state/nvim ~/.local/state/nvim.old
    cp -r ./nvim ~/.config/nvim
    nvim
}

check_deps
cat << EOF

⠀⣞⢽⢪⢣⢣⢣⢫⡺⡵⣝⡮⣗⢷⢽⢽⢽⣮⡷⡽⣜⣜⢮⢺⣜⢷⢽⢝⡽⣝
⠸⡸⠜⠕⠕⠁⢁⢇⢏⢽⢺⣪⡳⡝⣎⣏⢯⢞⡿⣟⣷⣳⢯⡷⣽⢽⢯⣳⣫⠇
⠀⠀⢀⢀⢄⢬⢪⡪⡎⣆⡈⠚⠜⠕⠇⠗⠝⢕⢯⢫⣞⣯⣿⣻⡽⣏⢗⣗⠏⠀
⠀⠪⡪⡪⣪⢪⢺⢸⢢⢓⢆⢤⢀⠀⠀⠀⠀⠈⢊⢞⡾⣿⡯⣏⢮⠷⠁⠀⠀
⠀⠀⠀⠈⠊⠆⡃⠕⢕⢇⢇⢇⢇⢇⢏⢎⢎⢆⢄⠀⢑⣽⣿⢝⠲⠉⠀⠀⠀⠀
⠀⠀⠀⠀⠀⡿⠂⠠⠀⡇⢇⠕⢈⣀⠀⠁⠡⠣⡣⡫⣂⣿⠯⢪⠰⠂⠀⠀⠀⠀
⠀⠀⠀⠀⡦⡙⡂⢀⢤⢣⠣⡈⣾⡃⠠⠄⠀⡄⢱⣌⣶⢏⢊⠂⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢝⡲⣜⡮⡏⢎⢌⢂⠙⠢⠐⢀⢘⢵⣽⣿⡿⠁⠁⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠨⣺⡺⡕⡕⡱⡑⡆⡕⡅⡕⡜⡼⢽⡻⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣼⣳⣫⣾⣵⣗⡵⡱⡡⢣⢑⢕⢜⢕⡝⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⣴⣿⣾⣿⣿⣿⡿⡽⡑⢌⠪⡢⡣⣣⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⡟⡾⣿⢿⢿⢵⣽⣾⣼⣘⢸⢸⣞⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠁⠇⠡⠩⡫⢿⣝⡻⡮⣒⢽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

This script will move any current Neovim configs to a .old directory, files affected:

$HOME/.config/nvim --> $HOME/.config/nvim.old
$HOME/.local/share/nvim --> $HOME/.local/share/nvim.old
$HOME/.local/state/nvim --> $HOME/.local/state/nvim.old

EOF

while true; do
    read -p "Do you wish to proceed? [y,n]> " yn
    case $yn in
        [Yy]* ) 
            install
            exit
            ;;
        [Nn]* ) 
            exit;;
        * ) 
            echo "Yes, or No?[y,n]";;
    esac
done



