
# enable completion features
# vim: ft=zsh
fpath=(~/.zfunc $fpath)
zmodload zsh/complist
setopt menucomplete
autoload -Uz compinit
compinit -d ~/.cache/zsh/.zcompdump

zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path "${HOME}/.cache/zsh/.zcompcache"
zstyle ':completion:*' menu select
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*' rehash true
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
zstyle ':completion:*:*:extract:*' file-patterns '*.tar* *.lzma *.bz2 *.zip *.7z'
zstyle ':completion:*' complete-options true
zstyle ':completion:*' squeeze-slashes true

zstyle ':completion:*:match:*' original only
zstyle ':completion:*:*:(eza|ls):*' file-sort modification

zstyle ':completion:*' completer _expand _complete _ignored _prefix _list

zstyle ':completion:*:correct:*' completer _correct
zstyle ':completion:*:approximate:*' completer _approximate
zstyle ':completion:*:correct:*' max-errors 1
zstyle ':completion:*:approximate:*' max-errors 1 numeric


zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'

zstyle ':completion:*' squeeze-slashes true

zstyle ':completion:*:cd:*' ignore-parents parent pwd

zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'



bindkey -M menuselect '^h' vi-backward-char
bindkey -M menuselect '^k' vi-up-line-or-history
bindkey -M menuselect '^j' vi-down-line-or-history
bindkey -M menuselect '^l' vi-forward-char
bindkey -M menuselect '^e' undo
bindkey -M menuselect '^[' accept
bindkey -M menuselect '^M' check-command
bindkey -M menuselect '^I' accept-and-infer-next-history
bindkey '^l' menu-select

setopt AUTO_PARAM_SLASH
setopt COMPLETE_IN_WORD
unsetopt menucomplete


compdef _directories mcd


_gcim_completion() {
  local -a commit_types

  commit_types=(
    'fix:Fix errors'
    'feat:New features'
    'chore:Routine chore'
    'docs:Documentation changes'
    'style:Code style'
    'refactor:Refactoring'
    'perf:Performance improvements'
    'test:Add tests'
    'revert:Revert changes'
    'ci:CI/CD changes'
    'build:Build system changes'
  )
  _describe 'commit message type in format CT1: "type(optional-scope): description"' commit_types -S ''
}

function _gcim() {
    noglob git cim "${*}"
}
compdef _gcim_completion _gcim

alias gcim='noglob _gcim'
