]> git.eshelyaron.com Git - emacs.git/commitdiff
Fontify some keywords in type face in c-ts-mode
authorYuan Fu <casouri@gmail.com>
Tue, 6 Dec 2022 08:15:30 +0000 (00:15 -0800)
committerYuan Fu <casouri@gmail.com>
Tue, 6 Dec 2022 21:43:58 +0000 (13:43 -0800)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--keywords): Remove some keywords.
(c-ts-mode--type-keywords): New variables.
(c-ts-mode--font-lock-settings): New rule.

lisp/progmodes/c-ts-mode.el

index 1bd093cfa2df7f5f9085d02714b8b62a84a54616..400af2db19e4b71d1d5e8d1e183a6c36a58fa97f 100644 (file)
@@ -169,9 +169,9 @@ MODE is either `c' or `cpp'."
          '("break" "case" "const" "continue"
            "default" "do" "else" "enum"
            "extern" "for" "goto" "if" "inline"
-           "long" "register" "return" "short"
-           "signed" "sizeof" "static" "struct"
-           "switch" "typedef" "union" "unsigned"
+           "register" "return"
+           "sizeof" "static" "struct"
+           "switch" "typedef" "union"
            "volatile" "while")))
     (if (eq mode 'cpp)
         (append c-keywords
@@ -188,6 +188,10 @@ MODE is either `c' or `cpp'."
                   "xor" "xor_eq"))
       (append '("auto") c-keywords))))
 
+(defvar c-ts-mode--type-keywords
+  '("long" "short" "signed" "unsigned")
+  "Keywords that should be considered as part of a type.")
+
 (defvar c-ts-mode--operators
   '("=" "-" "*" "/" "+" "%" "~" "|" "&" "^" "<<" ">>" "->"
     "." "<" "<=" ">=" ">" "==" "!=" "!" "&&" "||" "-="
@@ -263,7 +267,8 @@ MODE is either `c' or `cpp'."
            (qualified_identifier
             scope: (namespace_identifier) @font-lock-type-face)
 
-           (operator_cast) type: (type_identifier) @font-lock-type-face)))
+           (operator_cast) type: (type_identifier) @font-lock-type-face))
+     [,@c-ts-mode--type-keywords] @font-lock-type-face)
 
    :language mode
    :feature 'definition