all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Jostein Kjønigsen" <jostein@secure.kjonigsen.net>
To: Theodor Thornhill <theo@thornhill.no>, 59831@debbugs.gnu.org
Cc: jostein@kjonigsen.net, casuri@gmail.com
Subject: bug#59831: 29.0.60; typescript-ts-mode: Variables, properties & fields are often not fontified
Date: Mon, 5 Dec 2022 10:05:30 +0100	[thread overview]
Message-ID: <2151efc1-b6f6-4e0d-7416-cccae9277a34@secure.kjonigsen.net> (raw)
In-Reply-To: <87v8mqxmfo.fsf@thornhill.no>

[-- Attachment #1: Type: text/plain, Size: 2895 bytes --]

Attached is another patch with some further improvements.

These too OK with you, Theodor?

--
Jostein

jostein@kjonigsen.net 🍵 jostein@gmail.com
https://jostein.kjønigsen.no <https://jostein.kjønigsen.no>
On 05.12.2022 09:51, Theodor Thornhill wrote:
> Jostein Kjønigsen <jostein@secure.kjonigsen.net> writes:
>
>> When I create or use a class in a Typescript-file, I often have
>> properties and field declarations.
>>
>> These are all fontified using default-face, instead of
>> font-lock-property-face.
>>
>> Also when creating new objects using bracket syntac { key: value, key:
>> value, etc: etc }, default-face is used.
>>
>> Attached is a patch which improves fontification of these aspects in
>> both typescript-ts-mode and typescript-tsx-mode.
>>
>> It also contains code to further improve fontification of
>> retuen-statements, which IMO is a little bit lacking.
>>
> LGTM :) Yuan, feel free to apply when you have some free time!
>
>>  From 3bcbd89cc43c6ad7885f11aa4c7c92ebd600a164 Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= <jostein@kjonigsen.net>
>> Date: Mon, 5 Dec 2022 09:31:58 +0100
>> Subject: [PATCH] lisp/progmodes/typescript-ts-mode: improve fontification
>>
>> - syntax-highlight property and field definitions in class declaration.
>> - syntax-highlight property-keys in object initializaters.
>> - syntax-highlight variable-names in function/method return-statements.
>> ---
>>   lisp/progmodes/typescript-ts-mode.el | 13 +++++++++++--
>>   1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
>> index 48ac1169fe8..48d3c084b6e 100644
>> --- a/lisp/progmodes/typescript-ts-mode.el
>> +++ b/lisp/progmodes/typescript-ts-mode.el
>> @@ -213,7 +213,9 @@ typescript-ts-mode--font-lock-settings
>>         parameters:
>>         [(_ (identifier) @font-lock-variable-name-face)
>>          (_ (_ (identifier) @font-lock-variable-name-face))
>> -       (_ (_ (_ (identifier) @font-lock-variable-name-face)))]))
>> +       (_ (_ (_ (identifier) @font-lock-variable-name-face)))])
>> +
>> +     (return_statement (identifier) @font-lock-variable-name-face))
>>   
>>      :language language
>>      :override t
>> @@ -282,7 +284,14 @@ typescript-ts-mode--font-lock-settings
>>      :language language
>>      :override t
>>      :feature 'property
>> -   `((pair value: (identifier) @font-lock-variable-name-face)
>> +   `((property_signature
>> +      name: (property_identifier) @font-lock-property-face)
>> +     (public_field_definition
>> +      name: (property_identifier) @font-lock-property-face)
>> +
>> +     (pair key: (property_identifier) @font-lock-variable-name-face)
>> +
>> +     (pair value: (identifier) @font-lock-variable-name-face)
>>   
>>        ((shorthand_property_identifier) @font-lock-property-face)
>>   
> Thanks!
>
> Theo

[-- Attachment #2: 0002-lisp-progmodes-typescript-ts-mode-Improve-fontificat.patch --]
[-- Type: text/x-patch, Size: 1186 bytes --]

From 441b2340f0a8d9bf27b0dbcb985051c84672f41f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= <jostein@kjonigsen.net>
Date: Mon, 5 Dec 2022 10:00:15 +0100
Subject: [PATCH 2/2] lisp/progmodes/typescript-ts-mode: Improve fontifications
 of variables in use.

---
 lisp/progmodes/typescript-ts-mode.el | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index 48d3c084b6e..3da690567e2 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -215,7 +215,12 @@ typescript-ts-mode--font-lock-settings
        (_ (_ (identifier) @font-lock-variable-name-face))
        (_ (_ (_ (identifier) @font-lock-variable-name-face)))])
 
-     (return_statement (identifier) @font-lock-variable-name-face))
+     (return_statement (identifier) @font-lock-variable-name-face)
+
+     (binary_expression left: (identifier) @font-lock-variable-name-face)
+     (binary_expression right: (identifier) @font-lock-variable-name-face)
+
+     (arguments (identifier) @font-lock-variable-name-face))
 
    :language language
    :override t
-- 
2.37.2


  reply	other threads:[~2022-12-05  9:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05  8:42 bug#59831: 29.0.60; typescript-ts-mode: Variables, properties & fields are often not fontified Jostein Kjønigsen
2022-12-05  8:51 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05  9:05   ` Jostein Kjønigsen [this message]
2022-12-05  9:24     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05 20:13       ` Yuan Fu
2022-12-07  9:24         ` Jostein Kjønigsen
2022-12-07  9:33           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-07  9:42             ` Jostein Kjønigsen
2022-12-12  7:53               ` Jostein Kjønigsen
2022-12-14 18:46                 ` Jostein Kjønigsen
2022-12-14 19:03                   ` Eli Zaretskii
2022-12-14 19:39                     ` Yuan Fu
2022-12-14 21:56                       ` Jostein Kjønigsen
2022-12-14 22:21                         ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2151efc1-b6f6-4e0d-7416-cccae9277a34@secure.kjonigsen.net \
    --to=jostein@secure.kjonigsen.net \
    --cc=59831@debbugs.gnu.org \
    --cc=casuri@gmail.com \
    --cc=jostein@kjonigsen.net \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.