From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Standardizing tree-sitter fontification features Date: Thu, 24 Nov 2022 22:15:13 -0800 Message-ID: <88CEDB6E-AD74-4B18-81DE-F6A3436B5851@gmail.com> References: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) 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="36249"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Randy Taylor Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 25 07:15:58 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 1oyS0D-00099O-B3 for ged-emacs-devel@m.gmane-mx.org; Fri, 25 Nov 2022 07:15:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oyRze-0004kZ-4K; Fri, 25 Nov 2022 01:15:23 -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 1oyRzb-0004jg-DV for emacs-devel@gnu.org; Fri, 25 Nov 2022 01:15:19 -0500 Original-Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oyRzZ-0002E7-Ov for emacs-devel@gnu.org; Fri, 25 Nov 2022 01:15:19 -0500 Original-Received: by mail-pj1-x1033.google.com with SMTP id a1-20020a17090abe0100b00218a7df7789so6787649pjs.5 for ; Thu, 24 Nov 2022 22:15:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Hj03hOhhr9QW9FYC7Mskh6rwJHO2qxL6bGvmcTFSQX8=; b=jpoqOxIwgUegtXy5FaoF0oCeLruNP1lN0SUzYVVkHPAgT2RirvX4WpuATAXfWiScfJ pMfY2/IGaZh/2NmLmhJ1U1tIahPA8NNWnu9/9trOJsmoQyHNwkBf4DN64GPBLu4RcACT mA6RKuaeBLcSs2TCrJ8ULk7heVwvz+W4hHnhcpsf8ABNWlaTQdXEDnZslAzsvkpJTOyo ZaW242KbyuyzBRS+dZn8clVLn7o5AhoBKK1/4khoNmEPxEoI3Lus5UNxkJaKBDAuTOn3 k9AqiJI9JoEHhCsIz/J/SMGe1NLA5mlgbBRq/c8fS3x7H6O6Krypn2NSsxuBoySpHjuc nV/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hj03hOhhr9QW9FYC7Mskh6rwJHO2qxL6bGvmcTFSQX8=; b=Wv/8VfipNfuKhjOpppEmTYG4TNZYyzXB1pXF8A1z/10KQpMr+/2VJ6gGXbFb6+6vLX pBcfWqY/wfobwmHLS7yzQBCyZsy719ZlSJRpgblccubogyN5y0rJwftoYy2lcU5+zojF KQc1UB03HzLyTFJLj6nLvxkW1urO9JKLmiog841AEDmUGyGIeDner+NdzLcGqYUlQLnh A7OJSXg6RpmnmJbdYarb93FuzMgp598vNjMvLnmNW3N3VjpytuaqGtsp2S84szPzpU/0 YsC8v3zN9o1KGdS5U9eHA7tDigfV3JJmuN/qLZLOk/vpH+6ByAEqKf19Wn6LoSRpSsm+ Nscg== X-Gm-Message-State: ANoB5pmufFErR+70e4gh1KBMTiW/0w9MqODBxJXU62mjTL7F/i+vyGsI BosxiNrl+1JPDNJtL/pq+gue7AWE8yA= X-Google-Smtp-Source: AA0mqf4U/6JSknhCWGL4Ce+GWMPqAZgqUwEbXM+jRhpB4Gc/jNA1Vim6hwzjrCcU8qbLex7znC8dcg== X-Received: by 2002:a17:902:a511:b0:174:7d26:812f with SMTP id s17-20020a170902a51100b001747d26812fmr17466477plq.63.1669356916297; Thu, 24 Nov 2022 22:15:16 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id s2-20020a655842000000b0046faefad8a1sm1905611pgr.79.2022.11.24.22.15.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Nov 2022 22:15:16 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=casouri@gmail.com; helo=mail-pj1-x1033.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, FREEMAIL_FROM=0.001, 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-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:300460 Archived-At: > On Nov 24, 2022, at 5:13 PM, Randy Taylor wrote: >=20 > On Thursday, November 24th, 2022 at 17:16, Yuan Fu = wrote: >=20 >>=20 >> For tree-sitter-based major modes, fontification rules are = categorized into =E2=80=9Cfeatures=E2=80=9D, which can be individually = turned on/off. I think it would be good to have a standardized list of = common features and their precise meaning defined. We=E2=80=99ve been = working on these fontification 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 = here. >>=20 >> Once we agree on a list of standard features and their definition, = the next step would be to figure out how should a major mode introduce = its supported 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 = disable they by default. The default value of = font-lock-maximum-decoration is t, meaning use everything, which is not = very helpful... >>=20 >> Yuan >=20 > Looks good! >=20 > key should be considered property IMO, and that's how we're = highlighting things now. I agree. >=20 > I wonder if assignment and definition are really worth having (and = would prefer to do without them), since they should be covered by the = variable, function, type and property features. They are definitely useful. They are the things we currently highlight, = and for a reason. Personally I only want to highlight identifiers in = definition and assignment, not every occurrence of them. Since so much = of a program consists of variable and function identifiers, highlighting = all of them looks almost like highlighting everything. I just want some = visual cues on the program structure, not programming in skittles :-) >=20 > I would also add: > - misc-punctuation, for anything not considered a delimiter or = bracket. Most modes would use this for any special punctuation they've = got. Is there any examples? Maybe just merge delimiter and punctuation = together? > - (maybe) literal instead of number? That way there is a group for = chars too (and any other literals if there are any?). Or a char feature = in addition to the existing number one. I'm undecided... Literal seems to encompass numbers, strings, chars, and constants. So I = don=E2=80=99t know how does it fit. We could add char to string feature. >=20 > 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. Good idea :-) A tangent of your tangent: how did you alphabetize them? = Did you use the sort-word package on EmacsWiki? Yuan