# ════════════════════════════════════════════════════════════
# Ada's Modular ZSH Configuration
# ════════════════════════════════════════════════════════════

# ═══ Powerlevel10k Instant Prompt ══════════════════════════
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# Путь к конфигурации zsh
export ZDOTDIR="${ZDOTDIR:-${HOME}/.config/zsh}"
ZSH_CONFIG_DIR="${ZDOTDIR}/config"

# ═══ Zinit (Plugin Manager) ════════════════════════════════
# Автоматическая установка zinit при первом запуске
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
if [[ ! -d "$ZINIT_HOME" ]]; then
    print -P "%F{blue}▓▒░ Установка zinit...%f"
    mkdir -p "$(dirname $ZINIT_HOME)"
    git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi

# Загрузка zinit
source "${ZINIT_HOME}/zinit.zsh"

# ═══ Загрузка модулей ══════════════════════════════════════
# Порядок загрузки важен!
source "${ZSH_CONFIG_DIR}/env.zsh"          # Переменные окружения
source "${ZSH_CONFIG_DIR}/options.zsh"      # Настройки оболочки
source "${ZSH_CONFIG_DIR}/plugins.zsh"      # Плагины через zinit
source "${ZSH_CONFIG_DIR}/completion.zsh"   # Автодополнение
source "${ZSH_CONFIG_DIR}/aliases.zsh"      # Алиасы
source "${ZSH_CONFIG_DIR}/functions.zsh"    # Пользовательские функции
source "${ZSH_CONFIG_DIR}/keybindings.zsh"  # Горячие клавиши
source "${ZSH_CONFIG_DIR}/prompt.zsh"       # Настройка промпта (starship)

# ═══ Локальные настройки (опционально) ═════════════════════
# Для машинно-специфичных настроек
[[ -f "${ZSH_CONFIG_DIR}/local.zsh" ]] && source "${ZSH_CONFIG_DIR}/local.zsh"

# To customize prompt, run `p10k configure` or edit ~/.config/zsh/.p10k.zsh.
[[ ! -f ~/.config/zsh/.p10k.zsh ]] || source ~/.config/zsh/.p10k.zsh

# To customize prompt, run `p10k configure` or edit /home/ada/.config/zsh/.p10k.zsh.
[[ ! -f /home/ada/.config/zsh/.p10k.zsh ]] || source /home/ada/.config/zsh/.p10k.zsh


export NVM_DIR="$HOME/.config/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion


# . "$HOME/.local/share/../bin/env"

# To customize prompt, run `p10k configure` or edit ~/.dotfiles/zsh/.config/zsh/.p10k.zsh.
[[ ! -f ~/.dotfiles/zsh/.config/zsh/.p10k.zsh ]] || source ~/.dotfiles/zsh/.config/zsh/.p10k.zsh
