From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Randy Taylor Newsgroups: gmane.emacs.devel Subject: Re: Standardizing tree-sitter fontification features Date: Fri, 25 Nov 2022 01:13:46 +0000 Message-ID: References: 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="32490"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 25 02:15:02 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 1oyNIz-0008Dr-Q3 for ged-emacs-devel@m.gmane-mx.org; Fri, 25 Nov 2022 02:15:02 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oyNIA-0001bd-KS; Thu, 24 Nov 2022 20:14:10 -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 1oyNI8-0001b0-Or for emacs-devel@gnu.org; Thu, 24 Nov 2022 20:14:08 -0500 Original-Received: from mail-4323.proton.ch ([185.70.43.23]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oyNI5-0007Ie-Hz for emacs-devel@gnu.org; Thu, 24 Nov 2022 20:14:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rjt.dev; s=protonmail2; t=1669338840; x=1669598040; bh=+eB4/mLiLMV9KyNfR3SHrbr4+uE6NuzaTcTfsR8PBmw=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=rY1bHvf7LmcDuqmGr7a3onIfG976sleQfoi/lPktMGTq2tvW3jTI4H2CBCW6f6UH7 uiFVY9EsGDkuyuZRjUtTHX62hklFhrjrE+5YvdLOS04eIqTK5ezmmZ8QqO7FxLLGHx 2CY/KIlUZFr7m3WW6xp6im39jLQtNZrmndVWZtO5NaG4lULLNV+ilIUH2UxX0XQ545 67/5JskxlpR45CN93/lTwp/JDMTpGkxIBbEebZE/U8s9RxLZRuqEWNj5INAC+n2oXk bhMye7AAjwF9Npc0TPMe6KP7Md9V0nGeJqdnXVbmeBBse83CPIU02cynGhRsBzIvTE ObZY/hQpccBIw== In-Reply-To: Feedback-ID: 44397038:user:proton Received-SPF: pass client-ip=185.70.43.23; envelope-from=dev@rjt.dev; helo=mail-4323.proton.ch 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_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:300454 Archived-At: On Thursday, November 24th, 2022 at 17:16, Yuan Fu wrot= e: >=20 > For tree-sitter-based major modes, fontification rules are categorized in= to =E2=80=9Cfeatures=E2=80=9D, which can be individually turned on/off. I t= hink it would be good to have a standardized list of common features and th= eir precise meaning defined. We=E2=80=99ve been working on these fontificat= ion rules for some time and arrived at a reasonable baseline, and now it= =E2=80=99s a good time to discuss and bless it, I think. >=20 > Right now we have: >=20 > Basic tokens: >=20 > delimiter ,.; > operator =3D !=3D || > bracket []{}() >=20 > constant true, false, null > number > keyword > comment > string > string-interpolation f"text {variable}" > escape-sequence "\n\t\\" > function every function identifier > variable every variable identifier > type every type identifier > property a.b <--- highlight b > key { a: b, c: d } <--- highlight a, c > error highlight parse error >=20 > More abstract ones: >=20 > assignment: the LHS of an assignment (thing being assigned to), eg: >=20 > a =3D b <--- highlight a > a.b =3D c <--- highlight b > a[1] =3D d <--- highlight a >=20 > definition: the thing being defined, eg: >=20 > int a(int b) { <--- highlight a > return 0 > } >=20 > int a; <-- highlight a >=20 > struct a { <--- highlight a > int b; <--- highlight b > } >=20 > There are also language-specific features, but they are not the focus her= e. >=20 > Once we agree on a list of standard features and their definition, the ne= xt step would be to figure out how should a major mode introduce its suppor= ted features to a user (major mode docstring + link to manual for standard = features?). >=20 > Also, some of the features are very busy, it would be good if we can disa= ble they by default. The default value of font-lock-maximum-decoration is t= , meaning use everything, which is not very helpful... >=20 > Yuan Looks good! key should be considered property IMO, and that's how we're highlighting th= ings now. I wonder if assignment and definition are really worth having (and would pr= efer to do without them), since they should be covered by the variable, fun= ction, type and property features. I would also add: - misc-punctuation, for anything not considered a delimiter or bracket. Mos= t modes would use this for any special punctuation they've got. - (maybe) literal instead of number? That way there is a group for chars to= o (and any other literals if there are any?). Or a char feature in addition= to the existing number one. I'm undecided... Maybe a slight tangent but I also suggest we alphabetize all of these; both= the queries and the list of features. I'll send a patch to do that myself = once things cool down a bit. Although anything that overrides will need to = go at the bottom to make sure it gets applied.