You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.3 KiB

  1. # vim:ft=zsh:et:sw=4
  2. (( next_word = 2 | 8192 ))
  3. local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4"
  4. if (( __first_call )); then
  5. chroma/-git.ch $*
  6. return 1
  7. fi
  8. [[ "$__arg_type" = 3 ]] && return 2
  9. if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
  10. return 1
  11. fi
  12. if [[ "$__wrd" != -* ]] && (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then
  13. .fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 5 * 60 ))
  14. # Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix
  15. __lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} )
  16. if (( ${#__lines_list} > 0 )); then
  17. # (*)
  18. # First remove alias name (#*[[:space:]]) and the space after it, then
  19. # remove any leading spaces from what's left (##[[:space:]]##), then
  20. # remove everything except the first word that's in the left line
  21. # (%%[[:space:]]##*, i.e.: "everything from right side up to any space")
  22. FAST_HIGHLIGHT[chroma-git-subcommand]="${${${__lines_list[1]#*[[:space:]]}##[[:space:]]##}%%[[:space:]]##*}"
  23. else
  24. FAST_HIGHLIGHT[chroma-git-subcommand]="$__wrd"
  25. fi
  26. if [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "browse" \
  27. || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "ci-status" \
  28. || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "compare" \
  29. || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "create" \
  30. || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "delete" \
  31. || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fork" \
  32. || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "issue" \
  33. || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pr" \
  34. || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pull-request" \
  35. || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "release" \
  36. || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "sync" ]]; then
  37. FAST_HIGHLIGHT[chroma-git-got-subcommand]=1
  38. (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \
  39. && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}")
  40. (( FAST_HIGHLIGHT[chroma-git-counter] += 1 ))
  41. (( this_word = next_word ))
  42. _start_pos=$4
  43. return 0
  44. fi
  45. fi
  46. chroma/-git.ch $*