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/-node.ch | |
| parent | 08e564a8e1d4c13ad4c046ca4bfc9ca7f72373bd (diff) | |
feat: `zsh` fast-syntax-highlighting plugin
Diffstat (limited to '.config/shell/zsh-fast-syntax-highlighting/:chroma/-node.ch')
| -rw-r--r-- | .config/shell/zsh-fast-syntax-highlighting/:chroma/-node.ch | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/.config/shell/zsh-fast-syntax-highlighting/:chroma/-node.ch b/.config/shell/zsh-fast-syntax-highlighting/:chroma/-node.ch new file mode 100644 index 0000000..65f214c --- /dev/null +++ b/.config/shell/zsh-fast-syntax-highlighting/:chroma/-node.ch @@ -0,0 +1,37 @@ +# vim:ft=zsh:et:sw=4 +(( next_word = 2 | 8192 )) +[[ "$__arg_type" = 3 ]] && return 2 + +local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" +local __style + +if (( __first_call )); then + FAST_HIGHLIGHT[chroma-node-file]=1 +elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then + return 1 +elif [[ "$__wrd" = -- ]]; then + FAST_HIGHLIGHT[chroma-node-file]=2 +elif (( FAST_HIGHLIGHT[chroma-node-file] != 2 )) && [[ "$__wrd" = -* ]]; then + if [[ "$__wrd" = -*e* || "$__wrd" = --eval ]]; then + FAST_HIGHLIGHT[chroma-node-file]=0 + fi +elif (( FAST_HIGHLIGHT[chroma-node-file] )); then + if [[ "$__wrd" = debug || "$__wrd" = inspect ]]; then + __style=${FAST_THEME_NAME}subcommand + else + FAST_HIGHLIGHT[chroma-node-file]=0 + if [[ -f ${~__wrd} || -f ${~__wrd}.js || -f ${~__wrd}/index.js ]]; then + __style=${FAST_THEME_NAME}path + else + __style=${FAST_THEME_NAME}incorrect-subtle + fi + fi + (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \ + && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[$__style]}") + (( this_word = next_word )) + _start_pos=$_end_pos + + return 0 +fi + +return 1 |
