Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions languages/csharp/brackets.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
("(" @open ")" @close)
("[" @open "]" @close)
("{" @open "}" @close)
("<" @open ">" @close)
("\"" @open "\"" @close)
("(" @open
")" @close)

("[" @open
"]" @close)

("{" @open
"}" @close)

("<" @open
">" @close)

("\"" @open
"\"" @close)
115 changes: 71 additions & 44 deletions languages/csharp/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,42 +1,72 @@
(identifier) @variable

;; Methods
; Methods
(method_declaration
name: (identifier) @function)

(method_declaration name: (identifier) @function)
(_ function: (identifier) @function)
(local_function_statement name: (identifier) @function)
(_
function: (identifier) @function)

;; Types
(local_function_statement
name: (identifier) @function)

; Types
(interface_declaration
name: (identifier) @type)

(class_declaration
name: (identifier) @type)

(enum_declaration
name: (identifier) @type)

(struct_declaration
(identifier) @type)

(record_declaration
(identifier) @type)

(interface_declaration name: (identifier) @type)
(class_declaration name: (identifier) @type)
(enum_declaration name: (identifier) @type)
(struct_declaration (identifier) @type)
(record_declaration (identifier) @type)
; TODO: Let this be @module again once we support fallbacks
(namespace_declaration name: (identifier) @type)
(namespace_declaration
name: (identifier) @type)

(generic_name (identifier) @type)
(type_parameter (identifier) @property.definition)
(parameter type: (identifier) @type)
(type_argument_list (identifier) @type)
(as_expression right: (identifier) @type)
(is_expression right: (identifier) @type)
(generic_name
(identifier) @type)

(constructor_declaration name: (identifier) @constructor)
(destructor_declaration name: (identifier) @constructor)
(type_parameter
(identifier) @property.definition)

(_ type: (identifier) @type)
(parameter
type: (identifier) @type)

(base_list (identifier) @type)
(type_argument_list
(identifier) @type)

(predefined_type) @type.builtin
(as_expression
right: (identifier) @type)

(is_expression
right: (identifier) @type)

(constructor_declaration
name: (identifier) @constructor)

(destructor_declaration
name: (identifier) @constructor)

;; Enum
(enum_member_declaration (identifier) @property.definition)
(_
type: (identifier) @type)

;; Literals
(base_list
(identifier) @type)

(predefined_type) @type.builtin

; Enum
(enum_member_declaration
(identifier) @property.definition)

; Literals
[
(real_literal)
(integer_literal)
Expand All @@ -50,7 +80,7 @@
(interpolated_string_expression)
(interpolation_start)
(interpolation_quote)
] @string
] @string

(escape_sequence) @string.escape

Expand All @@ -59,12 +89,10 @@
(null_literal)
] @constant.builtin

;; Comments

; Comments
(comment) @comment

;; Tokens

; Tokens
[
";"
"."
Expand Down Expand Up @@ -122,10 +150,9 @@
"{"
"}"
(interpolation_brace)
] @punctuation.bracket

;; Keywords
] @punctuation.bracket

; Keywords
[
(modifier)
"this"
Expand Down Expand Up @@ -196,19 +223,19 @@
"let"
] @keyword

;; Attribute

(attribute name: (identifier) @attribute)

;; Parameters
; Attribute
(attribute
name: (identifier) @attribute)

; Parameters
(parameter
name: (identifier) @variable.parameter)

;; Type constraints

(type_parameter_constraints_clause (identifier) @property.definition)

;; Method calls
; Type constraints
(type_parameter_constraints_clause
(identifier) @property.definition)

(invocation_expression (member_access_expression name: (identifier) @function))
; Method calls
(invocation_expression
(member_access_expression
name: (identifier) @function))
14 changes: 11 additions & 3 deletions languages/csharp/indents.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
(_ "{" "}" @end) @indent
(_ "[" "]" @end) @indent
(_ "(" ")" @end) @indent
(_
"{"
"}" @end) @indent

(_
"["
"]" @end) @indent

(_
"("
")" @end) @indent
38 changes: 15 additions & 23 deletions languages/csharp/outline.scm
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
(class_declaration
"class" @context
name: (identifier) @name
) @item
"class" @context
name: (identifier) @name) @item

(constructor_declaration
name: (identifier) @name
) @item
name: (identifier) @name) @item

(property_declaration
type: (identifier)? @context
type: (predefined_type)? @context
name: (identifier) @name
) @item
type: (identifier)? @context
type: (predefined_type)? @context
name: (identifier) @name) @item

(field_declaration
(variable_declaration) @context
) @item
(variable_declaration) @context) @item

(method_declaration
name: (identifier) @name
parameters: (parameter_list) @context
) @item
name: (identifier) @name
parameters: (parameter_list) @context) @item

(enum_declaration
"enum" @context
name: (identifier) @name
) @item
"enum" @context
name: (identifier) @name) @item

(namespace_declaration
"namespace" @context
name: (qualified_name) @name
) @item
"namespace" @context
name: (qualified_name) @name) @item

(interface_declaration
"interface" @context
name: (identifier) @name
) @item
"interface" @context
name: (identifier) @name) @item
44 changes: 26 additions & 18 deletions languages/csharp/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
;; Join up all the comments
(comment)+ @comment.around

;; Standard methods
(method_declaration
body: (_ "{" (_)* @function.inside "}")) @function.around

;; Standard classes
(class_declaration
body: (_ "{" (_)* @class.inside "}")) @class.around

;; Interface declarations
(method_declaration) @function.around

;; Lambda expressions
(lambda_expression
body: (_ "{"? (_)* @function.inside "}"? )
) @function.around
; Join up all the comments
(comment)+ @comment.around

; Standard methods
(method_declaration
body: (_
"{"
(_)* @function.inside
"}")) @function.around

; Standard classes
(class_declaration
body: (_
"{"
(_)* @class.inside
"}")) @class.around

; Interface declarations
(method_declaration) @function.around

; Lambda expressions
(lambda_expression
body: (_
"{"?
(_)* @function.inside
"}"?)) @function.around
Loading