#!/usr/bin/env bash
# shellcheck shell=bash
# shellcheck enable=external-sources
# shellcheck disable=1091,2139
# vim: filetype=bash

# Antigen configuration
# https://github.com/zsh-users/antigen/wiki/Configuration
export ADOTDIR="$XDG_DATA_HOME/antigen"
export ANTIGEN_CACHE="$XDG_CACHE_HOME/antigen"
export ANTIGEN_SYSTEM_RECEIPT_F=".local/share/antigen/antigen_system_lastupdate"
export ANTIGEN_PLUGIN_RECEIPT_F=".local/share/antigen/antigen_plugin_lastupdate"

# Ansible configuration
# https://docs.ansible.com/ansible/latest/reference_appendices/config.html
export ANSIBLE_HOME="$XDG_CONFIG_HOME/ansible"
export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible.cfg"
export ANSIBLE_GALAXY_CACHE_DIR="$XDG_CACHE_HOME/ansible/galaxy_cache"
x-dc "$ANSIBLE_HOME"
x-dc "$ANSIBLE_GALAXY_CACHE_DIR"

export ANDROID_HOME="$XDG_DATA_HOME/android"

# bob manages nvim versions
export PATH="$XDG_DATA_HOME/bob/nvim-bin:$PATH"

# bkt (shell command caching tool) configuration
export BKT_TTL=1m

# brew, https://docs.brew.sh/Manpage
export HOMEBREW_NO_ENV_HINTS=true
export HOMEBREW_BUNDLE_MAS_SKIP=true
export HOMEBREW_BUNDLE_FILE="$XDG_CONFIG_HOME/homebrew/Brewfile"

# composer, https://getcomposer.org/
export COMPOSER_HOME="$XDG_STATE_HOME/composer"
export COMPOSER_BIN="$COMPOSER_HOME/vendor/bin"
export PATH="$COMPOSER_BIN:$PATH"

# docker, https://docs.docker.com/engine/reference/commandline/cli/
export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker"
x-dc "$DOCKER_CONFIG"
# Docker: Disable snyk ad
export DOCKER_SCAN_SUGGEST=false

# ffmpeg
export FFMPEG_DATADIR="$XDG_CONFIG_HOME/ffmpeg"
x-have ffmpeg && x-dc "$FFMPEG_DATADIR"

# GnuPG
export GNUPGHOME="$XDG_DATA_HOME/gnupg"

# Go
export GOPATH="$XDG_DATA_HOME/go"
export GOBIN="$XDG_BIN_HOME"

# Herd, herd.laravel.com
# Herd injected PHP binary.
export PATH="$HOME/Library/Application Support/Herd/bin/":$PATH

x-have herd && {
  # Herd injected PHP 8.3 configuration.
  export HERD_PHP_83_INI_SCAN_DIR="$HOME/Library/Application Support/Herd/config/php/83/"
  # Herd injected PHP 7.4 configuration.
  export HERD_PHP_74_INI_SCAN_DIR="$HOME/Library/Application Support/Herd/config/php/74/"
}

# nb, https://xwmx.github.io/nb/
export NBRC_PATH="$XDG_CONFIG_HOME/nbrc"
export NB_DIR="$XDG_STATE_HOME/nb"

# NPM: Add npm packages to path
x-have node && {
  NVM_NODE_BIN_DIR="$(dirname "$(which node)")"
  export PATH="$NVM_NODE_BIN_DIR:$PATH"
}

# op (1Password cli) is present
export OP_CACHE="$XDG_STATE_HOME/1password"

# Python
#
# pyenv, python environments
export WORKON_HOME="$XDG_DATA_HOME/virtualenvs"
export PYENV_ROOT="$XDG_STATE_HOME/pyenv"
export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
x-have pyenv && {
  eval "$(pyenv init -)"
}

# Ruby
#
# including: bundler, rbenv
export GEM_HOME="${XDG_DATA_HOME}"/gem
export GEM_SPEC_CACHE="${XDG_CACHE_HOME}"/gem
export BUNDLE_USER_CONFIG="$XDG_CONFIG_HOME"/bundle
export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle
export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle
export RBENV_ROOT="$XDG_STATE_HOME/rbenv"
x-dc "$RBENV_ROOT"
x-have gem && export PATH="${GEM_HOME}/bin:$PATH"

# Rust / cargo
export RUSTUP_HOME="$XDG_DATA_HOME/rustup"
export CARGO_HOME="$XDG_DATA_HOME/cargo"
export PATH="$CARGO_HOME/bin:$PATH"

# screen
export SCREENRC="$XDG_CONFIG_HOME/misc/screenrc"

# sonarlint
export SONARLINT_USER_HOME="$XDG_DATA_HOME/sonarlint"

# terraform
# https://www.terraform.io/docs/cli/config/config-file.html
# https://www.terraform.io/docs/cli/config/environment-variables.html
export TF_DATA_DIR="$XDG_STATE_HOME/terraform"
export TF_CLI_CONFIG_FILE="$XDG_CONFIG_HOME/terraform/terraformrc"
export TF_PLUGIN_CACHE_DIR="$XDG_CACHE_HOME/terraform/plugin-cache"

# tldr / tealdeer
export TEALDEER_CONFIG_DIR="$XDG_CONFIG_HOME/tealdeer/"

# tmux
export TMUX_CONF="$XDG_CONFIG_HOME/tmux/tmux.conf"

# wakatime, https://github.com/wakatime/wakatime-cli
export WAKATIME_HOME="$XDG_STATE_HOME/wakatime"
x-dc "$WAKATIME_HOME"

# Misc
export BAT_THEME="ansi"
export CHEAT_USE_FZF=true
export SQLITE_HISTORY="$XDG_CACHE_HOME"/sqlite_history
