#!/usr/bin/env bash

set -euxo pipefail

echo -e "\033[0;32m>>>>> Begin LVim installation <<<<<\033[0m"

{{ if (eq .chezmoi.osRelease.id "manjaro" "arch") -}}

  ## Install packages
  {{ range .packages_lvim.archlinux.yay -}}
    echo "installing {{ . | quote }}..."
    yay -S --needed --noconfirm {{ . | quote }}
  {{ end -}}

{{ else if (eq .chezmoi.osRelease.id "debian" "ubuntu") -}}

  export DEBIAN_FRONTEND=noninteractive

  ## Install packages
  {{ range .packages_base.debian.apt -}}
    echo "installing {{ . | quote }}..."
    {{- if ne .chezmoi.username "root" }}
      sudo -E apt-get install --yes --no-install-recommends --ignore-missing {{ . | quote }}
    {{- else}}
      apt-get install --yes --no-install-recommends --ignore-missing {{ . | quote }}
    {{- end }}
  {{ end -}}

  {{ range .packages_base.debian.mist -}}
    echo "installing {{ . | quote }}..."
    apt-get install --yes --no-install-recommends --ignore-missing {{ . | quote }}
  {{ end -}}

{{- end }}

LV_BRANCH='release-1.3/neovim-0.9' bash <(curl -s 'https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh')

echo -e "\033[0;32m>>>>> Finish LVim installation <<<<<\033[0m"