helix-mods/runtime/queries/c-sharp/highlights.scm

379 lines
7.2 KiB
Scheme
Raw Normal View History

;; Methods
2022-03-12 19:06:56 +01:00
(method_declaration
name: (identifier) @function)
(method_declaration
type: [(identifier) (qualified_name)] @type)
(invocation_expression
(member_access_expression
name: (identifier) @function))
(invocation_expression
function: (conditional_access_expression
(member_binding_expression
name: (identifier) @function)))
(invocation_expression
2022-10-10 19:07:14 +02:00
[(identifier) (qualified_name)] @function)
(local_function_statement
name: (identifier) @function)
2022-03-12 19:06:56 +01:00
; Generic Method invocation with generic type
(invocation_expression
function: (generic_name
2022-10-10 19:07:14 +02:00
. (identifier) @function))
2022-03-12 19:06:56 +01:00
;; Namespaces
(namespace_declaration
name: [(identifier) (qualified_name)] @namespace)
;; Types
(interface_declaration name: (identifier) @type)
(class_declaration name: (identifier) @type)
(enum_declaration name: (identifier) @type)
(struct_declaration (identifier) @type)
(record_declaration (identifier) @type)
(namespace_declaration name: (identifier) @type)
2022-03-12 19:06:56 +01:00
(using_directive (_) @namespace)
(constructor_declaration name: (identifier) @type)
2022-10-10 19:07:14 +02:00
(destructor_declaration name: (identifier) @type)
2022-03-12 19:06:56 +01:00
(object_creation_expression [(identifier) (qualified_name)] @type)
(type_parameter_list (type_parameter) @type)
2022-10-10 19:07:14 +02:00
(array_type (identifier) @type)
(for_each_statement type: (identifier) @type)
[
(implicit_type)
(nullable_type)
(pointer_type)
(function_pointer_type)
(predefined_type)
] @type.builtin
2022-03-12 19:06:56 +01:00
;; Generic Types
(type_of_expression
(generic_name
(identifier) @type))
(base_list
(generic_name
(identifier) @type))
(type_constraint
(generic_name
(identifier) @type))
(object_creation_expression
(generic_name
2022-10-10 19:07:14 +02:00
(identifier) @type))
2022-03-12 19:06:56 +01:00
(property_declaration
(generic_name
(identifier) @type))
(_
type: (generic_name
2022-10-10 19:07:14 +02:00
(identifier) @type))
2022-03-12 19:06:56 +01:00
;; Enum
(enum_member_declaration (identifier) @variable.other.member)
;; Literals
[
(real_literal)
(integer_literal)
] @constant.numeric.integer
(character_literal) @constant.character
[
(string_literal)
(verbatim_string_literal)
(interpolated_string_text)
(interpolated_verbatim_string_text)
2022-10-10 19:07:14 +02:00
(interpolation_format_clause)
"\""
"$\""
"@$\""
"$@\""
] @string
(boolean_literal) @constant.builtin.boolean
[
(null_literal)
(void_keyword)
] @constant.builtin
;; Comments
(comment) @comment
;; Tokens
2022-10-15 18:29:50 +02:00
(type_argument_list ["<" ">"] @punctuation.bracket)
(type_parameter_list ["<" ">"] @punctuation.bracket)
[
";"
"."
","
] @punctuation.delimiter
[
"--"
"-"
"-="
"&"
"&&"
"+"
"++"
"+="
"<"
2022-03-12 19:06:56 +01:00
"<="
"<<"
2022-03-12 19:06:56 +01:00
"<<="
"="
"=="
"!"
"!="
"=>"
">"
2022-03-12 19:06:56 +01:00
">="
">>"
2022-03-12 19:06:56 +01:00
">>="
"|"
"||"
2022-03-12 19:06:56 +01:00
"|="
"?"
"??"
"^"
2022-03-12 19:06:56 +01:00
"^="
"~"
"*"
2022-03-12 19:06:56 +01:00
"*="
"/"
2022-03-12 19:06:56 +01:00
"/="
"%"
2022-03-12 19:06:56 +01:00
"%="
":"
2022-10-10 19:07:14 +02:00
"::"
2022-03-12 19:06:56 +01:00
".."
"&="
"->"
"??="
] @operator
2022-10-15 18:29:50 +02:00
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
;; Keywords
2022-10-10 19:07:14 +02:00
(modifier) @keyword.storage.modifier
(this_expression) @keyword
(escape_sequence) @constant.character.escape
[
"as"
2022-10-15 18:29:50 +02:00
"await"
"base"
"checked"
2022-10-15 18:29:50 +02:00
"from"
"get"
"in"
"init"
"is"
2022-10-15 18:29:50 +02:00
"let"
"lock"
2022-10-15 18:29:50 +02:00
"new"
"operator"
2022-10-15 18:29:50 +02:00
"out"
"params"
2022-10-15 18:29:50 +02:00
"ref"
"select"
"set"
"sizeof"
"stackalloc"
"typeof"
"unchecked"
"using"
"when"
"where"
"with"
2022-10-15 18:29:50 +02:00
"yield"
] @keyword
2022-10-10 19:07:14 +02:00
[
"class"
"delegate"
"enum"
"event"
"interface"
"namespace"
"struct"
"record"
] @keyword.storage.type
[
"explicit"
"implicit"
"static"
] @keyword.storage.modifier
[
2022-10-15 18:29:50 +02:00
"break"
"continue"
"goto"
] @keyword.control
[
"catch"
"finally"
"throw"
"try"
] @keyword.control.exception
[
"do"
2022-10-10 19:07:14 +02:00
"for"
"foreach"
"while"
] @keyword.control.repeat
[
"case"
"default"
2022-10-15 18:29:50 +02:00
"else"
"if"
"switch"
2022-10-10 19:07:14 +02:00
] @keyword.control.conditional
"return" @keyword.control.return
[
(nullable_directive)
(define_directive)
(undef_directive)
(if_directive)
(else_directive)
(elif_directive)
(endif_directive)
(region_directive)
(endregion_directive)
(error_directive)
(warning_directive)
(line_directive)
(pragma_directive)
] @keyword.directive
;; Linq
(from_clause (identifier) @variable)
(group_clause)
(order_by_clause)
(select_clause (identifier) @variable)
(query_continuation (identifier) @variable) @keyword
;; Record
(with_expression
(with_initializer_expression
(simple_assignment_expression
(identifier) @variable)))
;; Exprs
2022-03-12 19:06:56 +01:00
(binary_expression [(identifier) (qualified_name)] @variable [(identifier) (qualified_name)] @variable)
(binary_expression [(identifier) (qualified_name)]* @variable)
(conditional_expression [(identifier) (qualified_name)] @variable)
2022-10-10 19:07:14 +02:00
(conditional_access_expression [(identifier) (qualified_name)] @variable)
2022-03-12 19:06:56 +01:00
(prefix_unary_expression [(identifier) (qualified_name)] @variable)
(postfix_unary_expression [(identifier) (qualified_name)]* @variable)
(assignment_expression [(identifier) (qualified_name)] @variable)
(cast_expression [(identifier) (qualified_name)] @type [(identifier) (qualified_name)] @variable)
2022-10-10 19:07:14 +02:00
(element_access_expression (identifier) @variable)
(member_access_expression
expression: ([(identifier) (qualified_name)] @type
(#match? @type "^[A-Z]")))
(member_access_expression [(identifier) (qualified_name)] @variable)
;; Class
(base_list (identifier) @type)
(property_declaration (generic_name))
(property_declaration
type: (nullable_type) @type
name: (identifier) @variable)
(property_declaration
type: (predefined_type) @type
name: (identifier) @variable)
(property_declaration
type: (identifier) @type
name: (identifier) @variable)
2022-03-12 19:06:56 +01:00
;; Delegate
(delegate_declaration (identifier) @type)
;; Lambda
(lambda_expression) @variable
;; Attribute
(attribute) @type
;; Parameter
(parameter
type: (identifier) @type
name: (identifier) @variable.parameter)
(parameter (identifier) @variable.parameter)
(parameter_modifier) @keyword
2022-03-12 19:06:56 +01:00
(parameter_list
(parameter
2022-10-10 19:07:14 +02:00
name: (identifier) @parameter))
2022-03-12 19:06:56 +01:00
(parameter_list
(parameter
2022-10-10 19:07:14 +02:00
type: [(identifier) (qualified_name)] @type))
2022-03-12 19:06:56 +01:00
;; Typeof
2022-03-12 19:06:56 +01:00
(type_of_expression [(identifier) (qualified_name)] @type)
;; Variable
2022-03-12 19:06:56 +01:00
(variable_declaration [(identifier) (qualified_name)] @type)
(variable_declarator [(identifier) (qualified_name)] @variable)
;; Return
(return_statement (identifier) @variable)
(yield_statement (identifier) @variable)
;; Type
(generic_name (identifier) @type)
2022-10-10 19:07:14 +02:00
(type_parameter [(identifier) (qualified_name)] @type)
2022-03-12 19:06:56 +01:00
(type_argument_list [(identifier) (qualified_name)] @type)
;; Type constraints
(type_parameter_constraints_clause (identifier) @variable.parameter)
(type_constraint (identifier) @type)
;; Exception
(catch_declaration (identifier) @type (identifier) @variable)
(catch_declaration (identifier) @type)
;; Switch
(switch_statement (identifier) @variable)
(switch_expression (identifier) @variable)
;; Lock statement
(lock_statement (identifier) @variable)
2022-03-12 19:06:56 +01:00
2022-10-10 19:07:14 +02:00
;; Declaration expression
(declaration_expression
type: (identifier) @type
name: (identifier) @variable)
2022-03-12 19:06:56 +01:00
;; Rest
(argument (identifier) @variable)
2022-10-10 19:07:14 +02:00
(name_colon (identifier) @variable)
(if_statement (identifier) @variable)
2022-03-12 19:06:56 +01:00
(for_statement (identifier) @variable)
(for_each_statement (identifier) @variable)
(expression_statement (identifier) @variable)
2022-10-10 19:07:14 +02:00
(array_rank_specifier (identifier) @variable)
(equals_value_clause (identifier) @variable)
(interpolation (identifier) @variable)
(cast_expression (identifier) @variable)
2022-03-12 19:06:56 +01:00
((identifier) @comment.unused
2022-10-10 19:07:14 +02:00
(#eq? @comment.unused "_"))