#compdef gwm
# gwm zsh completion script
# Generated by gwm completion
#
# Installation:
#   gwm completion install --shell zsh
#
# Manual installation:
#   Copy this file to ~/.zsh/completions/_gwm
#   Ensure your fpath includes ~/.zsh/completions
#   Add the following to your ~/.zshrc (before compinit):
#     fpath=(~/.zsh/completions $fpath)
#   Then run:
#     autoload -Uz compinit && compinit

_gwm() {
  local curcontext="$curcontext" state line
  typeset -A opt_args

  # 現在のワード位置を計算（gwm 自体を除く）
  local words_without_cmd=("${words[@]:1}")
  local cword=$((CURRENT - 1))

  # gwm completion __complete を呼び出し
  local candidates
  candidates=$(gwm completion __complete --shell zsh --cword "$cword" -- "${words_without_cmd[@]}" 2>/dev/null)

  if [[ -n "$candidates" ]]; then
    local -a completions
    while IFS=$'\t' read -r value desc; do
      if [[ -n "$desc" ]]; then
        completions+=("${value}:${desc}")
      else
        completions+=("$value")
      fi
    done <<< "$candidates"
    _describe 'gwm' completions
  fi
}

_gwm "$@"
