2024-01-17 08:55:52 -07:00
|
|
|
; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration.
|
|
|
|
((identifier) @variable
|
|
|
|
(#set! "priority" 95))
|
|
|
|
|
|
|
|
(preproc_def
|
|
|
|
(preproc_arg) @variable)
|
2020-10-06 00:09:28 -07:00
|
|
|
|
|
|
|
[
|
|
|
|
"default"
|
|
|
|
"enum"
|
|
|
|
"struct"
|
|
|
|
"typedef"
|
|
|
|
"union"
|
|
|
|
"goto"
|
2023-07-27 03:45:08 -07:00
|
|
|
"asm"
|
|
|
|
"__asm__"
|
2020-10-06 00:09:28 -07:00
|
|
|
] @keyword
|
|
|
|
|
2023-07-27 03:45:08 -07:00
|
|
|
[
|
|
|
|
"sizeof"
|
|
|
|
"offsetof"
|
|
|
|
] @keyword.operator
|
2024-01-17 08:55:52 -07:00
|
|
|
|
|
|
|
(alignof_expression
|
|
|
|
.
|
|
|
|
_ @keyword.operator)
|
2023-03-31 07:11:17 -07:00
|
|
|
|
|
|
|
"return" @keyword.return
|
|
|
|
|
2020-10-06 00:09:28 -07:00
|
|
|
[
|
|
|
|
"while"
|
|
|
|
"for"
|
|
|
|
"do"
|
|
|
|
"continue"
|
|
|
|
"break"
|
2024-01-17 08:55:52 -07:00
|
|
|
] @keyword.repeat
|
2020-10-06 00:09:28 -07:00
|
|
|
|
|
|
|
[
|
2024-01-17 08:55:52 -07:00
|
|
|
"if"
|
|
|
|
"else"
|
|
|
|
"case"
|
|
|
|
"switch"
|
|
|
|
] @keyword.conditional
|
2020-10-06 00:09:28 -07:00
|
|
|
|
|
|
|
[
|
|
|
|
"#if"
|
|
|
|
"#ifdef"
|
|
|
|
"#ifndef"
|
|
|
|
"#else"
|
|
|
|
"#elif"
|
|
|
|
"#endif"
|
2023-07-27 03:45:08 -07:00
|
|
|
"#elifdef"
|
|
|
|
"#elifndef"
|
2020-10-06 00:09:28 -07:00
|
|
|
(preproc_directive)
|
2024-01-17 08:55:52 -07:00
|
|
|
] @keyword.directive
|
2023-03-31 07:11:17 -07:00
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
"#define" @keyword.directive.define
|
2020-10-06 00:09:28 -07:00
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
"#include" @keyword.import
|
2020-10-06 00:09:28 -07:00
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
[
|
|
|
|
";"
|
|
|
|
":"
|
|
|
|
","
|
|
|
|
"::"
|
|
|
|
] @punctuation.delimiter
|
2023-03-31 07:11:17 -07:00
|
|
|
|
|
|
|
"..." @punctuation.special
|
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
[
|
|
|
|
"("
|
|
|
|
")"
|
|
|
|
"["
|
|
|
|
"]"
|
|
|
|
"{"
|
|
|
|
"}"
|
|
|
|
] @punctuation.bracket
|
2023-03-31 07:11:17 -07:00
|
|
|
|
2020-10-06 00:09:28 -07:00
|
|
|
[
|
|
|
|
"="
|
|
|
|
"-"
|
|
|
|
"*"
|
|
|
|
"/"
|
|
|
|
"+"
|
|
|
|
"%"
|
|
|
|
"~"
|
|
|
|
"|"
|
|
|
|
"&"
|
|
|
|
"^"
|
|
|
|
"<<"
|
|
|
|
">>"
|
|
|
|
"->"
|
2023-03-31 07:11:17 -07:00
|
|
|
"."
|
2020-10-06 00:09:28 -07:00
|
|
|
"<"
|
|
|
|
"<="
|
|
|
|
">="
|
|
|
|
">"
|
|
|
|
"=="
|
|
|
|
"!="
|
|
|
|
"!"
|
|
|
|
"&&"
|
|
|
|
"||"
|
|
|
|
"-="
|
|
|
|
"+="
|
|
|
|
"*="
|
|
|
|
"/="
|
|
|
|
"%="
|
|
|
|
"|="
|
|
|
|
"&="
|
|
|
|
"^="
|
2021-03-07 07:23:55 -07:00
|
|
|
">>="
|
|
|
|
"<<="
|
2020-10-06 00:09:28 -07:00
|
|
|
"--"
|
|
|
|
"++"
|
|
|
|
] @operator
|
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
; Make sure the comma operator is given a highlight group after the comma
|
|
|
|
; punctuator so the operator is highlighted properly.
|
|
|
|
(comma_expression
|
|
|
|
"," @operator)
|
2023-03-31 07:11:17 -07:00
|
|
|
|
2020-10-06 00:09:28 -07:00
|
|
|
[
|
2023-07-27 03:45:08 -07:00
|
|
|
(true)
|
|
|
|
(false)
|
2020-10-06 00:09:28 -07:00
|
|
|
] @boolean
|
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
(conditional_expression
|
|
|
|
[
|
|
|
|
"?"
|
|
|
|
":"
|
|
|
|
] @keyword.conditional.ternary)
|
2020-10-06 00:09:28 -07:00
|
|
|
|
|
|
|
(string_literal) @string
|
2024-01-17 08:55:52 -07:00
|
|
|
|
2020-10-06 00:09:28 -07:00
|
|
|
(system_lib_string) @string
|
2024-01-17 08:55:52 -07:00
|
|
|
|
2023-03-31 07:11:17 -07:00
|
|
|
(escape_sequence) @string.escape
|
2020-10-06 00:09:28 -07:00
|
|
|
|
|
|
|
(null) @constant.builtin
|
2024-01-17 08:55:52 -07:00
|
|
|
|
2020-10-06 00:09:28 -07:00
|
|
|
(number_literal) @number
|
2024-01-17 08:55:52 -07:00
|
|
|
|
2023-03-31 07:11:17 -07:00
|
|
|
(char_literal) @character
|
2020-10-06 00:09:28 -07:00
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
((preproc_arg) @function.macro
|
|
|
|
(#set! "priority" 90))
|
|
|
|
|
2023-07-27 03:45:08 -07:00
|
|
|
(preproc_defined) @function.macro
|
2020-10-06 00:09:28 -07:00
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
((field_expression
|
|
|
|
(field_identifier) @property) @_parent
|
|
|
|
(#not-has-parent? @_parent template_method function_declarator call_expression))
|
2023-05-13 03:56:21 -07:00
|
|
|
|
|
|
|
(field_designator) @property
|
2024-01-17 08:55:52 -07:00
|
|
|
|
|
|
|
((field_identifier) @property
|
|
|
|
(#has-ancestor? @property field_declaration)
|
|
|
|
(#not-has-ancestor? @property function_declarator))
|
2023-05-13 03:56:21 -07:00
|
|
|
|
2020-10-06 00:09:28 -07:00
|
|
|
(statement_identifier) @label
|
|
|
|
|
2024-03-17 05:07:57 -07:00
|
|
|
(declaration
|
|
|
|
type: (type_identifier) @_type
|
|
|
|
declarator: (identifier) @label
|
|
|
|
(#eq? @_type "__label__"))
|
|
|
|
|
2020-10-06 00:09:28 -07:00
|
|
|
[
|
2024-01-17 08:55:52 -07:00
|
|
|
(type_identifier)
|
|
|
|
(type_descriptor)
|
2023-03-31 07:11:17 -07:00
|
|
|
] @type
|
|
|
|
|
2024-03-17 05:07:57 -07:00
|
|
|
(storage_class_specifier) @keyword.modifier
|
2023-03-31 07:11:17 -07:00
|
|
|
|
2023-07-27 03:45:08 -07:00
|
|
|
[
|
2023-08-12 09:12:49 -07:00
|
|
|
(type_qualifier)
|
2023-07-27 03:45:08 -07:00
|
|
|
(gnu_asm_qualifier)
|
2023-08-12 09:12:49 -07:00
|
|
|
"__extension__"
|
2024-03-17 05:07:57 -07:00
|
|
|
] @keyword.modifier
|
2023-03-31 07:11:17 -07:00
|
|
|
|
|
|
|
(linkage_specification
|
2024-03-17 05:07:57 -07:00
|
|
|
"extern" @keyword.modifier)
|
2020-10-06 00:09:28 -07:00
|
|
|
|
2023-03-31 07:11:17 -07:00
|
|
|
(type_definition
|
|
|
|
declarator: (type_identifier) @type.definition)
|
|
|
|
|
|
|
|
(primitive_type) @type.builtin
|
2020-10-06 00:09:28 -07:00
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
(sized_type_specifier
|
|
|
|
_ @type.builtin
|
|
|
|
type: _?)
|
2023-05-13 03:56:21 -07:00
|
|
|
|
2020-10-06 00:09:28 -07:00
|
|
|
((identifier) @constant
|
2023-08-12 09:12:49 -07:00
|
|
|
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
|
2024-01-17 08:55:52 -07:00
|
|
|
|
|
|
|
(preproc_def
|
|
|
|
(preproc_arg) @constant
|
|
|
|
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
|
|
|
|
|
2023-03-31 07:11:17 -07:00
|
|
|
(enumerator
|
|
|
|
name: (identifier) @constant)
|
2024-01-17 08:55:52 -07:00
|
|
|
|
2023-03-31 07:11:17 -07:00
|
|
|
(case_statement
|
|
|
|
value: (identifier) @constant)
|
|
|
|
|
|
|
|
((identifier) @constant.builtin
|
2024-01-17 08:55:52 -07:00
|
|
|
; format-ignore
|
2023-08-12 09:12:49 -07:00
|
|
|
(#any-of? @constant.builtin
|
|
|
|
"stderr" "stdin" "stdout"
|
|
|
|
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
|
|
|
|
"__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__"
|
|
|
|
"__cplusplus" "__OBJC__" "__ASSEMBLER__"
|
|
|
|
"__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__"
|
|
|
|
"__TIMESTAMP__" "__clang__" "__clang_major__"
|
|
|
|
"__clang_minor__" "__clang_patchlevel__"
|
|
|
|
"__clang_version__" "__clang_literal_encoding__"
|
|
|
|
"__clang_wide_literal_encoding__"
|
|
|
|
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
|
|
|
|
"__VA_ARGS__" "__VA_OPT__"))
|
2024-01-17 08:55:52 -07:00
|
|
|
|
|
|
|
(preproc_def
|
|
|
|
(preproc_arg) @constant.builtin
|
|
|
|
; format-ignore
|
2023-08-12 09:12:49 -07:00
|
|
|
(#any-of? @constant.builtin
|
|
|
|
"stderr" "stdin" "stdout"
|
|
|
|
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
|
|
|
|
"__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__"
|
|
|
|
"__cplusplus" "__OBJC__" "__ASSEMBLER__"
|
|
|
|
"__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__"
|
|
|
|
"__TIMESTAMP__" "__clang__" "__clang_major__"
|
|
|
|
"__clang_minor__" "__clang_patchlevel__"
|
|
|
|
"__clang_version__" "__clang_literal_encoding__"
|
|
|
|
"__clang_wide_literal_encoding__"
|
|
|
|
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
|
|
|
|
"__VA_ARGS__" "__VA_OPT__"))
|
|
|
|
|
|
|
|
(attribute_specifier
|
2024-01-17 08:55:52 -07:00
|
|
|
(argument_list
|
|
|
|
(identifier) @variable.builtin))
|
|
|
|
|
2024-03-17 05:07:57 -07:00
|
|
|
(attribute_specifier
|
2024-01-17 08:55:52 -07:00
|
|
|
(argument_list
|
|
|
|
(call_expression
|
2024-03-17 05:07:57 -07:00
|
|
|
function: (identifier) @variable.builtin)))
|
2023-08-12 09:12:49 -07:00
|
|
|
|
|
|
|
((call_expression
|
|
|
|
function: (identifier) @function.builtin)
|
|
|
|
(#lua-match? @function.builtin "^__builtin_"))
|
2024-01-17 08:55:52 -07:00
|
|
|
|
2023-08-12 09:12:49 -07:00
|
|
|
((call_expression
|
2024-01-17 08:55:52 -07:00
|
|
|
function: (identifier) @function.builtin)
|
2023-08-12 09:12:49 -07:00
|
|
|
(#has-ancestor? @function.builtin attribute_specifier))
|
2020-10-06 00:09:28 -07:00
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
; Preproc def / undef
|
2021-03-07 07:23:55 -07:00
|
|
|
(preproc_def
|
|
|
|
name: (_) @constant)
|
2024-01-17 08:55:52 -07:00
|
|
|
|
2021-03-07 07:23:55 -07:00
|
|
|
(preproc_call
|
|
|
|
directive: (preproc_directive) @_u
|
|
|
|
argument: (_) @constant
|
|
|
|
(#eq? @_u "#undef"))
|
|
|
|
|
2023-03-31 07:11:17 -07:00
|
|
|
(call_expression
|
|
|
|
function: (identifier) @function.call)
|
2024-01-17 08:55:52 -07:00
|
|
|
|
2023-03-31 07:11:17 -07:00
|
|
|
(call_expression
|
2024-01-17 08:55:52 -07:00
|
|
|
function:
|
|
|
|
(field_expression
|
|
|
|
field: (field_identifier) @function.call))
|
|
|
|
|
2023-03-31 07:11:17 -07:00
|
|
|
(function_declarator
|
|
|
|
declarator: (identifier) @function)
|
2024-01-17 08:55:52 -07:00
|
|
|
|
2023-05-13 03:56:21 -07:00
|
|
|
(function_declarator
|
2024-01-17 08:55:52 -07:00
|
|
|
declarator:
|
|
|
|
(parenthesized_declarator
|
|
|
|
(pointer_declarator
|
|
|
|
declarator: (field_identifier) @function)))
|
|
|
|
|
2023-03-31 07:11:17 -07:00
|
|
|
(preproc_function_def
|
|
|
|
name: (identifier) @function.macro)
|
|
|
|
|
|
|
|
(comment) @comment @spell
|
2021-03-07 07:23:55 -07:00
|
|
|
|
2023-03-31 07:11:17 -07:00
|
|
|
((comment) @comment.documentation
|
|
|
|
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
2020-10-06 00:09:28 -07:00
|
|
|
|
2024-01-17 08:55:52 -07:00
|
|
|
; Parameters
|
2020-10-06 00:09:28 -07:00
|
|
|
(parameter_declaration
|
2024-01-17 08:55:52 -07:00
|
|
|
declarator: (identifier) @variable.parameter)
|
2020-10-06 00:09:28 -07:00
|
|
|
|
2023-08-12 09:12:49 -07:00
|
|
|
(parameter_declaration
|
2024-01-17 08:55:52 -07:00
|
|
|
declarator: (array_declarator) @variable.parameter)
|
2023-08-12 09:12:49 -07:00
|
|
|
|
2020-10-06 00:09:28 -07:00
|
|
|
(parameter_declaration
|
2024-01-17 08:55:52 -07:00
|
|
|
declarator: (pointer_declarator) @variable.parameter)
|
|
|
|
|
|
|
|
; K&R functions
|
|
|
|
; To enable support for K&R functions,
|
|
|
|
; add the following lines to your own query config and uncomment them.
|
|
|
|
; They are commented out as they'll conflict with C++
|
|
|
|
; Note that you'll need to have `; extends` at the top of your query file.
|
|
|
|
;
|
|
|
|
; (parameter_list (identifier) @variable.parameter)
|
|
|
|
;
|
|
|
|
; (function_definition
|
|
|
|
; declarator: _
|
|
|
|
; (declaration
|
|
|
|
; declarator: (identifier) @variable.parameter))
|
|
|
|
;
|
|
|
|
; (function_definition
|
|
|
|
; declarator: _
|
|
|
|
; (declaration
|
|
|
|
; declarator: (array_declarator) @variable.parameter))
|
|
|
|
;
|
|
|
|
; (function_definition
|
|
|
|
; declarator: _
|
|
|
|
; (declaration
|
|
|
|
; declarator: (pointer_declarator) @variable.parameter))
|
|
|
|
(preproc_params
|
|
|
|
(identifier) @variable.parameter)
|
2023-03-31 07:11:17 -07:00
|
|
|
|
|
|
|
[
|
|
|
|
"__attribute__"
|
2023-07-27 03:45:08 -07:00
|
|
|
"__declspec"
|
|
|
|
"__based"
|
2023-03-31 07:11:17 -07:00
|
|
|
"__cdecl"
|
|
|
|
"__clrcall"
|
|
|
|
"__stdcall"
|
|
|
|
"__fastcall"
|
|
|
|
"__thiscall"
|
|
|
|
"__vectorcall"
|
2023-07-27 03:45:08 -07:00
|
|
|
(ms_pointer_modifier)
|
2023-03-31 07:11:17 -07:00
|
|
|
(attribute_declaration)
|
|
|
|
] @attribute
|