@@ -635,3 +635,82 @@ Emacs packages that understand code structurally. For example:
@item More informative indexing for imenu.
@end enumerate")
(license license:expat)))
+
+(define-public emacs-tree-sitter-langs
+ (package
+ (name "emacs-tree-sitter-langs")
+ (version "0.10.2")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/emacs-tree-sitter/tree-sitter-langs")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0lym09jnlb7kvqkwkjbrqpc24fkpv99f8r9139sw8g537yj5f8rq"))))
+ (build-system emacs-build-system)
+ ;; FIXME: Support for some languages, such as bash, is still missing from
+ ;; the bundle.
+ (inputs
+ `(("tree-sitter-c" ,tree-sitter-c)
+ ("tree-sitter-cpp" ,tree-sitter-cpp)
+ ("tree-sitter-css" ,tree-sitter-css)
+ ("tree-sitter-go" ,tree-sitter-go)
+ ("tree-sitter-html" ,tree-sitter-html)
+ ("tree-sitter-java" ,tree-sitter-java)
+ ("tree-sitter-javascript" ,tree-sitter-javascript)
+ ("tree-sitter-json" ,tree-sitter-json)
+ ("tree-sitter-julia" ,tree-sitter-julia)
+ ("tree-sitter-php" ,tree-sitter-php)
+ ("tree-sitter-python" ,tree-sitter-python)
+ ("tree-sitter-rust" ,tree-sitter-rust)
+ ("tree-sitter-typescript" ,tree-sitter-typescript)))
+ (propagated-inputs
+ `(("emacs-tree-sitter" ,emacs-tree-sitter)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-before 'build 'fake-bundle
+ (lambda _
+ ;; The BUNDLE-VERSION file prevents the package from
+ ;; downloading libraries at load time.
+ (call-with-output-file "bin/BUNDLE-VERSION"
+ (lambda (port) (display ,version port)))))
+ (add-after 'install 'install-libs
+ (lambda* (#:key outputs inputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out"))))
+ (define (install-lib lang)
+ (let ((input (assoc-ref inputs (string-append "tree-sitter-" lang))))
+ (copy-file (string-append input "/lib/tree-sitter/" lang ".so")
+ (string-append elpa "/bin/" lang ".so"))))
+ (mkdir-p (string-append elpa "/bin"))
+ ;; The BUNDLE-VERSION file prevents the package from
+ ;; downloading libraries at load time.
+ (call-with-output-file (string-append elpa "/bin/BUNDLE-VERSION")
+ (lambda (port) (display ,version port)))
+ (for-each (lambda (input)
+ (use-modules (ice-9 regex))
+ (cond
+ ((string-match "^tree-sitter-(.*)$" (car input))
+ => (lambda (m)
+ (install-lib (match:substring m 1))))))
+ inputs))))
+ (add-after 'install 'install-queries
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out"))))
+ (copy-recursively "queries" (string-append elpa "/queries"))))))))
+ (home-page "https://ubolonton.github.io/emacs-tree-sitter/languages/")
+ (synopsis "Language support bundle for Tree-sitter")
+ (description "This package is a convenient language bundle for
+Tree-sitter. For each supported language, this package provides:
+
+@enumerate
+@item Pre-compiled grammar binaries.
+@item An optional highlights.scm file that provides highlighting patterns.
+This is mainly intended for major modes that are not aware of tree-sitter.
+@item Optional query patterns for other minor modes that provide high-level
+functionalities on top of tree-sitter, such as code folding, evil text
+objects, ...etc.
+@end enumerate")
+ (license license:expat)))