(define-module (11kb packages tree-sitter)
#:use-module (guix packages)
#:use-module (guix build utils)
#:use-module ((guix utils)
#:select (substitute-keyword-arguments
ensure-keyword-arguments))
#:use-module ((guix modules)
#:select (source-module-closure))
#:use-module (guix gexp)
#:use-module (gnu packages tree-sitter)
#:use-module (ice-9 match)
#:use-module ((guix build-system tree-sitter)
#:prefix guix-ts:))
(define (package-without-tests p)
(package/inherit p
(arguments
(substitute-keyword-arguments (package-arguments p)
((#:tests? _ #f) #f)))))
;; There's a problem with the peerDependencies so we have to remove them.
(define tree-sitter-typst-broken
(package-without-tests
((@@ (gnu packages tree-sitter) tree-sitter-grammar)
"typst" "Typst"
"06a3hzmc5xa4vfpfrk77hq9j0n39jxhy450rx2qxisc06bf53zxk"
"0.12"
#:commit "46cf4ded12ee974a70bf8457263b67ad7ee0379d"
#:repository-url "https://github.com/uben0/tree-sitter-typst")))
(define-public tree-sitter-typst
(package/inherit tree-sitter-typst-broken
(arguments
(ensure-keyword-arguments
(package-arguments tree-sitter-typst-broken)
(list #:imported-modules
(cons* '(guix build node-build-system)
guix-ts:%tree-sitter-build-system-modules)
#:modules
'((guix build utils)
(guix build tree-sitter-build-system)
(ice-9 match)
(guix build node-build-system))
#:phases
#~(modify-phases %standard-phases
(add-after 'patch-dependencies 'patch-peer-dependencies
(lambda _
(modify-json
(delete-dependencies '("tree-sitter")))))))))))