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: Support multiple tree-sitter grammars Date: Sun, 07 May 2023 13:59:38 +0300 Message-ID: <83ild4e7ad.fsf@gnu.org> References: <873548to4k.fsf@cassou.me> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="406"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Damien Cassou Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 07 12:58:59 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 1pvc6V-000ASP-6q for ged-emacs-devel@m.gmane-mx.org; Sun, 07 May 2023 12:58:59 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pvc6E-0006Lv-Ih; Sun, 07 May 2023 06:58:42 -0400 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 1pvc6D-0006Lk-3G for emacs-devel@gnu.org; Sun, 07 May 2023 06:58:41 -0400 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 1pvc6C-0003t7-K2; Sun, 07 May 2023 06:58:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=tDy+CcYepVpj1j/pf6/Ei6iNWXhzhBnflWnIJcnnOv4=; b=HEM9ffqFbk66 Y1mq56gky+sN4R/VPzX6AbssCrXzZd7b0qAEKUXR5LucCn5eMhcU0EjHXNAOafHgT6ugpTrWp61rn 9DdoTVHZgsnAvp4+xdGKLph6+Hvy7CXeQDx3doIlP3SATg7GadfSAA92pbVRxUoOYi+my0UjOERkg et+DYxexK8DV5Lv7cORYVL90wThoAA8Z51jHBWRoPQFbx9NXMAugS56y1+GDNxPR9jiG+S14xhfd0 zT0AFs+Sp9sMWO3y0RsP32N5Q+ck7yF0OmwDGVPiV060Ux3gc2ip+IkhzoVE47ZGxt8jQvOQQlDAR Y/Ot4Shz1Sr/Nyc2O8lnjw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pvc6C-0004pS-3e; Sun, 07 May 2023 06:58:40 -0400 In-Reply-To: <873548to4k.fsf@cassou.me> (message from Damien Cassou on Sun, 07 May 2023 12:46:51 +0200) 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:305948 Archived-At: > From: Damien Cassou > Date: Sun, 07 May 2023 12:46:51 +0200 > > Hi, > > some files may consist of several parts requiring different tree-sitter > grammars. For example, a JavaScript file may have its documentation > written with jsdoc: JavaScript and jsdoc have a tree-sitter grammar > each. > > Is there a way to use a tree-sitter grammar in parts of the file and > another one in other parts? There could be a main grammar and secondary > grammars would be activated on some kinds of nodes of the main one. Yes, it should be possible, AFAIU. See the node "Multiple Languages" in the ELisp manual, I believe it explains how to do what you want.