From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 cK5sEFUZgGPf2QAAbAwnHQ (envelope-from ) for ; Fri, 25 Nov 2022 02:24:37 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 2ItoEFUZgGO+dgAAauVa8A (envelope-from ) for ; Fri, 25 Nov 2022 02:24:37 +0100 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 E684827590 for ; Fri, 25 Nov 2022 02:24:36 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oyNRl-0006Sc-Q7; Thu, 24 Nov 2022 20:24:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oyNRi-0006Pw-OV for guix-patches@gnu.org; Thu, 24 Nov 2022 20:24:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oyNRi-0004s1-Fo for guix-patches@gnu.org; Thu, 24 Nov 2022 20:24:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oyNRi-0000TL-Bw for guix-patches@gnu.org; Thu, 24 Nov 2022 20:24:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH v7 32/32] gnu: Add emacs-tree-sitter-langs. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 25 Nov 2022 01:24:02 +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.16693394001724 (code B ref 49946); Fri, 25 Nov 2022 01:24:02 +0000 Received: (at 49946) by debbugs.gnu.org; 25 Nov 2022 01:23:20 +0000 Received: from localhost ([127.0.0.1]:60866 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyNR2-0000Re-6k for submit@debbugs.gnu.org; Thu, 24 Nov 2022 20:23:20 -0500 Received: from mout.gmx.net ([212.227.17.22]:33115) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyNQD-0000JQ-AL for 49946@debbugs.gnu.org; Thu, 24 Nov 2022 20:22:30 -0500 Received: from localhost.localdomain ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MJmGP-1pIVle279F-00K9hX; Fri, 25 Nov 2022 02:22:23 +0100 From: Pierre Langlois Date: Fri, 25 Nov 2022 01:21:42 +0000 Message-Id: <20221125012142.22579-33-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221125012142.22579-1-pierre.langlois@gmx.com> References: <87mtfi63ut.fsf@gmx.com> <20221125012142.22579-1-pierre.langlois@gmx.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:p2PnVRh5JbdrOAQug2c77p9QgdAqNsacHan6OxarUzv7R5cw0B2 PXJlkJki5A0cmmo4k04oqynjYZqGVppvoxcghKgLSE6LgyfCVi3693X5oznO3vvI4u5vLZP W5oY4TDd/Ez8Vws0oqSNoOtiQHYkgp5V2f6q3QobJ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Ijt7VdMU7F4buyHQpQBqWsM30w= 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1669339477; 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; bh=ZPctCEPeblJhfhlspCy+lV/ptYZadEFG2eFLApfydvY=; b=LRYqO3OJfLkVS8HE55kChbMkv3r1igrQopfM3vwq6FKwvUXobMafo1l5of7R7c8FH/A9ex lFcgMQdlNsj3B3JhgpQwjehlJwEQJBIy3GrDBZQA3URBTHozfQ1mha1CU6o5P/0BBM51ES 1Ud8Qnc7GULMwY9WZMWzcF78eugAToA73H4Frh5jBoT0PuGAdHauKVb0QaBsuQmEJj2DDM oX947y9hCgH352IEJ4gKe1eOyxbgxBgjz9sHJCFqCeZNfqRGWspNWphJviy5ZP7N6KBGrI uTvpqCMz+nXbwFkxh1QDT532tM2NvhGIv1I+W5SuoP8EXxBpMSFO0V95GE6P6Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1669339477; a=rsa-sha256; cv=none; b=kvwQBRSs2PvT0v0vkPyDg4xEzQ7Xx7RgeiZKzntJqqqZ2If0pE49dwm3KTrr5bBXIYHF+f 4Mg0ClsplySrS5KBGG/vBWklhlSmoo26j8UzjN91U79udft5BknKUe7LZWpHWxYtiYfrCQ CxCQ/fpjQi8INBz5ymYGgQ92M1aLGa1RB/y9wHiS4rqDwpS69KGyiUiodiR8cQPnsFmcjC 1+VEcuIvOgiPIe5clX/za/q8zQF/hqpboMOiWzjKQh6VyFUbSZQ+Qc0w2Arw4CRKryUznL 9YhUoVzDYXzVG54J2gwxzc2rRXA6hzRlm3d4NJfqjK4TpPBB5sf2cIaXXeLC8w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" 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: 3.40 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" 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: E684827590 X-Spam-Score: 3.40 X-Migadu-Scanner: scn0.migadu.com X-TUID: LT793Qc9ZoVt * gnu/packages/tree-sitter.scm (make-emacs-tree-sitter-langs-grammar-bundle): New procedure. (emacs-tree-sitter-langs): New variable. --- gnu/packages/tree-sitter.scm | 150 +++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index 26b0206575..02d515bdc4 100644 --- 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) @@ -849,3 +850,152 @@ (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-haskell + 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-r + 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)))))))) + (synopsis #f) + (description #f) + (home-page #f) + (license #f))) + +(define-public emacs-tree-sitter-langs + (package + (name "emacs-tree-sitter-langs") + (version "0.12.6") + (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 + "1qqf5naf4a9zm0am1rn9yn2b2s6q3h9fapsl5d546vbsyvak5q40")))) + (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 installed " + "via Guix. Installing external grammars via this " + "function isn't supported, if a language you need is " + "missing please report a bug at bug-guix@gnu.org."))) + (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 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-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))) -- 2.38.1