aboutsummaryrefslogtreecommitdiff
path: root/.config/shell/zsh-fast-syntax-highlighting/:chroma/-lab.ch
diff options
context:
space:
mode:
authorBlista Kanjo2023-08-02 22:22:54 -0400
committerBlista Kanjo2023-08-02 22:22:54 -0400
commit7e72e9ac87fc1c052726202f84a1e16466e06ad4 (patch)
treeeb35478ad142aa154d80d85aa583500c5eab65b8 /.config/shell/zsh-fast-syntax-highlighting/:chroma/-lab.ch
parent08e564a8e1d4c13ad4c046ca4bfc9ca7f72373bd (diff)
feat: `zsh` fast-syntax-highlighting plugin
Diffstat (limited to '.config/shell/zsh-fast-syntax-highlighting/:chroma/-lab.ch')
-rw-r--r--.config/shell/zsh-fast-syntax-highlighting/:chroma/-lab.ch59
1 files changed, 59 insertions, 0 deletions
diff --git a/.config/shell/zsh-fast-syntax-highlighting/:chroma/-lab.ch b/.config/shell/zsh-fast-syntax-highlighting/:chroma/-lab.ch
new file mode 100644
index 0000000..cf3fc95
--- /dev/null
+++ b/.config/shell/zsh-fast-syntax-highlighting/:chroma/-lab.ch
@@ -0,0 +1,59 @@
+# vim:ft=zsh:et:sw=4
+#
+# The `lab' tool after which this chroma is modeled after:
+# https://github.com/zaquestion/lab
+#
+(( 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" \
+ || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "mr" \
+ || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "project" \
+ || "${FAST_HIGHLIGHT[chroma-git-subcommand]}" = "snippet" \
+ || "${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 $*