# 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

# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git zsh-syntax-highlighting zsh-autosuggestions common-aliases docker docker-compose ansible aliases history nmap pip python rsync systemd vscode)

source $ZSH/oh-my-zsh.sh

# Source shared configurations
if [ -f ~/.dotfiles/shared/exports ]; then
    source ~/.dotfiles/shared/exports
fi

if [ -f ~/.dotfiles/shared/aliases ]; then
    source ~/.dotfiles/shared/aliases
fi

if [ -f ~/.dotfiles/shared/functions ]; then
    source ~/.dotfiles/shared/functions
fi

if [ -f ~/.dotfiles/shared/sync ]; then
    source ~/.dotfiles/shared/sync
fi

if [ -f ~/.dotfiles/shared/completions ]; then
    source ~/.dotfiles/shared/completions
fi

# Zsh-specific settings
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
setopt HIST_SAVE_NO_DUPS
setopt APPEND_HISTORY
setopt SHARE_HISTORY
setopt AUTO_CD
setopt CORRECT
setopt EXTENDED_GLOB

# Enhanced completion system
autoload -Uz compinit; compinit
autoload -Uz bashcompinit; bashcompinit

# Completion settings
zstyle ':completion:*' rehash true

# Docker completion optimization
zstyle ':completion:*:*:docker:*' option-stacking yes
zstyle ':completion:*:*:docker-*:*' option-stacking yes

# NVM configuration
export NVM_DIR="$HOME/.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

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

# Source zsh-specific aliases if they exist
if [ -f ~/.dotfiles/zsh/.zsh_aliases ]; then
    source ~/.dotfiles/zsh/.zsh_aliases
fi

