# ── PATH ──────────────────────────────────────────────────────────
export PATH="$HOME/.local/bin:$PATH"

# ── Homebrew ──────────────────────────────────────────────────────
eval "$(/opt/homebrew/bin/brew shellenv)"
export HOMEBREW_AUTOREMOVE=1
export HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS=7

# ── Zinit Plugin Manager ─────────────────────────────────────────
ZINIT_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/zinit/zinit.git"
source "${ZINIT_HOME}/zinit.zsh"

zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-syntax-highlighting

# ── Tab accepts autosuggestion or falls back to completion ────
_accept_or_complete() {
  if [[ -n "$POSTDISPLAY" ]]; then
    zle autosuggest-accept
  else
    zle expand-or-complete
  fi
}
zle -N _accept_or_complete
bindkey '\t' _accept_or_complete

# ── Starship Prompt ───────────────────────────────────────────────
eval "$(starship init zsh)"

# ── mise (runtime version manager) ───────────────────────────────
eval "$(mise activate zsh)"

# ── zoxide (smart cd) ────────────────────────────────────────────
eval "$(zoxide init zsh)"

# ── fzf (fuzzy finder: CTRL-R history, CTRL-T files, ALT-C dirs)
source <(fzf --zsh)

# ── PostgreSQL client tools (keg-only, server runs via Docker) ───
export PATH="/opt/homebrew/opt/libpq/bin:$PATH"

# ── Aliases ───────────────────────────────────────────────────────
alias ls="eza --icons --group-directories-first"
alias ll="eza --icons --group-directories-first -la"
alias lt="eza --icons --tree --level=2"
alias cat="bat --paging=never"
alias find="fd"
alias grep="rg"
alias update-all="topgrade"

# ── Local LLM (Docker Model Runner) ─────────────────────────────
export LLM_API_BASE="http://localhost:12434/v1"
alias llm="docker model run ai/gpt-oss"
alias llm-reason="docker model run hf.co/ggml-org/gpt-oss-120b-GGUF"
alias llm-code="docker model run ai/qwen3-coder-next"
alias llm-list="docker model list"
alias llm-ps="docker model ps"
alias llm-api="curl -s ${LLM_API_BASE}/models | jq"

# ── History ───────────────────────────────────────────────────────
HISTSIZE=50000
SAVEHIST=50000
HISTFILE=~/.zsh_history
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE

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