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.

59 lines
2.7 KiB

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