diff options
| -rw-r--r-- | CONTRIBUTING.md | 1 | ||||
| -rw-r--r-- | queries/c/highlights.scm | 77 | ||||
| -rw-r--r-- | queries/c/locals.scm | 36 |
3 files changed, 114 insertions, 0 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 46c7a9419..5335d04ea 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -92,6 +92,7 @@ are optional and will not have any effect for now. `var` `macro` `type` + `field` `@scope` diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm new file mode 100644 index 000000000..4cfb042cc --- /dev/null +++ b/queries/c/highlights.scm @@ -0,0 +1,77 @@ +"break" @keyword +"case" @conditional +"const" @keyword +"continue" @repeat +"default" @keyword +"do" @repeat +"else" @conditional +"enum" @keyword +"extern" @keyword +"for" @repeat +"if" @conditional +"inline" @keyword +"return" @keyword +"sizeof" @keyword +"static" @keyword +"struct" @keyword +"switch" @keyword +"typedef" @keyword +"union" @keyword +"volatile" @keyword +"while" @repeat + +"#define" @constant.macro +"#else" @keyword +"#endif" @keyword +"#if" @keyword +"#ifdef" @keyword +"#ifndef" @keyword +"#include" @keyword +(preproc_directive) @keyword + +"--" @operator +"-" @operator +"-=" @operator +"->" @operator +"!=" @operator +"*" @operator +"&" @operator +"&&" @operator +"+" @operator +"++" @operator +"+=" @operator +"<" @operator +"==" @operator +">" @operator +"||" @operator + +"." @delimiter +";" @delimiter + +(string_literal) @string +(system_lib_string) @string + +(null) @constant.builtin +(number_literal) @number +(char_literal) @number + +(call_expression + function: (identifier) @function) +(call_expression + function: (field_expression + field: (field_identifier) @function)) +(function_declarator + declarator: (identifier) @function) +(preproc_function_def + name: (identifier) @function.macro) + +(field_identifier) @property +(statement_identifier) @label +(type_identifier) @type +(primitive_type) @type +(sized_type_specifier) @type + +((identifier) @constant + (match? @constant "^[A-Z][A-Z\\d_]+$")) + +(comment) @comment diff --git a/queries/c/locals.scm b/queries/c/locals.scm new file mode 100644 index 000000000..159deca3a --- /dev/null +++ b/queries/c/locals.scm @@ -0,0 +1,36 @@ +;; Functions definitions +(function_declarator + declarator: (identifier) @definition.function) @scope +(preproc_function_def + name: (identifier) @definition.macro) @scope + +(preproc_def + name: (identifier) @definition.macro) +(pointer_declarator + declarator: (identifier) @definition.variable) +(parameter_declaration + declarator: (identifier) @definition.variable) +(init_declarator + declarator: (identifier) @definition.variable) +(array_declarator + declarator: (identifier) @definition.variable) +(declaration + declarator: (identifier) @definition.variable) +(enum_specifier + name: (*) @definition.type + (enumerator_list + (enumerator name: (identifier) @definition.variable))) + +;; Type / Struct / Enum +(field_declaration + declarator: (field_identifier) @definition.field) +(type_definition + declarator: (type_identifier) @definition.type) + +;; References +(identifier) @reference + +;; Scope +(for_statement) @scope +(if_statement) @scope +(while_statement) @scope |
