#!/usr/bin/env bash
#
# Clone or update nvim to $HOME/dev/neovim, build and install to $HOME/local
set -e

mkdir -p "$HOME/dev"
destdir=$HOME/dev/neovim
if [ -d "$destdir" ]; then
  echo "Updating nvim..."
  cd "$destdir"
  git pull --rebase
else
  echo "Cloning nvim..."
  cd "$HOME/dev"
  git clone -q https://github.com/neovim/neovim.git neovim
  cd "$destdir"
fi

make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX="$HOME/local"
make install