diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm index 2cb05217..5101df0c 100644 --- a/runtime/queries/c/highlights.scm +++ b/runtime/queries/c/highlights.scm @@ -3,7 +3,14 @@ ((identifier) @constant (#match? @constant "^[A-Z][A-Z\\d_]*$")) -"sizeof" @keyword +[ + "sizeof" + "offsetof" + "alignof" + "_Alignof" + "asm" + "__asm__" +] @keyword [ "enum" @@ -48,6 +55,8 @@ "#if" "#ifdef" "#ifndef" + "#elifdef" + "#elifndef" "#include" (preproc_directive) ] @keyword.directive @@ -119,6 +128,10 @@ (primitive_type) @type.builtin (sized_type_specifier) @type.builtin +; `typedef ... Name;` — the introduced name +(type_definition + declarator: (type_identifier) @type.definition) + (call_expression function: (identifier) @function) (call_expression @@ -128,6 +141,11 @@ (function_declarator declarator: [(identifier) (field_identifier)] @function) +; GCC builtins, e.g. __builtin_expect +((call_expression + function: (identifier) @function.builtin) + (#match? @function.builtin "^__builtin_")) + ; Up to 6 layers of declarators (parameter_declaration declarator: (identifier) @variable.parameter) @@ -163,4 +181,26 @@ (attribute name: (identifier) @attribute) +; GNU / MSVC attributes and calling conventions +[ + "__attribute__" + "__declspec" + "__based" + "__cdecl" + "__clrcall" + "__stdcall" + "__fastcall" + "__thiscall" + "__vectorcall" +] @attribute + +; Builtin/predefined constants and macros. +((identifier) @constant.builtin + (#any-of? @constant.builtin + "stderr" "stdin" "stdout" + "__FILE__" "__LINE__" "__DATE__" "__TIME__" "__func__" + "__FUNCTION__" "__PRETTY_FUNCTION__" "__BASE_FILE__" + "__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__" + "__VA_ARGS__" "__VA_OPT__" "__cplusplus")) + (comment) @comment diff --git a/runtime/queries/c/tags.scm b/runtime/queries/c/tags.scm index 6ab7cbe1..13da6fe5 100644 --- a/runtime/queries/c/tags.scm +++ b/runtime/queries/c/tags.scm @@ -13,3 +13,6 @@ (enum_specifier name: (type_identifier) @definition.enum) + +(union_specifier + name: (type_identifier) @definition.struct) diff --git a/runtime/queries/cpp/highlights.scm b/runtime/queries/cpp/highlights.scm index 03050860..710ba2f1 100644 --- a/runtime/queries/cpp/highlights.scm +++ b/runtime/queries/cpp/highlights.scm @@ -13,6 +13,10 @@ (namespace_definition name: (namespace_identifier) @namespace) (namespace_identifier) @namespace +; Type-introducing declarations +(concept_definition name: (identifier) @type.definition) +(alias_declaration name: (type_identifier) @type.definition) + (auto) @type.builtin (ref_qualifier ["&" "&&"] @type.builtin) diff --git a/runtime/queries/cpp/tags.scm b/runtime/queries/cpp/tags.scm index 44b01bd2..880d9389 100644 --- a/runtime/queries/cpp/tags.scm +++ b/runtime/queries/cpp/tags.scm @@ -6,3 +6,12 @@ (class_specifier name: (type_identifier) @definition.class body: (field_declaration_list)) + +(namespace_definition + name: (namespace_identifier) @definition.module) + +(concept_definition + name: (identifier) @definition.interface) + +(alias_declaration + name: (type_identifier) @definition.type)