Subject: 29.0.50; [PATCH]: Add new font-lock settings to css-ts-mode

From: Theodor Thornhill <[email-masked]>
Date: Mon, 28 Nov 2022 09:58:09 +0100

Hi Yuan and Stefan!

I added some more font-lock settings to css-ts-mode.  See attached
patch.

Theo

>From c2b134de55573117ad88b8651ff1f2d75662e2a2 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <[email-masked]>
Date: Mon, 28 Nov 2022 09:35:15 +0100
Subject: [PATCH] Add more font-lock settings to css-ts-mode

* lisp/textmodes/css-mode.el (css--treesit-settings): Add new
font-lock features 'query', 'keyword', 'operator' and 'bracket'.
(css-ts-mode): Use new features.
---
 lisp/textmodes/css-mode.el | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 734252ee66..123ce23762 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -1353,10 +1353,27 @@ css--treesit-settings
    :language 'css
    '((string_value) @font-lock-string-face)
 
+   :feature 'keyword
+   :language 'css
+   '(["@media"
+      "@import"
+      "@charset"
+      "@namespace"
+      "@keyframes"] @font-lock-builtin-face
+      ["and"
+      "or"
+      "not"
+      "only"
+      "selector"] @font-lock-keyword-face)
+
    :feature 'variable
    :language 'css
    '((plain_value) @font-lock-variable-name-face)
 
+   :language 'css
+   :feature 'operator
+   `(["=" "~=" "^=" "|=" "*=" "$="] @font-lock-operator-face)
+
    :feature 'selector
    :language 'css
    '((class_selector) @css-selector
@@ -1377,7 +1394,18 @@ css--treesit-settings
    :language 'css
    '((integer_value) @font-lock-number-face
      (float_value) @font-lock-number-face
-     (unit) @font-lock-constant-face)
+     (unit) @font-lock-constant-face
+     (important) @font-lock-builtin-face)
+
+   :feature 'query
+   :language 'css
+   '((keyword_query) @font-lock-property-face
+     (feature_name) @font-lock-property-face)
+
+
+   :feature 'bracket
+   :language 'css
+   '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face)
 
    :feature 'error
    :language 'css
@@ -1808,9 +1836,9 @@ css-ts-mode
     (setq-local treesit-defun-type-regexp "rule_set")
     (setq-local treesit-font-lock-settings css--treesit-settings)
     (setq-local treesit-font-lock-feature-list
-                '((selector comment)
+                '((selector comment query keyword)
                   (property constant string)
-                  (error variable function)))
+                  (error variable function operator bracket)))
     ;; Tree-sitter-css, for whatever reason, cannot reliably return
     ;; the captured nodes in a given range (it instead returns the
     ;; nodes preceding range).  Before this is fixed in
-- 
2.34.1