From patchwork Fri Feb 18 14:39:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Langlois X-Patchwork-Id: 37339 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7350C27BBEA; Fri, 18 Feb 2022 14:51:16 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id DC70927BBE9 for ; Fri, 18 Feb 2022 14:51:15 +0000 (GMT) Received: from localhost ([::1]:45126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nL4bL-0007uf-1Z for patchwork@mira.cbaines.net; Fri, 18 Feb 2022 09:51:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nL4WK-0002I0-GR for guix-patches@gnu.org; Fri, 18 Feb 2022 09:46:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:59970) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nL4WK-0006RB-3l for guix-patches@gnu.org; Fri, 18 Feb 2022 09:46:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nL4WK-0000F7-2e for guix-patches@gnu.org; Fri, 18 Feb 2022 09:46:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH v4 31/31] gnu: Add emacs-tree-sitter-langs. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 18 Feb 2022 14:46:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49946 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49946@debbugs.gnu.org Cc: Pierre Langlois Received: via spool by 49946-submit@debbugs.gnu.org id=B49946.1645195517820 (code B ref 49946); Fri, 18 Feb 2022 14:46:04 +0000 Received: (at 49946) by debbugs.gnu.org; 18 Feb 2022 14:45:17 +0000 Received: from localhost ([127.0.0.1]:53861 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nL4VY-0000D5-SC for submit@debbugs.gnu.org; Fri, 18 Feb 2022 09:45:17 -0500 Received: from mout.gmx.net ([212.227.17.21]:37907) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nL4VS-0000Ba-9A for 49946@debbugs.gnu.org; Fri, 18 Feb 2022 09:45:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1645195504; bh=KQKtk/Htaalubl8Qbew8r1AMYScY44rvz5nDNhyGK70=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ErTac/D165TjUudgHhD33mLhCE7OwFwBFBhqw+PbRZkTpP/hzZTloxQ1Bm//IjE2N w1obXrMw7LdrMnTEdVZIQTFgJ/8I1mELNN1FTU2e7uXJpBEC6t2gUlIAtloD1zEENR VoVsOPeBf3YLWeMpryectZH0/azBYXuvTzahexhY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([82.69.64.142]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MeCtj-1nsCJw34y7-00bH8E; Fri, 18 Feb 2022 15:40:03 +0100 From: Pierre Langlois Date: Fri, 18 Feb 2022 14:39:48 +0000 Message-Id: <20220218143948.28989-31-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220218143948.28989-1-pierre.langlois@gmx.com> References: <877d9s2qa9.fsf@gmx.com> <20220218143948.28989-1-pierre.langlois@gmx.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:gfPn5D495JujHjxoOvXFmlgEwmkgp2xmT7B2kilVOS7G96lQJua lqADVp3VxDCRuj31rqszRskRjNFpnZDDcSKuphHvIleXA0mZp8B4aUu3kMPsQiCsQVohCoh omysZKQsGufNbogJNioAaQMjlmoTMnQ+4hm6/QuIoLH5xhoJI0VMmZB7kDFYZKr4cTrL5CP J7lxialsEZzVNj3fCg++Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:8FKs1noL39Y=:SHgy61yQIvoYdCCSVpq4Ri HlmNuZY5HGN3cYk6quPbSeSn7IVQZkO4hGqq4as27hSdqjKsQBGo5wPRVkpG3yswqy97LIRGc sJ7hxJIqFWphHq3jvTUVFesPuUq6CTnNryUDO++h800puv+AB+TCcQm6MZYrVSMmqSg+NLV4W zjr+J6teJbqSyaHrheZnAXnJRLDAcYZfLveLqzY3g1CaYIHwq7ODh2pjhQzKVae5h9dK1KuFQ 6liN+0TRu7FmDlSOvare9GvNu7D9EwEYs/ymzAUjNFbhI0lUKk4QODzRU1vYZUkjEvwjG14g/ ZcrB1o0Z4np7GoGP1Fct+U9DMOzOouSzfWut0SzmqnJsV3VyNEhmC2vCmfMvSlbXcVrT8nDyY Vkfk/+TZryHmT58qBgl+vckw42SK0BUVfYARljSF0pLrGTlxLc2fO07vENBCwK0iHgvwec0W9 AleAVaBdhZLQvkIcjQ4r70WTd7HsxdZ+x9Yf39dnnb3e1jehs1GxRg/TeXN4W5/+zS1oGqupE adxwiGbg9DZTL+ETzURmBUB2m6kfJnzvrCSCw1F1gERTrAHUPhDVKGpPOaHES3eDxcPGdgcfj LgplbgjJrTsI2A2Ul0gkw5iS7131zoYnRyDDkgfiFn6aQsm4ghwxzXUnpz56jZPahUYnZH/UO bWJOC3HLlniefzBp03EF8CcvrfSfitqx5rcYuuKGrRZaz/ytf13GXnDSSi+xhEbaUZf0G3xp3 v9CySP7/uef6zpR7rWwio9nuZXMiYGebqRswWroq6z6Cbzu8zOmzmpUgDQ8HPIs/jEmkptnmM xvJ7Q2DyrCuYJV0BYTTfW3eisPjiyO93xhryZz1i13i9OXGnWgY5zKksAj7dGgOQYZKFL13GX ourH5T80FGIBX+NY3psq3/rn4WSPBYodRF4KepqfVFbTSzVfnX8Xz83Qv7iCcCfvmsJj+VPor xjOYX5hDacqflTz8JGsLn848nNtfG/ayCalvDVnVmJ7Z7b13WnfIdWyMy4wwtxBjgodidJYsH z+vSW5eZNFAbF6rV9T7S4SkSUuMn6O+sV0ZBEurwPSGmC17Po307Rc666L2axKthedSqdUk1o 7WyekP3tTbGM2A= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/tree-sitter.scm (tree-sitter-langs-grammar-bundle, emacs-tree-sitter-langs): New variables. --- gnu/packages/tree-sitter.scm | 136 +++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) -- 2.34.0 diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index 9a427bed7f..d1341a2ddd 100644 --- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -23,6 +23,7 @@ (define-module (gnu packages tree-sitter) #:use-module (guix build-system emacs) #:use-module (guix build-system gnu) #:use-module (guix build-system node) + #:use-module (guix build-system trivial) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix packages) @@ -950,3 +951,138 @@ (define-public emacs-tree-sitter @item More informative indexing for imenu. @end enumerate") (license license:expat))) + +(define tree-sitter-langs-grammar-bundle + (package + (name "tree-sitter-langs-grammar-bundle") + (source #f) + (version "0.11.3") + (build-system trivial-build-system) + (inputs + ;; FIXME: Support for some languages is still left to package. + (list tree-sitter-bash + tree-sitter-c + tree-sitter-c-sharp + tree-sitter-cpp + tree-sitter-css + tree-sitter-elixir + tree-sitter-elm + tree-sitter-go + tree-sitter-html + tree-sitter-java + tree-sitter-javascript + tree-sitter-json + tree-sitter-julia + tree-sitter-ocaml + tree-sitter-php + tree-sitter-python + tree-sitter-rust + tree-sitter-ruby + tree-sitter-typescript)) + (arguments + (list #:builder + (with-imported-modules '((guix build union) + (guix build utils)) + #~(begin + (use-modules (ice-9 match) + (guix build union) + (guix build utils)) + (union-build + #$output + (filter directory-exists? + (map (match-lambda + ((name directory) + (string-append directory "/lib/tree-sitter"))) + '#$(package-inputs this-package)))) + ;; The BUNDLE-VERSION file prevents emacs-tree-sitter-langs + ;; from downloading libraries at load time. + (call-with-output-file (string-append #$output "/BUNDLE-VERSION") + (lambda (port) (display #$version port))))))) + (synopsis #f) + (description #f) + (home-page #f) + (license #f))) + +(define-public emacs-tree-sitter-langs + (package + (name "emacs-tree-sitter-langs") + (version "0.11.3") + (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 + "1sgpsjd3037pbvwk7lgw70gb4j0fyqikv4lwxwa6l5dwnqvqxgq6")))) + (build-system emacs-build-system) + (inputs + (list tree-sitter-langs-grammar-bundle)) + (propagated-inputs + (list emacs-tree-sitter)) + (arguments + (list + #:tests? #t + #:test-command ''("script/test") + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'remove-cask + (lambda _ + (substitute* "script/test" + (("cask") "")))) + (add-before 'check 'bundle-for-testing + (lambda* (#:key inputs #:allow-other-keys) + (delete-file-recursively "bin") + (symlink #$tree-sitter-langs-grammar-bundle "bin"))) + (add-before 'check 'patch-tree-sitter-require-test + (lambda _ + (use-modules (ice-9 regex)) + ;; This test needs a git repositories with submodules for + ;; each languages in order to map all repositories. We patch + ;; the mapping function with one that invokes the tests for each + ;; packaged language. + (let ((supported-languages + (map (lambda (lib) + (match:substring + (string-match "(.*)\\.so$" (basename lib)) + 1)) + (find-files "bin" "\\.so$")))) + (substitute* "tree-sitter-langs-tests.el" + (("tree-sitter-langs--map-repos") + (call-with-output-string + (lambda (port) + (write `(lambda (fn) + (dolist (lang ',supported-languages) + (funcall fn lang))) + port)))))))) + ;; Tests for queries will fail given those languages are not + ;; packages yet. + (add-before 'check 'remove-unused-highlight-queries + (lambda _ + (delete-file-recursively "queries/hcl") + (delete-file-recursively "queries/pgn"))) + (add-before 'install 'install-bundle + (lambda _ + (let ((elpa (elpa-directory #$output))) + (mkdir-p elpa) + (symlink #$tree-sitter-langs-grammar-bundle + (string-append elpa "/bin"))))) + (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)))