Subject: [bug#49946] [PATCH v6 17/27] gnu: Add tree-sitter-ocaml.

From: Pierre Langlois <[email-masked]>
Date: Sun, 15 May 2022 19:38:24 +0100

* gnu/packages/tree-sitter.scm (tree-sitter-ocaml): New variable.
---
 gnu/packages/tree-sitter.scm | 39 ++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index a535d8bc4a..ff98044cc1 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -458,3 +458,42 @@ (define-public tree-sitter-julia
     (description
      "This package provides a Julia grammar for the Tree-sitter library.")
     (license license:expat)))
+
+(define-public tree-sitter-ocaml
+  (let ((commit "0348562f385bc2bd67ecf181425e1afd6d454192")
+        (revision "1"))
+    (package
+      (name "tree-sitter-ocaml")
+      (version (git-version "0.19.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/tree-sitter/tree-sitter-ocaml")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0iqmwcz3c2ai4gyx4xli1rhn6hi6a0f60dn20f8jas9ham9dc2df"))
+                (modules '((guix build utils)))
+                (snippet
+                 '(begin
+                    (delete-file "binding.gyp")
+                    (delete-file-recursively "bindings")
+                    (for-each
+                     (lambda (lang)
+                       (with-directory-excursion lang
+                         (delete-file "src/grammar.json")
+                         (delete-file "src/node-types.json")
+                         (delete-file "src/parser.c")
+                         (delete-file-recursively "src/tree_sitter")))
+                     '("ocaml" "interface"))
+                    #t))))
+      (build-system tree-sitter-build-system)
+      (arguments
+       (list
+        #:grammar-directories '("ocaml" "interface")))
+      (home-page "https://github.com/tree-sitter/tree-sitter-ocaml")
+      (synopsis "Tree-sitter OCaml grammar")
+      (description
+       "This package provides a OCaml grammar for the Tree-sitter library.")
+      (license license:expat))))
--
2.36.0