From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Tree Sitter and highlights.scm file Date: Fri, 01 Dec 2023 10:25:37 +0200 Message-ID: <83wmty9vni.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17171"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Tad Lispy , Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 01 09:26:29 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r8yqy-0004GN-Tq for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Dec 2023 09:26:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8yqH-0007S2-6c; Fri, 01 Dec 2023 03:25:45 -0500 Original-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 1r8yqF-0007QB-9F for emacs-devel@gnu.org; Fri, 01 Dec 2023 03:25:43 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8yqE-0004ZW-Dk; Fri, 01 Dec 2023 03:25:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=QapduvhnhWxacIgCl719YoFfahK1R7MG8xnsuktuiA4=; b=nPR6LyS4gkVvqu6jlG60 259fD4F7Pusc9e7hGChj27/jkpC1JThfkM5K8wMBxV+3i+xdtVL+r5KVbyJvB4TgwqiINVSHBXNZJ WThq3wC3Ac5U7Y4nRMcT/MzHRN6/hjBNLmrXySYuvhuy5MMmiGYyHkjXWQZ6oheTZa1Dyy+EEZDFY 6Uu1hWFeSSp+uIlv9LXk7iyqXFwqVdzNW77ss0CRlPM/JiGD2c2q/2jxVQxhL+7tz1M1Ff0KDm+35 difzo/z+10lHbTF2ljLGY9n0UUpAuJPzQEnVR1QqWsIiAn3Ph6zX4Le3t/6rcRf1pDTZEaRDbYPLu LAr5iXKSb1abbw==; In-Reply-To: (message from Tad Lispy on Thu, 30 Nov 2023 11:35:42 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:313426 Archived-At: > Date: Thu, 30 Nov 2023 11:35:42 +0000 > From: Tad Lispy > > Hi! It's my first post ever to a mailing list, so I hope I do everything > right. I'm also not very experienced with Emacs Lisp. > > Here is my context. I'm working on a major mode for a new programming > language. I'd like to leverage the built-in Tree Sitter support for > syntax highlighting. My colleague works on the Tree Sitter grammar. In > their repository there is a file called `queries/highlights.scm`. It's a > scheme file that contains queries for different syntactic elements. Most > other grammars I see also have such file, so I think it's standard in > Tree Sitter grammars. I think it's generated by the `tree-sitter` > command line program and later customized by a grammar author. It looks > like all the necessary information for syntax highlighting is there. > Since it's also a lisp, it should be possible to use this file to > automatically derive font lock rules. But all examples of tree sitter > modes I see re-implement all the queries in Emacs Lisp with > `treesit-font-lock-rules` function. Why is that? > > Before Emacs 29 there was a suite of 3rd party packages maintained by > Tuấn-Anh Nguyễn. One of the packages is a library of Tree Sitter > languages, that for each language contains the `highlights.scm` file. > See for example > https://github.com/emacs-tree-sitter/tree-sitter-langs/blob/master/queries/elm/highlights.scm. > So it looks like previously it was possible to utilize this file. Can we > still do it with Emacs 29? Yuan, any comments?