[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting tree-sitter grammars in Guix

From: Demis Balbach
Subject: Getting tree-sitter grammars in Guix
Date: Tue, 10 Jan 2023 18:29:04 +0100

Hello, I was wondering what the "correct" way would be to get grammars
for the tree-sitter library available in Guix when using tree-sitter
with Emacs 29+.

There is, but I
don't think it has been packaged in Guix yet. I started packaging the
grammar for JS/TS:

--8<---------------cut here---------------start------------->8---
(define-public tree-sitter-javascript
  (let ((commit "7a29d06274b7cf87d643212a433d970b73969016")
        (revision "0")
        (version "0.20.0"))
     (name "tree-sitter-javascript")
     (version (git-version version revision commit))
       (method git-fetch)
       (uri (git-reference
             (url "";)
             (commit commit)))
        (base32 "1pk6d9g6a7bzhxmwnvfiycarcgz76wq2rgfqr0xjh7y7swfw5hvw"))
       (file-name (git-file-name name version))))
     (build-system gnu-build-system)
      (list gcc))
         (delete 'configure)
         (delete 'install)
         (delete 'build)
         (add-after 'unpack 'create-dirs
                    (lambda _ (mkdir "lib")))
         (add-after 'create-dirs 'compile
                    (lambda* (#:key inputs outputs #:allow-other-keys)
                      (let* ((out (assoc-ref outputs "out"))
                             (gcc (string-append (assoc-ref inputs "gcc") 
                        (copy-file "grammar.js" "src/grammar.js")
                         (string-append "./src")
                         (invoke (string-append gcc "/gcc") "-fPIC" "-c" "-I." 
                         (invoke (string-append gcc "/gcc") "-fPIC" "-c" "-I." 
                         (invoke (string-append gcc "/gcc")
                                 "-fPIC" "-shared" "parser.o" "scanner.o" "-o"
         (add-after 'compile 'symlink
                    (lambda* (#:key inputs outputs #:allow-other-keys)
                      (let* ((out (assoc-ref outputs "out"))
                             (lib (string-append out "/lib")))
                        (install-file "src/" 
      (home-page "";)
     (synopsis "JavaScript and JSX grammar for tree-sitter.")
     (description "JavaScript and JSX grammar for tree-sitter.")
     (license license:expat))))
--8<---------------cut here---------------end--------------->8---

But I'm not sure if packaging each grammar is the correct way. I
hesitate to continue working on this because there are not other
grammars packaged in Guix (yet). With tree-sitter being built into Emacs
29+ I expected grammars to be packaged already (hence why I'm asking if
this approach is correct).

Thanks in advance!

Best regards / Mit freundlichen Grüßen,
Demis Balbach

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]