# {{{ Reminders to install useful extensions
#if [[ -e /usr/share/zsh/plugins/zsh-directory-history/zsh-directory-history.zsh ]]; then
    #. /usr/share/zsh/plugins/zsh-directory-history/zsh-directory-history.zsh
#elif [[ -x "$(whence yay)" ]]; then
    #echo 'yay -S zsh-directory-history-git'
#fi
if [[ -e /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
    . /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
elif [[ -e /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
    . /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
elif [[ -x "$(whence yay)" ]]; then
    echo 'yay -S zsh-autosuggestions'
elif [[ -x "$(whence zyp)" ]]; then
    echo 'zyp in zsh-autosuggestions'
else
    echo "zsh-autosuggestions not found"
fi
if [[ -e /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
    . /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
elif [[ -e /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
    . /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
elif [[ -x "$(whence yay)" ]]; then
    echo 'yay -S zsh-syntax-highlighting'
elif [[ -x "$(whence apt)" ]]; then
    echo 'sudo apt install zsh-syntax-highlighting'
elif [[ -x "$(whence zyp)" ]]; then
    echo 'zyp in zsh-syntax-highlighting'
else
    echo "zsh-syntax-highlighting not found"
fi
if [[ -e /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh ]]; then
    . /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
elif [[ -e /usr/share/zsh-history-substring-search/zsh-history-substring-search.zsh ]]; then
    . /usr/share/zsh-history-substring-search/zsh-history-substring-search.zsh
elif [[ -x "$(whence yay)" ]]; then
    echo 'yay -S zsh-history-substring-search'
elif [[ -x "$(whence zyp)" ]]; then
    echo 'zyp in zsh-history-substring-search'
else
    echo "zsh-history-substring-search not found"
fi
if [[ -x "$(whence direnv)" ]]; then
    eval "$(direnv hook zsh)"
elif [[ -x "$(whence pacman)" ]]; then
    echo 'pacman -S direnv'
else
    echo "direnv tool not found"
fi
# }}}

zmodload -i zsh/complist
autoload -U compaudit compinit && compinit

unsetopt flowcontrol

unsetopt menucomplete
setopt list_ambiguous
setopt complete_in_word
setopt glob_complete
unsetopt complete_aliases
setopt always_to_end
setopt auto_param_slash
setopt interactivecomments
setopt no_nomatch
setopt no_nullglob
setopt no_listbeep

bindkey -M menuselect '^o' accept-and-infer-next-history
zle -C all-matches complete-word _generic
bindkey '^Xa' all-matches
zstyle ':completion:*' menu select=2
zstyle ':completion:*' verbose yes
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' list-colors ''
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path "$HOME/.cache/zsh/completion/"
zstyle ':completion:all-matches:*' old-matches only
zstyle ':completion:all-matches::::' completer _all_matches

zstyle ':completion:*:*:*:users' ignored-patterns \
        adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
        clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
        gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
        ldap lp mail mailman mailnull man messagebus  mldonkey mysql nagios \
        named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
        operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
        rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
        usbmux uucp vcsa wwwrun xfs '_*'
zstyle '*' single-ignored show

source $HOME/.sh_aliases
source $HOME/.sh_paths
source $HOME/.sh_functions
source $HOME/.sh_colorize
source $HOME/.zsh_aliases
source $HOME/.zsh-vi-mode/zsh-vi-mode.plugin.zsh

# correct_all is stupid and whoever thought it was a good idea to set it is stupid.
setopt correct nocorrect_all

if [ -z "$HISTFILE" ]; then
    HISTFILE=$HOME/.zsh_history
fi
HISTSIZE=30000
SAVEHIST=100000
setopt append_history
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_verify
setopt inc_append_history
setopt share_history
setopt extendedglob notify
bindkey '[3~' delete-char

if [ -f ~/.profile ]; then
	source ~/.profile
fi

autoload -Uz vcs_info

zstyle ':vcs_info:*' stagedstr '%F{28}●'
zstyle ':vcs_info:*' unstagedstr '%F{11}●'
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{11}%r'
zstyle ':vcs_info:*' enable git svn cvs darcs hg
zstyle ':vcs_info:*' disable bzr


if [[ -e NEXT_TO_RUN ]]
then
    cat NEXT_TO_RUN
fi
export PATH=$PATH:/sbin/
export PATH=$PATH:$HOME/.spicetify:$HOME/.cargo/bin:/usr/local/texlive/2022/bin/x86_64-linux
export PATH=$PATH:$HOME/.local/share/flutter/bin
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH=$PATH:/opt/gradle/gradle-6.9.4/bin
export TERMINAL=kitty
export MPD_HOST=127.0.0.1
export MPD_PORT=6969
export EDITOR="emacsclient -nc --alternate-editor="""

function reload_gtk_theme() {
  theme=$(gsettings get org.gnome.desktop.interface gtk-theme)
  gsettings set org.gnome.desktop.interface gtk-theme ''
  sleep 1
  gsettings set org.gnome.desktop.interface gtk-theme $theme
}
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
###-begin-flutter-completion-###

if type complete &>/dev/null; then
  __flutter_completion() {
    local si="$IFS"
    IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
                           COMP_LINE="$COMP_LINE" \
                           COMP_POINT="$COMP_POINT" \
                           flutter completion -- "${COMP_WORDS[@]}" \
                           2>/dev/null)) || return $?
    IFS="$si"
  }
  complete -F __flutter_completion flutter
elif type compdef &>/dev/null; then
  __flutter_completion() {
    si=$IFS
    compadd -- $(COMP_CWORD=$((CURRENT-1)) \
                 COMP_LINE=$BUFFER \
                 COMP_POINT=0 \
                 flutter completion -- "${words[@]}" \
                 2>/dev/null)
    IFS=$si
  }
  compdef __flutter_completion flutter
elif type compctl &>/dev/null; then
  __flutter_completion() {
    local cword line point words si
    read -Ac words
    read -cn cword
    let cword-=1
    read -l line
    read -ln point
    si="$IFS"
    IFS=$'\n' reply=($(COMP_CWORD="$cword" \
                       COMP_LINE="$line" \
                       COMP_POINT="$point" \
                       flutter completion -- "${words[@]}" \
                       2>/dev/null)) || return $?
    IFS="$si"
  }
  compctl -K __flutter_completion flutter
fi

###-end-flutter-completion-###

## Generated 2023-02-10 19:53:12.722758Z
## By /home/libkyy/.local/share/flutter/bin/cache/flutter_tools.snapshot
#anaconda slows shit down D:<<<<
export PATH=$PATH:~/.spicetify
export PATH=$PATH:$HOME/.spicetify
export PATH=$PATH:$HOME/.emacs.d/bin
export PATH=$PATH:$HOME/.config/emacs/bin
export PATH=$PATH:$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/
export PATH=$PATH:/home/linly/.spicetify

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/linly/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/linly/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/linly/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/linly/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<


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