# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=tree-sitter-typescript
pkgver=0.20.6
pkgrel=0
pkgdesc="TypeScript grammar for tree-sitter"
url="https://github.com/tree-sitter/tree-sitter-typescript"
arch="all"
license="MIT"
makedepends="tree-sitter-dev"
provides="tree-sitter-tsx=$pkgver-r$pkgrel"
install_if="tree-sitter-grammars"
source="https://github.com/tree-sitter/tree-sitter-typescript/archive/v$pkgver/tree-sitter-typescript-$pkgver.tar.gz"
options="!check"  # no tests for shared lib

_langs='tsx typescript'

build() {
	local lang; for lang in $_langs; do
		abuild-tree-sitter build -s "$lang/src"
	done
}

package() {
	local querydir="$pkgdir/usr/share/tree-sitter/queries"

	local lang; for lang in $_langs; do
		DESTDIR="$pkgdir" abuild-tree-sitter install -s "$lang/src"
	done

	rm "$querydir"/tsx/*
	echo '; inherits: typescript' > "$querydir"/tsx/highlights.scm
	echo '; inherits: typescript' > "$querydir"/tsx/injections.scm
}

sha512sums="
f30f38aa269302eee5f738422626187111c14c7ba07982d619b200a58a20a08849f8a0e79358cad331d689afd5ab389a88b246bda30031ae354f93433e85b763  tree-sitter-typescript-0.20.6.tar.gz
"
