# this is my zsh config. there are many like it, but this one is mine.
# https://zsh.sourceforge.io/Intro/intro_3.html
# shellcheck shell=bash

# export VERBOSE=1
# export DEBUG=1
autoload -U promptinit; promptinit

export DOTFILES="$HOME/.dotfiles"
LOCAL_SHARE="$HOME/.local/share"
export PATH="$HOME/.local/bin:$DOTFILES/local/bin:$LOCAL_SHARE/nvim/mason/bin:$LOCAL_SHARE/bob/nvim-bin:$LOCAL_SHARE/cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"
export SHARED_SCRIPTS_SOURCED=0

source "$DOTFILES/config/shared.sh"

# zsh completions directory
[ -z "$ZSH_COMPLETIONS" ] && export ZSH_COMPLETIONS="$XDG_CONFIG_HOME/zsh/completion"

# Add zsh completions to FPATH, compinit will be called later
FPATH="$ZSH_COMPLETIONS:$FPATH"

ZSH_COMPDUMP="$XDG_CACHE_HOME/zsh/zcompdump-${SHORT_HOST}-${ZSH_VERSION}"

source "$DOTFILES/config/zsh/antidote.zsh"

# Function to source FZF configuration
source_fzf_config()
{
  local fzf_config="${DOTFILES}/config/fzf/fzf.zsh"
  if [[ -f "$fzf_config" ]]; then
    # shellcheck source=config/fzf/fzf.zsh
    source "$fzf_config"
  fi
}

# Function to set up tmux window name plugin if tmux is active
setup_tmux_window_name_plugin()
{
  if [[ -n "$TMUX" ]]; then
    local tmux_window_name_plugin="$TMUX_PLUGINS/tmux-window-name/scripts/rename_session_windows.py"
    if [[ -f "$tmux_window_name_plugin" ]]; then
      tmux_window_name()
      {
        ($tmux_window_name_plugin &)
      }
      add-zsh-hook chpwd tmux_window_name
      tmux_window_name
    fi
  fi
}

source_fzf_config
setup_tmux_window_name_plugin
x-have antidot && eval "$(antidot init)"

autoload -Uz compinit bashcompinit
compinit -d $ZSH_COMPDUMP
bashcompinit

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
export P10K_CONFIG="$DOTFILES/config/zsh/p10k.zsh"
[[ ! -f "$P10K_CONFIG" ]] || source "$P10K_CONFIG"

# Added by LM Studio CLI (lms)
export PATH="$PATH:$HOME/.lmstudio/bin"
