@@ -725,3 +725,84 @@ (define-public emacs-tree-sitter
@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.11.1")
+ (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
+ "0r3yw25czg1vcxk9015yd8p1n0z427z2l4hizfjy8w8jjjg7cxxf"))))
+ (build-system emacs-build-system)
+ ;; FIXME: Support for some languages, such as ruby, is still missing from
+ ;; the bundle.
+ (inputs
+ (list tree-sitter-bash
+ tree-sitter-c
+ tree-sitter-cpp
+ tree-sitter-css
+ tree-sitter-go
+ tree-sitter-html
+ tree-sitter-java
+ tree-sitter-javascript
+ tree-sitter-json
+ tree-sitter-julia
+ tree-sitter-php
+ tree-sitter-python
+ tree-sitter-rust
+ tree-sitter-typescript))
+ (propagated-inputs
+ (list 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"))))
+ (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)))
+
+ (define (install-lib lang)
+ (let ((input (assoc-ref inputs (string-append "tree-sitter-" lang))))
+ (symlink (string-append input "/lib/tree-sitter/" lang ".so")
+ (string-append elpa "/bin/" lang ".so"))))
+ (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)))