aboutsummaryrefslogtreecommitdiffstats
path: root/queries/c/highlights.scm
diff options
context:
space:
mode:
Diffstat (limited to 'queries/c/highlights.scm')
-rw-r--r--queries/c/highlights.scm129
1 files changed, 86 insertions, 43 deletions
diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm
index 0a6145e3e..c848f68dc 100644
--- a/queries/c/highlights.scm
+++ b/queries/c/highlights.scm
@@ -1,6 +1,9 @@
; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration.
-((identifier) @variable (#set! "priority" 95))
-(preproc_def (preproc_arg) @variable)
+((identifier) @variable
+ (#set! "priority" 95))
+
+(preproc_def
+ (preproc_arg) @variable)
[
"default"
@@ -17,7 +20,10 @@
"sizeof"
"offsetof"
] @keyword.operator
-(alignof_expression . _ @keyword.operator)
+
+(alignof_expression
+ .
+ _ @keyword.operator)
"return" @keyword.return
@@ -30,10 +36,10 @@
] @keyword.repeat
[
- "if"
- "else"
- "case"
- "switch"
+ "if"
+ "else"
+ "case"
+ "switch"
] @keyword.conditional
[
@@ -52,42 +58,48 @@
"#include" @keyword.import
-[ ";" ":" "," "::" ] @punctuation.delimiter
+[
+ ";"
+ ":"
+ ","
+ "::"
+] @punctuation.delimiter
"..." @punctuation.special
-[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
[
"="
-
"-"
"*"
"/"
"+"
"%"
-
"~"
"|"
"&"
"^"
"<<"
">>"
-
"->"
"."
-
"<"
"<="
">="
">"
"=="
"!="
-
"!"
"&&"
"||"
-
"-="
"+="
"*="
@@ -102,42 +114,54 @@
"++"
] @operator
-;; Make sure the comma operator is given a highlight group after the comma
-;; punctuator so the operator is highlighted properly.
-(comma_expression [ "," ] @operator)
+; Make sure the comma operator is given a highlight group after the comma
+; punctuator so the operator is highlighted properly.
+(comma_expression
+ "," @operator)
[
(true)
(false)
] @boolean
-(conditional_expression [ "?" ":" ] @keyword.conditional.ternary)
+(conditional_expression
+ [
+ "?"
+ ":"
+ ] @keyword.conditional.ternary)
(string_literal) @string
+
(system_lib_string) @string
+
(escape_sequence) @string.escape
(null) @constant.builtin
+
(number_literal) @number
+
(char_literal) @character
-((preproc_arg) @function.macro (#set! "priority" 90))
+((preproc_arg) @function.macro
+ (#set! "priority" 90))
+
(preproc_defined) @function.macro
((field_expression
- (field_identifier) @property) @_parent
- (#not-has-parent? @_parent template_method function_declarator call_expression))
+ (field_identifier) @property) @_parent
+ (#not-has-parent? @_parent template_method function_declarator call_expression))
(field_designator) @property
+
((field_identifier) @property
- (#has-ancestor? @property field_declaration)
- (#not-has-ancestor? @property function_declarator))
+ (#has-ancestor? @property field_declaration)
+ (#not-has-ancestor? @property function_declarator))
(statement_identifier) @label
[
- (type_identifier)
- (type_descriptor)
+ (type_identifier)
+ (type_descriptor)
] @type
(storage_class_specifier) @keyword.storage
@@ -156,14 +180,20 @@
(primitive_type) @type.builtin
-(sized_type_specifier _ @type.builtin type: _?)
+(sized_type_specifier
+ _ @type.builtin
+ type: _?)
((identifier) @constant
- (#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
-(preproc_def (preproc_arg) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
+
+(preproc_def
+ (preproc_arg) @constant
+ (#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
+
(enumerator
name: (identifier) @constant)
+
(case_statement
value: (identifier) @constant)
@@ -181,7 +211,9 @@
"__clang_wide_literal_encoding__"
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
"__VA_ARGS__" "__VA_OPT__"))
-(preproc_def (preproc_arg) @constant.builtin
+
+(preproc_def
+ (preproc_arg) @constant.builtin
; format-ignore
(#any-of? @constant.builtin
"stderr" "stdin" "stdout"
@@ -197,21 +229,26 @@
"__VA_ARGS__" "__VA_OPT__"))
(attribute_specifier
- (argument_list (identifier) @variable.builtin))
+ (argument_list
+ (identifier) @variable.builtin))
+
((attribute_specifier
- (argument_list (call_expression
- function: (identifier) @variable.builtin))))
+ (argument_list
+ (call_expression
+ function: (identifier) @variable.builtin))))
((call_expression
function: (identifier) @function.builtin)
(#lua-match? @function.builtin "^__builtin_"))
+
((call_expression
- function: (identifier) @function.builtin)
+ function: (identifier) @function.builtin)
(#has-ancestor? @function.builtin attribute_specifier))
-;; Preproc def / undef
+; Preproc def / undef
(preproc_def
name: (_) @constant)
+
(preproc_call
directive: (preproc_directive) @_u
argument: (_) @constant
@@ -219,15 +256,21 @@
(call_expression
function: (identifier) @function.call)
+
(call_expression
- function: (field_expression
- field: (field_identifier) @function.call))
+ function:
+ (field_expression
+ field: (field_identifier) @function.call))
+
(function_declarator
declarator: (identifier) @function)
+
(function_declarator
- declarator: (parenthesized_declarator
- (pointer_declarator
- declarator: (field_identifier) @function)))
+ declarator:
+ (parenthesized_declarator
+ (pointer_declarator
+ declarator: (field_identifier) @function)))
+
(preproc_function_def
name: (identifier) @function.macro)
@@ -236,7 +279,7 @@
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
-;; Parameters
+; Parameters
(parameter_declaration
declarator: (identifier) @variable.parameter)
@@ -268,8 +311,8 @@
; declarator: _
; (declaration
; declarator: (pointer_declarator) @variable.parameter))
-
-(preproc_params (identifier) @variable.parameter)
+(preproc_params
+ (identifier) @variable.parameter)
[
"__attribute__"