nvim-treesitter/queries/c/highlights.scm

211 lines
3.3 KiB
Scheme
Raw Normal View History

; Lower priority to prefer @parameter when identifier appears in parameter_declaration.
((identifier) @variable (#set! "priority" 95))
2020-08-15 09:24:24 -05:00
[
"default"
"enum"
"struct"
"typedef"
"union"
"goto"
] @keyword
"sizeof" @keyword.operator
"return" @keyword.return
2020-07-06 23:01:46 +02:00
[
"while"
"for"
"do"
"continue"
"break"
] @repeat
[
"if"
"else"
"case"
2020-07-06 23:01:46 +02:00
"switch"
] @conditional
2020-06-27 21:06:11 +02:00
[
"#if"
"#ifdef"
"#ifndef"
"#else"
"#elif"
"#endif"
(preproc_directive)
] @preproc
"#define" @define
"#include" @include
[ ";" ":" "," ] @punctuation.delimiter
"..." @punctuation.special
[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
[
2020-07-06 23:01:46 +02:00
"="
"-"
"*"
"/"
"+"
2020-07-20 08:56:27 +02:00
"%"
2020-07-06 23:01:46 +02:00
"~"
"|"
"&"
2020-08-27 01:17:44 +02:00
"^"
2020-07-06 23:01:46 +02:00
"<<"
">>"
"->"
"."
2020-07-06 23:01:46 +02:00
"<"
"<="
">="
2020-07-06 23:01:46 +02:00
">"
"=="
"!="
"!"
2020-07-06 23:01:46 +02:00
"&&"
"||"
"-="
"+="
"*="
"/="
2020-07-20 08:56:27 +02:00
"%="
"|="
"&="
2020-08-27 01:17:44 +02:00
"^="
">>="
"<<="
2020-07-06 23:01:46 +02:00
"--"
"++"
] @operator
;; Make sure the comma operator is given a highlight group after the comma
;; punctuator so the operator is highlighted properly.
(comma_expression [ "," ] @operator)
2020-07-06 23:01:46 +02:00
[
(true)
(false)
] @boolean
(conditional_expression [ "?" ":" ] @conditional.ternary)
2020-07-06 23:01:46 +02:00
(string_literal) @string
(system_lib_string) @string
(escape_sequence) @string.escape
(null) @constant.builtin
(number_literal) @number
(char_literal) @character
[
(preproc_arg)
(preproc_defined)
] @function.macro
(((field_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))
(statement_identifier) @label
2020-07-06 23:01:46 +02:00
[
2021-09-17 01:01:28 +02:00
(type_identifier)
(type_descriptor)
] @type
2020-07-06 23:01:46 +02:00
(storage_class_specifier) @storageclass
(type_qualifier) @type.qualifier
(linkage_specification
"extern" @storageclass)
(type_definition
declarator: (type_identifier) @type.definition)
2020-05-23 21:02:43 +02:00
(primitive_type) @type.builtin
(sized_type_specifier _ @type.builtin type: _?)
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
(enumerator
name: (identifier) @constant)
(case_statement
value: (identifier) @constant)
((identifier) @constant.builtin
(#any-of? @constant.builtin "stderr" "stdin" "stdout"))
;; Preproc def / undef
(preproc_def
name: (_) @constant)
(preproc_call
directive: (preproc_directive) @_u
argument: (_) @constant
(#eq? @_u "#undef"))
(call_expression
function: (identifier) @function.call)
(call_expression
function: (field_expression
field: (field_identifier) @function.call))
(function_declarator
declarator: (identifier) @function)
(function_declarator
declarator: (parenthesized_declarator
(pointer_declarator
declarator: (field_identifier) @function)))
(preproc_function_def
name: (identifier) @function.macro)
2022-09-26 10:19:02 +01:00
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
2020-05-23 21:50:52 +02:00
;; Parameters
2020-08-15 09:24:24 -05:00
(parameter_declaration
declarator: (identifier) @parameter)
2020-05-23 21:50:52 +02:00
(parameter_declaration
declarator: (pointer_declarator) @parameter)
(preproc_params (identifier) @parameter)
[
"__attribute__"
"__cdecl"
"__clrcall"
"__stdcall"
"__fastcall"
"__thiscall"
"__vectorcall"
"_unaligned"
"__unaligned"
"__declspec"
(attribute_declaration)
] @attribute
(ERROR) @error