aboutsummaryrefslogtreecommitdiff
path: root/.config/shell/zsh-fast-syntax-highlighting/→chroma/-fast-theme.ch
blob: 15bc210863e5554378145fbd48a3035ef96fc4ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# vim:ft=zsh:et:sw=4
(( next_word = 2 | 8192 ))
[[ "$__arg_type" = 3 ]] && return 2

local __first_call="$1" __wrd="${(Q)2}" __start_pos="$3" __end_pos="$4"
local __style

if (( __first_call )); then
    FAST_HIGHLIGHT[chroma-fast-theme-first]=0
    return 1
elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
        return 1
elif (( ${FAST_HIGHLIGHT[chroma-fast-theme-first]} )) || [[ $__wrd = -* ]]; then
    return 1
else
    FAST_HIGHLIGHT[chroma-fast-theme-first]=1
fi

if [[ "$__wrd" = */* || "$__wrd" = (XDG|LOCAL|HOME|OPT):* ]]; then
    __wrd="${${__wrd/(#s)XDG:/${${XDG_CONFIG_HOME:-$HOME/.config}%/}/fsh/}%.ini}.ini"
    __wrd="${${__wrd/(#s)LOCAL://usr/local/share/fsh/}%.ini}.ini"
    __wrd="${${__wrd/(#s)HOME:/$HOME/.fsh/}%.ini}.ini"
    __wrd="${${__wrd/(#s)OPT://opt/local/share/fsh/}%.ini}.ini"
    __wrd=${~__wrd} # allow user to quote ~
else
    __wrd="$FAST_BASE_DIR/themes/$__wrd.ini"
fi

if [[ -f $__wrd ]]; then
    __style=${FAST_THEME_NAME}path
else
    __style=${FAST_THEME_NAME}incorrect-subtle
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