Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c/c++ highlighting: various tweaks #4282

Merged
merged 1 commit into from
Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions runtime/queries/c/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
] @keyword.storage.type

[
"const"
"extern"
"inline"
"register"
"volatile"
(type_qualifier)
(storage_class_specifier)
] @keyword.storage.modifier

Expand Down Expand Up @@ -104,7 +102,7 @@
(system_lib_string) @string

(null) @constant
(number_literal) @constant.numeric.integer
(number_literal) @constant.numeric
(char_literal) @constant.character

(call_expression
Expand All @@ -130,7 +128,7 @@
(statement_identifier) @label
(type_identifier) @type
(primitive_type) @type.builtin
(sized_type_specifier) @type
(sized_type_specifier) @type.builtin

((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
Expand Down
22 changes: 16 additions & 6 deletions runtime/queries/cpp/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
; 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
function: (qualified_identifier
name: (identifier) @function))
Expand Down Expand Up @@ -59,7 +65,6 @@
"co_yield"
"concept"
"delete"
"final"
"new"
"operator"
"requires"
Expand Down Expand Up @@ -91,22 +96,27 @@
"class"
"namespace"
"typename"
"template"
] @keyword.storage.type

[
"constexpr"
"constinit"
"consteval"
"mutable"
] @keyword.storage.modifier

; Modifiers that aren't plausibly type/storage related.
[
"explicit"
"friend"
"mutable"
"virtual"
(virtual_specifier) ; override/final
"private"
"protected"
"public"
"override"
"template"
"virtual"
] @keyword.storage.modifier
"inline" ; C++ meaning differs from C!
] @keyword

; Strings

Expand Down