From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Wilhelm Kirschbaum Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter, using treesit-range-rules for embedded languages Date: Wed, 23 Nov 2022 09:12:14 +0200 Organization: Floatpays Message-ID: <3957565.hDPux3bv2P@melissa.local> References: <87o7syaon6.fsf@gmail.com> <93179658.VN8fuaoyE4@melissa.local> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1399"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 23 13:04:18 2022 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 1oxoUB-000AcO-W0 for ged-emacs-devel@m.gmane-mx.org; Wed, 23 Nov 2022 13:04:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxoTT-0007sM-2y; Wed, 23 Nov 2022 07:03:31 -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 1oxjvl-0004Cq-5A for emacs-devel@gnu.org; Wed, 23 Nov 2022 02:12:26 -0500 Original-Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxjvh-0001rZ-HF for emacs-devel@gnu.org; Wed, 23 Nov 2022 02:12:24 -0500 Original-Received: by mail-wm1-x335.google.com with SMTP id p16so12409127wmc.3 for ; Tue, 22 Nov 2022 23:12:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=floatpays.co.za; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :organization:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=sVSsIIRrpj1bV/VX5VgBGFVUjnAoq1iDyPtpcNCKbyU=; b=eZ0WZ94o7IvR+xnSZLl43sgJokq4rEejiX8/rH3blLpdviL/OZ4bJcH50w2VGFCV2p MFGOYGRr0L1RHCzpQGZOnt6G3+d3GNw+Xpkv5O+NlgPLwM5iDP7hWaBg/ZIJP/vTSDV8 vOFGk5eFtZtv5Vx3bhLiSITz46bte1pGbrKEw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :organization:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=sVSsIIRrpj1bV/VX5VgBGFVUjnAoq1iDyPtpcNCKbyU=; b=RPHcR7aHv6siO7REEJ+vxOMk+8F5Nzh1SZjozFRMEIGmM1YGXrV6O9SlXCeoNYpOkq Ff631Z6o76qoTPllfCnzJwontJhDaXJfnRHzrX8slZBXf8Mlul7l9mWtR13ZBuNTnzSk FNVpbhyLLMq0kJ6XUd+UsOCmNJwL4CfNWiCYQPnSmyzJZSpxEBRzBDXPHV2+7IxMLFk2 KO0Dyetnju1oAHzB8NuSab1sNak7NeoiaRgk4USuJpGeeACMgbe/QCKQJxeUsjG2vEGk ndVY1bXuTOuJm16ur0+zNM4O8l7ZGEUX0N24qeXMOsXmyEwRTb4f2QE4zR+Wgat6pOLV NjKQ== X-Gm-Message-State: ANoB5pmR0js2Uw11V6JkaBfy+yp7QKzS/1ZmAeBwXP0PSJTImnGQ5Mib BLAUnZ+AZ12P+1sHDHIBcicM7w== X-Google-Smtp-Source: AA0mqf4Buq+2eW0jmKI5a/g6PoaptYeo0By1KdRr0AYBKD4y9CZYUFj4UiH36kDmK14IB/wDzaHI7g== X-Received: by 2002:a7b:cbcb:0:b0:3cf:a83b:cf25 with SMTP id n11-20020a7bcbcb000000b003cfa83bcf25mr7655621wmi.170.1669187538373; Tue, 22 Nov 2022 23:12:18 -0800 (PST) Original-Received: from melissa.local ([2c0f:ef18:1431:0:b09:9616:db04:c248]) by smtp.gmail.com with ESMTPSA id u14-20020a05600c19ce00b003b3307fb98fsm1245563wmq.24.2022.11.22.23.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 23:12:17 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=wilhelm@floatpays.co.za; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 23 Nov 2022 07:03:13 -0500 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:300385 Archived-At: On Tuesday, 22 November 2022 22:39:54 SAST Yuan Fu wrote: > > On Nov 22, 2022, at 11:52 AM, Wilhelm Hugo Kirschbaum > > wrote:>=20 > > On Tuesday, 22 November 2022 21:28:48 SAST Yuan Fu wrote: > >>> On Nov 22, 2022, at 9:24 AM, Wilhelm wrote: > >>>=20 > >>> Is there perhaps an example using treesit-range-rules? To following > >>> attempt to set treesit-range-settings does not seem to have the desir= ed > >>> effect. > >>>=20 > >>> (defvar heex--treesit-range-rules > >>>=20 > >>> (treesit-range-rules > >>>=20 > >>> :embed 'elixir > >>> :host 'heex > >>> =20 > >>> '((directive (partial_expression_value) @cap) > >>> =20 > >>> (directive (expression_value) @cap) > >>> (expression (expression_value) @cap)))) > >>>=20 > >>> (setq-local treesit-range-settings heex--treesit-range-rules) > >>>=20 > >>> The following error also pops up when modifying the buffer when remov= ing > >>> buffer content: > >>>=20 > >>> Error during redisplay: (jit-lock-function 1) signaled > >>> (treesit-range-invalid "RANGE is either overlapping, out-of-order or > >>> out-of-range" ((11 . 20))) > >>>=20 > >>> The full attempt is here: > >>> https://github.com/wkirschbaum/elixir-mode/blob/main/heex-mode.el > >>=20 > >> Thanks Wilhelm. It would be nice if you can provide some example source > >> file of heex for me to experiment with. I tried to find some on the > >> internet but didn=E2=80=99t get very far :-) > >>=20 > >> Yuan > >=20 > > Thanks for having a look as I was not sure if this was meant to be used > > yet. > >=20 > > A heex file can be as simple as this: > >=20 > > #sample.html.heex > >
> >=20 > > <%=3D Enum.map([1, 2], &(&1 + 1)) %> > >=20 > >
> >=20 > > and the directive <%=3D (partial_expression_value) %> should then be > > elixir., > > not heex. > >=20 > > When checking with (treesit-language-at (point)) for the embed it still > > show. > >=20 > > Wilhelm >=20 > Cool. Please see if this works. Admittedly the process is a little =E2=80= =9Craw=E2=80=9D. > That=E2=80=99s mainly due to me not wanting to commit to a framework befo= re we have > a lot of real-world experience with multi-language major modes. Please let > me know if you think how could this be improved. For starters, maybe > someways to =E2=80=9Cinherit=E2=80=9D font-lock rules with treesit-font-l= ock-rules? Maybe > the feature-list should have independent configuration for each language, > so we don=E2=80=99t have feature-namespace conflicts? (Right now we renam= e all > elixir features to elixir-.) >=20 > I=E2=80=99ve also fixed the warning you see (which is due to treesit.el, = not your > code), so you=E2=80=99ll need to pull master. >=20 > Thanks! > Yuan This is great, thank you! The font lock for the embedded language seems to= =20 work with some quirks, but will have a look in the next couple of days to=20 pinpoint any specific issues. Wilhelm