#!/bin/sh -e

current_path="$PWD"
luals_path="$HOME/.local/share/nvim/lsp/lua-language-server"

# Clone / Update
if [ -d "$luals_path" ]; then
    cd $luals_path
    git pull --rebase
else
    git clone https://github.com/sumneko/lua-language-server.git $luals_path
fi

cd $luals_path
git submodule update --init --recursive

# Build
cd 3rd/luamake
./compile/install.sh
cd ../..
./3rd/luamake/luamake rebuild

cd $current_path
