#!/bin/bash

if ! [ -a /usr/bin/nvim ]; then
    echo "Installing nvim..."
    curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
    chmod au+x nvim.appimage
    cp nvim.appimage /usr/bin/nvim

    sudo update-alternatives --install /usr/bin/vi vi /usr/bin/nvim 60
    sudo update-alternatives --config vi
    sudo update-alternatives --install /usr/bin/vim vim /usr/bin/nvim 60
    sudo update-alternatives --config vim
    sudo update-alternatives --install /usr/bin/editor editor /usr/bin/nvim 60
    sudo update-alternatives --config editor
fi

sudo apt update
sudo apt install -y tmux stow podman cloc

mkdir -p ~/Code
cd ~/Code

if ! [ -a config ]; then
    git clone https://github.com/ntietz/config.git
    cd config
fi

mkdir -p ~/Code/vendor
cd ~/Code/vendor

if ! [ -a tla-bin ]; then
    git clone https://github.com/pmer/tla-bin.git
fi
cd tla-bin
./download_or_update_tla.sh
sudo ./install.sh /usr/local
sudo apt install -y openjdk-17-jre

# This is needed for coc.nvim
sudo apt install -y nodejs npm