aboutsummaryrefslogtreecommitdiff
path: root/contrib/completion/hx.zsh
blob: 16631519bc461d04917c57df18ef146ad4baf03d (plain) (blame)
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
#compdef _hx hx
# Zsh completion script for Helix editor

_hx() {
	_arguments -C \
		"-h[Prints help information]" \
		"--help[Prints help information]" \
		"-v[Increase logging verbosity]" \
		"-vv[Increase logging verbosity]" \
		"-vvv[Increase logging verbosity]" \
		"-V[Prints version information]" \
		"--version[Prints version information]" \
		"--tutor[Loads the tutorial]" \
		"--health[Checks for errors in editor setup]:language:->health" \
		"-g[Fetches or builds tree-sitter grammars]:action:->grammar" \
		"--grammar[Fetches or builds tree-sitter grammars]:action:->grammar" \
		"*:file:_files"

	case "$state" in
	health)
		local languages=($(hx --health |tail -n '+7' |awk '{print $1}' |sed 's/\x1b\[[0-9;]*m//g'))
		_values 'language' $languages
		;;
	grammar)
		_values 'action' fetch build
		;;
	esac
}