# vim: syntax=zsh

function prompt_matir_setup {
  autoload -Uz add-zsh-hook
  autoload -Uz vcs_info
  autoload -Uz colors

  prompt_opts=(sp subst cr percent)

  colors

  add-zsh-hook precmd prompt_matir_precmd

  # Git related styles
  zstyle ':vcs_info:*' enable git
  zstyle ':vcs_info:*' check-for-changes true
  zstyle ':vcs_info:*' formats ' (%b%u%c)'
  zstyle ':vcs_info:*' stagedstr '*'
  zstyle ':vcs_info:*' unstagedstr '*'

  # Virtualenv formatting
  zstyle ':prezto:module:python:info:virtualenv' format ' (py:%v)'

  PROMPT='%{$fg[black]%}[%{$fg[yellow]%}%h%{$fg[black]%}] '  # History #
  PROMPT+='%{%(!.$fg[red].$fg[green])%}%8>..>%n%>>%{$fg[white]%}@'  # username@
  PROMPT+='%{$fg[blue]%}%12>..>%m%>>%{$fg[white]%}:'  # hostname
  PROMPT+='%{$fg[green]%}%32<...<%~%<<'  # path
  PROMPT+='%{$fg[magenta]%}${python_info[virtualenv]}'  # virtualenv
  PROMPT+='%{$fg[blue]%}${vcs_info_msg_0_}'  # VCS info
  PROMPT+='%{$fg[white]%}%#%{$reset_color%} '  # prompt symbol

  # Editor options
  zstyle ':prezto:module:editor:info:keymap:primary' format ''
  zstyle ':prezto:module:editor:info:keymap:primary:insert' format 'I'
  zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format 'O'
  zstyle ':prezto:module:editor:info:keymap:alternate' format ' [VICMD]'
  zstyle ':prezto:module:editor:info:completing' format '...'

  # Rprompt setup
  local show_return="✘ "
  # Default is to show the return value
  if zstyle -T ':prezto:module:prompt' show-return-val; then
    show_return+='%? '
  fi
  RPROMPT='%(?:: %{$fg[red]%}'
  RPROMPT+=${show_return}
  RPROMPT+='%{$reset_color%})'
  RPROMPT+='${editor_info[keymap]}'
}

function prompt_matir_precmd {
  vcs_info
  python-info
}

prompt_matir_setup "$@"
