From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id qNudGgdJgWJSJAAAbAwnHQ (envelope-from ) for ; Sun, 15 May 2022 20:40:07 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id cMeaGQdJgWKGCgEAG6o9tA (envelope-from ) for ; Sun, 15 May 2022 20:40:07 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F37CA28436 for ; Sun, 15 May 2022 20:40:06 +0200 (CEST) Received: from localhost ([::1]:44842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqJ9y-0003tq-0R for larch@yhetil.org; Sun, 15 May 2022 14:40:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqJ97-0001sw-R7 for guix-patches@gnu.org; Sun, 15 May 2022 14:39:13 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nqJ97-0000Ce-Gd for guix-patches@gnu.org; Sun, 15 May 2022 14:39:13 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nqJ97-0006fW-E0 for guix-patches@gnu.org; Sun, 15 May 2022 14:39:13 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH v6 27/27] gnu: Add emacs-tree-sitter-langs. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 15 May 2022 18:39:13 +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.165263994925566 (code B ref 49946); Sun, 15 May 2022 18:39:13 +0000 Received: (at 49946) by debbugs.gnu.org; 15 May 2022 18:39:09 +0000 Received: from localhost ([127.0.0.1]:50710 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nqJ92-0006e3-NJ for submit@debbugs.gnu.org; Sun, 15 May 2022 14:39:09 -0400 Received: from mout.gmx.net ([212.227.17.20]:48423) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nqJ8k-0006YD-DC for 49946@debbugs.gnu.org; Sun, 15 May 2022 14:38:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1652639924; bh=rzjUKvyN2JiF/2ShQClfYtFdkOYOOpQkYHzaM+yOqTw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=EcBfsyvTO6Fnt//3Q5FtqFwEA86RXdpB7HR+xAiv/CmJA4mxsgccSPahbGkjsLXNV OU3CtOZ9mai2eewU5DlYLgHbw4JCTCEorms2wBykSN4fIw7Q3lDo8y44Jfrc2peiOf J3wUbtlBvTRPS+uoB8lqmRYS3UielPpOppPPGlMw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MDQic-1o0nWE2GjG-00AXWO; Sun, 15 May 2022 20:38:44 +0200 From: Pierre Langlois Date: Sun, 15 May 2022 19:38:34 +0100 Message-Id: <20220515183834.18771-27-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220515183834.18771-1-pierre.langlois@gmx.com> References: <87mtfi63ut.fsf@gmx.com> <20220515183834.18771-1-pierre.langlois@gmx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:DRh/8TP3dGHfCCtrS61RCGkLTm0dYGvZf3Cq8kgL7kebeYBJy37 7MU5NdNVVyh+cPJl3h+vMjwIyyZxvxSjHn4TvqPk1HnzZ3OdUbnfHwZIlsgRxZtdQG07htu RRtzsyRuyNf+WDgJA15jPQ7jxaQgTQkOsPXmPT+Fc2QRHiNJlYzKmxcBIhfyKmKEywSPwAs tnO6/TH5pEd2i6Dv4yyxg== X-UI-Out-Filterresults: notjunk:1;V03:K0:nOUgpELOlNY=:qIM9NglQq9hk7Vwr3Nrz7T O1DgwRqOwfpOQp4TK2F7SV+4F5shZSsBURocBOKp3O4FN30AlDLiS4c0GGNBgx57GKdKNllOP Nui0J4Kk7bWE4p+SZ9CijE3KMannbjvPuqIiWiDJHW1kzNzoFSfn/1I116DUnAMK7DBCle2b2 BE72E1WAXXD9wH+k4zQ5zOpmf6lvV1iYRnKXGJ/tTe32Bjwovxc+l634bRpFK9OzhKwoS6e2j QDlSg5fhE1d7KjHzT26EMQhhVg9nZQscaGAd4zTpnH0loreLkeR+rMjVmXlA3VQjHgSCZD1uV o189ndJZHZXKjR4G2paIVgpv1ga9gY8mYDPZeF6rzcJUc14DhmkmQ9nKIO3exLJHyYM/aoGTy 6nJ74aNg0NpP/J34VHuV0wAurE2/fBCNiZ+g8P5KQ2RKwkKHyAKuFRa3ej6NWMBDyj2V1S5TS RM/+GOYyUAEZ6byAd4oQiavP53wxw9p/Nk4NOH8us4pcxlJJ7DGOj7hjOmbxnmK4VRp4cy9bx DiJf/ahNrXAifiTyS/SZ6gGhJwOhyzxOEv822Fnn6OeoJ/K1w1igsHlxA2cZMUwF4r98ztUJ2 /hE7wYrDx2iQmbNAxuBzMVllCuHUNN2z39gkPCiXSkr1s9F9ZanQOOMjLvgnJXXIeZvGa90IS GBnxbEdaazeOwnSo7ZjnQ/rSAqsRKLeFQfNF6703ZiCEYIbVtwGZ5TUaFOI7Vp6aUGs9Qwm94 Llh0+ZHL/dfPG5mKbs1fF8bYeYAXLLERazrDKCeddu7qhpQlLf3c1mFL9YCGSit+U8ymr4BFt GDyw3BBDKoL77UVGGtFwSFbWK/B5P3c8NkCHIXUoly2LFiQoWPvSlqomQw1FJAazpu71vPZQm K2BxXddy4pVR7ZkbHOePD2HLisAPDfIW8r8XG9FRqsgA0Zz01Ughxi97t4rIa3AXN0S5EqQB5 cJ0hCN1/Ys18FM9QWexPjwuyLLyAs1lJNbVTqkMMu7Bc9QAMWCAy6uegwuOU8n9puQRrgn3ud 6MIsn3f+akBbdH4TKFaxMm/3c6PjkHCus1ZnLDi3+K+NL1bon+rdloecFjIP5PKCVYvaaJu5e wVao6x0A8Npleo= 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1652640007; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=yRbiVhWwHKtioNC1M+fZ8vmH7qIEdq+/zJdgbkRlnFo=; b=kEZSt704k7VHu4XYa8wLpThEbEJTaFfqt07jCZ2+VohZwox7SvnH+uAIkCDM40+NglNy2X 5p6rZML+Yz8nEHApIhSx54aW3o5xLsKVShq4CAELlbReRP8AL6ulEwlF6oyIzSd2dzmU13 YQ6gY39ksDipZDeFD4wwXOBmSffxcx436AkzC2xV7bx6yisEBR/XXWTJU55zmM7LfH26jX ORlEJdekM1Ow2syyMufyM29RZWxq+4NKeCRQTVtUxAbIEwTJCoV082+Hibs2fb5Us2hpfx JNjMrpIp0uo43WliH53guLJAlPWWgC1XyX2aMNZAxg4n2FoKsLWJ9N74sHLagQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1652640007; a=rsa-sha256; cv=none; b=AS7tjYP0iOQilDNaYnPYnCQ/HMlZW7UPN2eQNvY9oK7iopGefOXFFJlYUj347JLHTD1f5u 9mKiNxWdJwLwRVIjvQ1++6y5q3bv4FVcG6ESnQbQD63AfSe//cX617T2wbZNX0uF1p8X3v OpSdj3YePxYWBcYVYr7XDnQUdtzgZO3oCAHYJjebz4l4/bdW782JKfaZLvg2WapTMRGY5b dmWalznzr0Dc24VFd3wZf+mlbR2hWrGK2rZS9FPKe7PgG8ZIRGEpjZE9oHluBv/JL7KVf4 qBHJKpM3Abmvw/u2GXrggrg0j91XpJQvzZ7jdxhnfFHpZ3dFZMsuRo0vblNesQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=EcBfsyvT; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 7.07 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=EcBfsyvT; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: F37CA28436 X-Spam-Score: 7.07 X-Migadu-Scanner: scn0.migadu.com X-TUID: lpIBGoxfoGvR * gnu/packages/tree-sitter.scm (make-emacs-tree-sitter-langs-grammar-bundl= e): New procedure. (emacs-tree-sitter-langs): New variable. =2D-- gnu/packages/tree-sitter.scm | 148 +++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index cb3f326367..b80d912bfc 100644 =2D-- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -24,6 +24,7 @@ (define-module (gnu packages tree-sitter) #:use-module (guix build-system emacs) #:use-module (guix build-system gnu) #:use-module (guix build-system tree-sitter) + #:use-module (guix build-system trivial) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix packages) @@ -797,3 +798,150 @@ (define-public emacs-tree-sitter @item More informative indexing for imenu. @end enumerate") (license license:expat))) + +(define emacs-tree-sitter-langs-grammar-bundle + (package + (name "emacs-tree-sitter-langs-grammar-bundle") + (source #f) + (version (package-version tree-sitter)) + (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-sit= ter"))) + '#$(package-inputs this-package)))))))) + (synopsis #f) + (description #f) + (home-page #f) + (license #f))) + +(define-public emacs-tree-sitter-langs + (package + (name "emacs-tree-sitter-langs") + (version "0.12.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/emacs-tree-sitter/tree-sitte= r-langs") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1p2zbb6ac7wi6x6zpbczcmpkb2p45md2csd2bj43d8s56ckzw5mp")))= ) + (build-system emacs-build-system) + (inputs + (list emacs-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 'disable-downloader + (lambda _ + (call-with-output-file "tree-sitter-langs-build.el" + (lambda (port) + (let ((on-load-message + (string-append + "tree-sitter-langs: Grammar bundle already inst= alled " + "via Guix. Installing external grammars via th= is " + "function isn't supported, if a language you ne= ed is " + "missing please report a bug at bug-guix@gnu.or= g."))) + (format + port + ";;;###autoload + (defun tree-sitter-langs-install-grammars + (&optional skip-if-installed version os + keep-bundle) + (interactive) + (message \"~a\")) + (defconst tree-sitter-langs--queries-dir + (file-name-as-directory + (concat (file-name-directory (locate-library \"= tree-sitter-langs.el\")) + \"queries\"))) + (defun tree-sitter-langs--bin-dir () \"~a\") + (provide 'tree-sitter-langs-build)" + on-load-message + #$emacs-tree-sitter-langs-grammar-bundle)))))) + (add-after 'unpack 'remove-cask + (lambda _ + (substitute* "script/test" + (("cask") "")))) + (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 pat= ch + ;; 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-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-lev= el +functionalities on top of tree-sitter, such as code folding, evil text +objects, ...etc. +@end enumerate") + (license license:expat))) =2D- 2.36.0