c/c++ highlighting: various tweaks

- treat `restrict`/`_Atomic` like `const`/`volatile` => @keyword.storage.modifier
- highlight `unsigned int` as builtin => @type.builtin
- recognize `static_cast` and friends => @keyword
- `template` is a kind of entity like `typename` => @keyword.storage.type
- many declaration modifiers have nothing to do with storage/types
  (explicit, friend, access specifiers, inline in C++) => @keyword
- fix floats highlighted as integer => @constant.numeric
pull/1/head
Sam McCall 2 years ago committed by Michael Davis
parent a3ed9169df
commit aef37d43d7

@ -8,11 +8,9 @@
] @keyword.storage.type ] @keyword.storage.type
[ [
"const"
"extern" "extern"
"inline"
"register" "register"
"volatile" (type_qualifier)
(storage_class_specifier) (storage_class_specifier)
] @keyword.storage.modifier ] @keyword.storage.modifier
@ -107,7 +105,7 @@
(system_lib_string) @string (system_lib_string) @string
(null) @constant (null) @constant
(number_literal) @constant.numeric.integer (number_literal) @constant.numeric
(char_literal) @constant.character (char_literal) @constant.character
(call_expression (call_expression
@ -133,7 +131,7 @@
(statement_identifier) @label (statement_identifier) @label
(type_identifier) @type (type_identifier) @type
(primitive_type) @type.builtin (primitive_type) @type.builtin
(sized_type_specifier) @type (sized_type_specifier) @type.builtin
((identifier) @constant ((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$")) (#match? @constant "^[A-Z][A-Z\\d_]*$"))

@ -1,5 +1,11 @@
; Functions ; Functions
; These casts are parsed as function calls, but are not.
((identifier) @keyword (#eq? @keyword "static_cast"))
((identifier) @keyword (#eq? @keyword "dynamic_cast"))
((identifier) @keyword (#eq? @keyword "reinterpret_cast"))
((identifier) @keyword (#eq? @keyword "const_cast"))
(call_expression (call_expression
function: (qualified_identifier function: (qualified_identifier
name: (identifier) @function)) name: (identifier) @function))
@ -63,7 +69,6 @@
"co_yield" "co_yield"
"concept" "concept"
"delete" "delete"
"final"
"new" "new"
"operator" "operator"
"requires" "requires"
@ -95,22 +100,27 @@
"class" "class"
"namespace" "namespace"
"typename" "typename"
"template"
] @keyword.storage.type ] @keyword.storage.type
[ [
"constexpr" "constexpr"
"constinit" "constinit"
"consteval" "consteval"
"mutable"
] @keyword.storage.modifier
; Modifiers that aren't plausibly type/storage related.
[
"explicit" "explicit"
"friend" "friend"
"mutable" "virtual"
(virtual_specifier) ; override/final
"private" "private"
"protected" "protected"
"public" "public"
"override" "inline" ; C++ meaning differs from C!
"template" ] @keyword
"virtual"
] @keyword.storage.modifier
; Strings ; Strings

Loading…
Cancel
Save