unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59651: 29.0.50; [PATCH]: Add new font-lock settings to css-ts-mode
@ 2022-11-28  8:58 Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-11-28 22:56 ` Yuan Fu
  0 siblings, 1 reply; 3+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-28  8:58 UTC (permalink / raw)
  To: 59651; +Cc: casouri, stefankangas

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

Hi Yuan and Stefan!

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

Theo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-more-font-lock-settings-to-css-ts-mode.patch --]
[-- Type: text/x-diff, Size: 2526 bytes --]

From c2b134de55573117ad88b8651ff1f2d75662e2a2 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#59651: 29.0.50; [PATCH]: Add new font-lock settings to  css-ts-mode
  2022-11-28  8:58 bug#59651: 29.0.50; [PATCH]: Add new font-lock settings to css-ts-mode Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-11-28 22:56 ` Yuan Fu
  2022-11-28 22:58   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 3+ messages in thread
From: Yuan Fu @ 2022-11-28 22:56 UTC (permalink / raw)
  To: Theodor Thornhill; +Cc: 59651, stefankangas


Theodor Thornhill <theo@thornhill.no> writes:

> Hi Yuan and Stefan!
>
> I added some more font-lock settings to css-ts-mode.  See attached
> patch.
>
> Theo
>

Thanks! Applied.

Yuan





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#59651: 29.0.50; [PATCH]: Add new font-lock settings to  css-ts-mode
  2022-11-28 22:56 ` Yuan Fu
@ 2022-11-28 22:58   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 3+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-28 22:58 UTC (permalink / raw)
  To: Yuan Fu; +Cc: 59651, stefankangas



On 28 November 2022 23:56:34 CET, Yuan Fu <casouri@gmail.com> wrote:
>
>Theodor Thornhill <theo@thornhill.no> writes:
>
>> Hi Yuan and Stefan!
>>
>> I added some more font-lock settings to css-ts-mode.  See attached
>> patch.
>>
>> Theo
>>
>
>Thanks! Applied.
>
>Yuan

Thanks :)





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-28 22:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-28  8:58 bug#59651: 29.0.50; [PATCH]: Add new font-lock settings to css-ts-mode Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-28 22:56 ` Yuan Fu
2022-11-28 22:58   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).