# =============================================================================
# 1. ZSH THEME & PLUGINS (Must be defined before Oh My Zsh loads)
# =============================================================================
export ZSH="$HOME/.oh-my-zsh"

source_if_readable() {
    local file="$1"
    if [[ -f "$file" && -r "$file" ]]; then
        source "$file"
    fi
}

ZSH_THEME="spaceship"

SPACESHIP_PROMPT_ORDER=(
  time          # Time stamps section
  user          # Username section
  dir           # Current directory section
  git           # Git section (git_branch + git_status)
  node          # Node.js section
  dotnet        # .NET section
  java          # Java section
  kotlin        # Kotlin section
  ruby          # Ruby section
  xcode         # Xcode section
  swift         # Swift section
  golang        # Go section
  docker        # Docker section
  venv          # virtualenv section
  line_sep      # Line break
  char          # Prompt character
)

SPACESHIP_USER_SHOW=always
SPACESHIP_PROMPT_SEPARATE_LINE=true
SPACESHIP_PROMPT_ADD_NEWLINE=true
SPACESHIP_CHAR_SYMBOL="❯"
SPACESHIP_CHAR_SUFFIX=" "
SPACESHIP_DOCKER_CONTEXT_SHOW=false

if [[ $(uname) == "Darwin" ]]; then
    #  is the Apple logo in Nerd Fonts
    SPACESHIP_USER_SUFFIX="%F{cyan} [ macOS]%f "
elif [[ $(uname) == "Linux" ]]; then
    #  is the Ubuntu logo in Nerd Fonts
    SPACESHIP_USER_SUFFIX="%F{yellow} [ Ubuntu]%f "
else
    SPACESHIP_USER_SUFFIX=" "
fi

plugins=(git zsh-syntax-highlighting zsh-autosuggestions)

# Initialize Oh My Zsh (Crucial for themes and plugins to work)
source_if_readable "$ZSH/oh-my-zsh.sh"

# =============================================================================
# 2. THIRD-PARTY INITIALIZATION (SDKMAN, NVM, Oh My Zsh)
# =============================================================================
source_if_readable "$HOME/.sourcerc"

# =============================================================================
# 3. CUSTOM OVERRIDES (Functions must load before Path Management)
# =============================================================================
source_if_readable "$HOME/.func"

# =============================================================================
# 4. PATH MANAGEMENT (Relies on append_path from .func)
# =============================================================================
source_if_readable "$HOME/.pathrc"

# =============================================================================
# 5. ALIASES (Loaded dead last so YOUR code always wins over Oh My Zsh)
# =============================================================================
source_if_readable "$HOME/.alias"
