diff options
| author | Blista Kanjo | 2023-08-02 22:22:54 -0400 |
|---|---|---|
| committer | Blista Kanjo | 2023-08-02 22:22:54 -0400 |
| commit | 7e72e9ac87fc1c052726202f84a1e16466e06ad4 (patch) | |
| tree | eb35478ad142aa154d80d85aa583500c5eab65b8 /.config/shell/zsh-fast-syntax-highlighting/:chroma/-hub.ch | |
| parent | 08e564a8e1d4c13ad4c046ca4bfc9ca7f72373bd (diff) | |
feat: `zsh` fast-syntax-highlighting plugin
Diffstat (limited to '.config/shell/zsh-fast-syntax-highlighting/:chroma/-hub.ch')
| -rw-r--r-- | .config/shell/zsh-fast-syntax-highlighting/:chroma/-hub.ch | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/.config/shell/zsh-fast-syntax-highlighting/:chroma/-hub.ch b/.config/shell/zsh-fast-syntax-highlighting/:chroma/-hub.ch new file mode 100644 index 0000000..466d2e5 --- /dev/null +++ b/.config/shell/zsh-fast-syntax-highlighting/:chroma/-hub.ch @@ -0,0 +1,51 @@ +# vim:ft=zsh:et:sw=4 +(( next_word = 2 | 8192 )) +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" + +if (( __first_call )); then + chroma/-git.ch $* + return 1 +fi +[[ "$__arg_type" = 3 ]] && return 2 + +if (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 +fi + +if [[ "$__wrd" != -* ]] && (( FAST_HIGHLIGHT[chroma-git-got-subcommand] == 0 )); then + -fast-run-command "git config --get-regexp 'alias.*'" chroma-git-alias-list "" $(( 5 * 60 )) + # Grep for line: alias.{user-entered-subcmd}[[:space:]], and remove alias. prefix + __lines_list=( ${${(M)__lines_list[@]:#alias.${__wrd}[[:space:]]##*}#alias.} ) + + if (( ${#__lines_list} > 0 )); then + # (*) + # First remove alias name (#*[[:space:]]) and the space after it, then + # remove any leading spaces from what's left (##[[:space:]]##), then + # remove everything except the first word that's in the left line + # (%%[[:space:]]##*, i.e.: "everything from right side up to any space") + FAST_HIGHLIGHT[chroma-git-subcommand]="${${${__lines_list[1]#*[[:space:]]}##[[:space:]]##}%%[[:space:]]##*}" + else + FAST_HIGHLIGHT[chroma-git-subcommand]="$__wrd" + fi + if [[ "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "browse" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "ci-status" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "compare" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "create" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "delete" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "fork" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "issue" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pr" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "pull-request" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "release" \ + || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "sync" ]]; then + FAST_HIGHLIGHT[chroma-git-got-subcommand]=1 + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}") + (( FAST_HIGHLIGHT[chroma-git-counter] += 1 )) + (( this_word = next_word )) + _start_pos=$4 + return 0 + fi +fi + +chroma/-git.ch $* |
