Debian Codegraph @

hyprpm/hyprpm.zsh

raw symbols SCIP
1 #compdef hyprpm
2
3 _hyprpm_cmd_0scip-shell shell shell-project 0.0.0 _hyprpm_cmd_0(). () {
4 hyprpm list | awkscip-shell system . . awk. '/Plugin/{print $4}scip-shell filesystem . . `/Plugin/{print $4}`.'
5 }
6
7 _hyprpm_cmd_1scip-shell shell shell-project 0.0.0 _hyprpm_cmd_1(). () {
8 hyprpm list | awkscip-shell system . . awk. '/Repository/{print $4}scip-shell filesystem . . `/Repository/{print $4}`.' | sedscip-shell system . . sed. 's/:$//'
9 }
10
11 _hyprpmscip-shell shell shell-project 0.0.0 _hyprpm(). () {
12 local -a literals=("--no-shallow" "-n" "::=" "disable" "list" "--help" "update" "add" "--verbose" "-v" "--force" "-s" "remove" "enable" "--notify" "-h" "reload" "-f")
13
14 local -A descriptions
15 descriptions[1]="Disable shallow cloning of Hyprland sources"
16 descriptions[2]="Send a hyprland notification for important events (e.g. load fail)"
17 descriptions[4]="Unload a plugin"
18 descriptions[5]="List all installed plugins"
19 descriptions[6]="Show help menu"
20 descriptions[7]="Check and update all plugins if needed"
21 descriptions[8]="Install a new plugin repository from git"
22 descriptions[9]="Enable too much logging"
23 descriptions[10]="Enable too much logging"
24 descriptions[11]="Force an operation ignoring checks (e.g. update -f)"
25 descriptions[12]="Disable shallow cloning of Hyprland sources"
26 descriptions[13]="Remove a plugin repository"
27 descriptions[14]="Load a plugin"
28 descriptions[15]="Send a hyprland notification for important events (e.g. load fail)"
29 descriptions[16]="Show help menu"
30 descriptions[17]="Reload all plugins"
31 descriptions[18]="Force an operation ignoring checks (e.g. update -f)"
32
33 local -A literal_transitions
34 literal_transitions[1]="([1]=8 [4]=4 [5]=5 [9]=8 [10]=8 [7]=5 [8]=5 [12]=8 [6]=8 [11]=8 [13]=3 [14]=4 [16]=8 [17]=5 [18]=8)"
35 literal_transitions[2]="([13]=3 [14]=4 [4]=4 [5]=5 [17]=5 [7]=5 [8]=5)"
36 literal_transitions[6]="([3]=7)"
37 literal_transitions[7]="([2]=8 [15]=8)"
38
39 local -A match_anything_transitions
40 match_anything_transitions=([2]=2 [5]=6 [4]=5 [3]=5 [1]=2)
41
42 declare -A subword_transitions
43
44 local state=1
45 local word_index=2
46 while [[ $word_index -lt $CURRENT ]]; do
47 if [[ -v "literal_transitions[$state]" ]]; then
48 local -A state_transitions
49 eval "state_transitions=${literal_transitions[$state]}"
50
51 local word=${words[$word_index]}
52 local word_matched=0
53 for ((literal_id = 1; literal_id <= $#literals; literal_id++)); do
54 if [[ ${literals[$literal_id]} = "$word" ]]; then
55 if [[ -v "state_transitions[$literal_id]" ]]; then
56 state=${state_transitions[$literal_id]}
57 word_index=$((word_index + 1))
58 word_matched=1
59 break
60 fi
61 fi
62 done
63 if [[ $word_matched -ne 0 ]]; then
64 continue
65 fi
66 fi
67
68 if [[ -v "match_anything_transitions[$state]" ]]; then
69 state=${match_anything_transitions[$state]}
70 word_index=$((word_index + 1))
71 continue
72 fi
73
74 return 1
75 done
76
77 completions_no_description_trailing_space=()
78 completions_no_description_no_trailing_space=()
79 completions_trailing_space=()
80 suffixes_trailing_space=()
81 descriptions_trailing_space=()
82 completions_no_trailing_space=()
83 suffixes_no_trailing_space=()
84 descriptions_no_trailing_space=()
85
86 if [[ -v "literal_transitions[$state]" ]]; then
87 local -A state_transitions
88 eval "state_transitions=${literal_transitions[$state]}"
89
90 for literal_id in ${(k)state_transitions}; do
91 if [[ -v "descriptions[$literal_id]" ]]; then
92 completions_trailing_space+=("${literals[$literal_id]}")
93 suffixes_trailing_space+=("${literals[$literal_id]}")
94 descriptions_trailing_space+=("${descriptions[$literal_id]}")
95 else
96 completions_no_description_trailing_space+=("${literals[$literal_id]}")
97 fi
98 done
99 fi
100 local -A commands=([4]=0 [3]=1)
101
102 if [[ -v "commands[$state]" ]]; then
103 local command_id=${commands[$state]}
104 local output=$(_hyprpm_cmd_${command_id} "${words[$CURRENT]}")
105 local -a command_completions=("${(@f)output}")
106 for line in ${command_completions[@]}; do
107 local parts=(${(@s: :)line})
108 if [[ -v "parts[2]" ]]; then
109 completions_trailing_space+=("${parts[1]}")
110 suffixes_trailing_space+=("${parts[1]}")
111 descriptions_trailing_space+=("${parts[2]}")
112 else
113 completions_no_description_trailing_space+=("${parts[1]}")
114 fi
115 done
116 fi
117
118 local maxlen=0
119 for suffix in ${suffixes_trailing_space[@]}; do
120 if [[ ${#suffix} -gt $maxlen ]]; then
121 maxlen=${#suffix}
122 fi
123 done
124 for suffix in ${suffixes_no_trailing_space[@]}; do
125 if [[ ${#suffix} -gt $maxlen ]]; then
126 maxlen=${#suffix}
127 fi
128 done
129
130 for ((i = 1; i <= $#suffixes_trailing_space; i++)); do
131 if [[ -z ${descriptions_trailing_space[$i]} ]]; then
132 descriptions_trailing_space[$i]="${(r($maxlen)( ))${suffixes_trailing_space[$i]}}"
133 else
134 descriptions_trailing_space[$i]="${(r($maxlen)( ))${suffixes_trailing_space[$i]}} -- ${descriptions_trailing_space[$i]}"
135 fi
136 done
137
138 for ((i = 1; i <= $#suffixes_no_trailing_space; i++)); do
139 if [[ -z ${descriptions_no_trailing_space[$i]} ]]; then
140 descriptions_no_trailing_space[$i]="${(r($maxlen)( ))${suffixes_no_trailing_space[$i]}}"
141 else
142 descriptions_no_trailing_space[$i]="${(r($maxlen)( ))${suffixes_no_trailing_space[$i]}} -- ${descriptions_no_trailing_space[$i]}"
143 fi
144 done
145
146 compadd -Q -a completions_no_description_trailing_space
147 compadd -Q -S ' ' -a completions_no_description_no_trailing_space
148 compadd -l -Q -a -d descriptions_trailing_space completions_trailing_space
149 compadd -l -Q -S '' -a -d descriptions_no_trailing_space completions_no_trailing_space
150 return 0
151 }
152
153 if [[ $ZSH_EVAL_CONTEXT =~ :file$ ]]; then
154 compdef _hyprpm hyprpm
155 else
156 _hyprpmscip-shell shell shell-project 0.0.0 _hyprpm().
157 fi