Fontify some keywords in type face in c-ts-mode

* 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.
This commit is contained in:
Yuan Fu 2022-12-06 00:15:30 -08:00
parent b3847c0208
commit 6187d001f2
No known key found for this signature in database
GPG key ID: 56E19BC57664A442

View file

@ -169,9 +169,9 @@ MODE is either `c' or `cpp'."
'("break" "case" "const" "continue" '("break" "case" "const" "continue"
"default" "do" "else" "enum" "default" "do" "else" "enum"
"extern" "for" "goto" "if" "inline" "extern" "for" "goto" "if" "inline"
"long" "register" "return" "short" "register" "return"
"signed" "sizeof" "static" "struct" "sizeof" "static" "struct"
"switch" "typedef" "union" "unsigned" "switch" "typedef" "union"
"volatile" "while"))) "volatile" "while")))
(if (eq mode 'cpp) (if (eq mode 'cpp)
(append c-keywords (append c-keywords
@ -188,6 +188,10 @@ MODE is either `c' or `cpp'."
"xor" "xor_eq")) "xor" "xor_eq"))
(append '("auto") c-keywords)))) (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 (defvar c-ts-mode--operators
'("=" "-" "*" "/" "+" "%" "~" "|" "&" "^" "<<" ">>" "->" '("=" "-" "*" "/" "+" "%" "~" "|" "&" "^" "<<" ">>" "->"
"." "<" "<=" ">=" ">" "==" "!=" "!" "&&" "||" "-=" "." "<" "<=" ">=" ">" "==" "!=" "!" "&&" "||" "-="
@ -263,7 +267,8 @@ MODE is either `c' or `cpp'."
(qualified_identifier (qualified_identifier
scope: (namespace_identifier) @font-lock-type-face) 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 :language mode
:feature 'definition :feature 'definition