summaryrefslogtreecommitdiff
path: root/textproc/tree-sitter-grammars/gh_tuples.sh
blob: 4d4e62cf2009bed349f849ca9c4a69a0ad84432f (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
30
31
32
33
34
35
36
#!/bin/sh

# pkg install textproc/tomlq

vers="v0.4.2+1f9f9dd"

# https://github.com/lapce/tree-sitter-grammars/blob/v0.4.2%2B1f9f9dd/src/main.rs#L92

helix_rev=$(fetch -q -o - "https://raw.githubusercontent.com/lapce/tree-sitter-grammars/refs/tags/${vers}/src/main.rs" | grep -A1 "https://github.com/helix-editor/helix"  | tail -n 1 | sed -e 's# ##g' -e 's#"##g' -e 's#,##')

echo "https://raw.githubusercontent.com/helix-editor/helix/${helix_rev}/languages.toml"
exit
fetch -q https://raw.githubusercontent.com/helix-editor/helix/${helix_rev}/languages.toml

len=$(tomlq '.grammar | length' languages.toml)
len=$(expr ${len} - 1)

for i in $(seq 0 ${len})
do
	# git source and git rev
	name=$(tomlq ".grammar[${i}].name" languages.toml | sed 's#"##g')
	src=$(tomlq ".grammar[${i}].source.git" languages.toml | sed 's#"##g')
	rev=$(tomlq ".grammar[${i}].source.rev" languages.toml | sed 's#"##g')
	subpath=$(tomlq ".grammar[${i}].source.subpath" languages.toml | sed 's#"##g')

	echo ${src} | grep -q github.com
	if [ $? -ne 0 ]; then
#		echo "XXX $src, $rev not a github repo"
		continue
	fi

	src_a=$(echo ${src} | awk -F '/' '{print $4}')
	src_b=$(echo ${src} | awk -F '/' '{print $5}')

	echo "${src_a}:${src_b}:${rev}:ts${i}/grammars/tree-sitter-${name} \\"
done