Improve C# syntax highlighting (#4118)

pull/4222/head
Chickenkeeper 2 years ago committed by GitHub
parent d27551d814
commit 8e8ba06f60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -235,7 +235,7 @@ language-server = { command = "OmniSharp", args = [ "--languageserver" ] }
[[grammar]] [[grammar]]
name = "c-sharp" name = "c-sharp"
source = { git = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "9c494a503c8e2044bfffce57f70b480c01a82f03" } source = { git = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "5b60f99545fea00a33bbfae5be956f684c4c69e2" }
[[language]] [[language]]
name = "go" name = "go"

@ -9,10 +9,6 @@
(member_access_expression (member_access_expression
name: (identifier) @function)) name: (identifier) @function))
(invocation_expression
(member_access_expression
expression: (identifier) @variable))
(invocation_expression (invocation_expression
function: (conditional_access_expression function: (conditional_access_expression
(member_binding_expression (member_binding_expression
@ -21,13 +17,15 @@
(invocation_expression (invocation_expression
[(identifier) (qualified_name)] @function) [(identifier) (qualified_name)] @function)
(local_function_statement
name: (identifier) @function)
; Generic Method invocation with generic type ; Generic Method invocation with generic type
(invocation_expression (invocation_expression
function: (generic_name function: (generic_name
. (identifier) @function)) . (identifier) @function))
;; Namespaces ;; Namespaces
(namespace_declaration (namespace_declaration
name: [(identifier) (qualified_name)] @namespace) name: [(identifier) (qualified_name)] @namespace)
@ -40,8 +38,11 @@
(namespace_declaration name: (identifier) @type) (namespace_declaration name: (identifier) @type)
(using_directive (_) @namespace) (using_directive (_) @namespace)
(constructor_declaration name: (identifier) @type) (constructor_declaration name: (identifier) @type)
(destructor_declaration name: (identifier) @type)
(object_creation_expression [(identifier) (qualified_name)] @type) (object_creation_expression [(identifier) (qualified_name)] @type)
(type_parameter_list (type_parameter) @type) (type_parameter_list (type_parameter) @type)
(array_type (identifier) @type)
(for_each_statement type: (identifier) @type)
[ [
(implicit_type) (implicit_type)
@ -91,6 +92,7 @@
(verbatim_string_literal) (verbatim_string_literal)
(interpolated_string_text) (interpolated_string_text)
(interpolated_verbatim_string_text) (interpolated_verbatim_string_text)
(interpolation_format_clause)
"\"" "\""
"$\"" "$\""
"@$\"" "@$\""
@ -150,6 +152,7 @@
"%" "%"
"%=" "%="
":" ":"
"::"
".." ".."
"&=" "&="
"->" "->"
@ -166,50 +169,27 @@
] @punctuation.bracket ] @punctuation.bracket
;; Keywords ;; Keywords
(modifier) @keyword (modifier) @keyword.storage.modifier
(this_expression) @keyword (this_expression) @keyword
(escape_sequence) @constant.character.escape (escape_sequence) @constant.character.escape
[ [
"as" "as"
"base" "base"
"break"
"case"
"catch" "catch"
"checked" "checked"
"class"
"continue"
"default"
"delegate"
"do"
"else"
"enum"
"event"
"explicit"
"finally" "finally"
"for"
"foreach"
"goto"
"if"
"implicit"
"interface"
"is" "is"
"lock" "lock"
"namespace"
"operator" "operator"
"params" "params"
"return"
"sizeof" "sizeof"
"stackalloc" "stackalloc"
"static"
"struct"
"switch"
"throw" "throw"
"try" "try"
"typeof" "typeof"
"unchecked" "unchecked"
"using" "using"
"while"
"new" "new"
"await" "await"
"in" "in"
@ -222,25 +202,63 @@
"from" "from"
"where" "where"
"select" "select"
"record"
"init" "init"
"with" "with"
"let" "let"
] @keyword ] @keyword
(nullable_directive) @keyword.directive [
(define_directive) @keyword.directive "class"
(undef_directive) @keyword.directive "delegate"
(if_directive) @keyword.directive "enum"
(else_directive) @keyword.directive "event"
(elif_directive) @keyword.directive "interface"
(endif_directive) @keyword.directive "namespace"
(region_directive) @keyword.directive "struct"
(endregion_directive) @keyword.directive "record"
(error_directive) @keyword.directive ] @keyword.storage.type
(warning_directive) @keyword.directive
(line_directive) @keyword.directive [
(pragma_directive) @keyword.directive "explicit"
"implicit"
"static"
] @keyword.storage.modifier
[
"for"
"foreach"
"do"
"while"
"break"
"continue"
] @keyword.control.repeat
[
"goto"
"if"
"else"
"switch"
"case"
"default"
] @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 ;; Linq
(from_clause (identifier) @variable) (from_clause (identifier) @variable)
@ -259,10 +277,16 @@
(binary_expression [(identifier) (qualified_name)] @variable [(identifier) (qualified_name)] @variable) (binary_expression [(identifier) (qualified_name)] @variable [(identifier) (qualified_name)] @variable)
(binary_expression [(identifier) (qualified_name)]* @variable) (binary_expression [(identifier) (qualified_name)]* @variable)
(conditional_expression [(identifier) (qualified_name)] @variable) (conditional_expression [(identifier) (qualified_name)] @variable)
(conditional_access_expression [(identifier) (qualified_name)] @variable)
(prefix_unary_expression [(identifier) (qualified_name)] @variable) (prefix_unary_expression [(identifier) (qualified_name)] @variable)
(postfix_unary_expression [(identifier) (qualified_name)]* @variable) (postfix_unary_expression [(identifier) (qualified_name)]* @variable)
(assignment_expression [(identifier) (qualified_name)] @variable) (assignment_expression [(identifier) (qualified_name)] @variable)
(cast_expression [(identifier) (qualified_name)] @type [(identifier) (qualified_name)] @variable) (cast_expression [(identifier) (qualified_name)] @type [(identifier) (qualified_name)] @variable)
(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 ;; Class
(base_list (identifier) @type) (base_list (identifier) @type)
@ -278,7 +302,6 @@
name: (identifier) @variable) name: (identifier) @variable)
;; Delegate ;; Delegate
(delegate_declaration (identifier) @type) (delegate_declaration (identifier) @type)
;; Lambda ;; Lambda
@ -315,7 +338,7 @@
;; Type ;; Type
(generic_name (identifier) @type) (generic_name (identifier) @type)
(type_parameter [(identifier) (qualified_name)] @variable.parameter) (type_parameter [(identifier) (qualified_name)] @type)
(type_argument_list [(identifier) (qualified_name)] @type) (type_argument_list [(identifier) (qualified_name)] @type)
;; Type constraints ;; Type constraints
@ -333,15 +356,21 @@
;; Lock statement ;; Lock statement
(lock_statement (identifier) @variable) (lock_statement (identifier) @variable)
;; Declaration expression
(declaration_expression
type: (identifier) @type
name: (identifier) @variable)
;; Rest ;; Rest
(member_access_expression) @variable
(element_access_expression (identifier) @variable)
(argument (identifier) @variable) (argument (identifier) @variable)
(name_colon (identifier) @variable)
(if_statement (identifier) @variable)
(for_statement (identifier) @variable) (for_statement (identifier) @variable)
(for_each_statement (identifier) @variable) (for_each_statement (identifier) @variable)
(expression_statement (identifier) @variable) (expression_statement (identifier) @variable)
(member_access_expression expression: (identifier) @variable) (array_rank_specifier (identifier) @variable)
(member_access_expression name: (identifier) @variable) (equals_value_clause (identifier) @variable)
(conditional_access_expression [(identifier) (qualified_name)] @variable) (interpolation (identifier) @variable)
(cast_expression (identifier) @variable)
((identifier) @comment.unused ((identifier) @comment.unused
(#eq? @comment.unused "_")) (#eq? @comment.unused "_"))

Loading…
Cancel
Save