aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaan Qureshi <amaanq12@gmail.com>2024-05-03 20:10:58 -0400
committerAmaan Qureshi <amaanq12@gmail.com>2024-05-11 15:26:30 -0400
commit6587d8e6942b8d2146d61bab4c4acff9dec5ae59 (patch)
tree692b60f95e29eb8dae81194cd0f21e92d0fcd142
parentbot(lockfile): update dtd, go, idl, javascript, tact, xml (diff)
downloadnvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar
nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar.gz
nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar.bz2
nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar.lz
nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar.xz
nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.tar.zst
nvim-treesitter-6587d8e6942b8d2146d61bab4c4acff9dec5ae59.zip
feat(c_sharp): update parser & queries
-rw-r--r--README.md2
-rw-r--r--lockfile.json2
-rw-r--r--lua/nvim-treesitter/parsers.lua2
-rw-r--r--queries/c_sharp/folds.scm3
-rw-r--r--queries/c_sharp/highlights.scm238
-rw-r--r--queries/c_sharp/locals.scm4
6 files changed, 180 insertions, 71 deletions
diff --git a/README.md b/README.md
index 3cb08346a..e04e700d3 100644
--- a/README.md
+++ b/README.md
@@ -190,7 +190,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [bitbake](https://github.com/amaanq/tree-sitter-bitbake) (maintained by @amaanq)
- [x] [blueprint](https://gitlab.com/gabmus/tree-sitter-blueprint.git) (experimental, maintained by @gabmus)
- [x] [c](https://github.com/tree-sitter/tree-sitter-c) (maintained by @amaanq)
-- [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @Luxed)
+- [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @amaanq)
- [x] [cairo](https://github.com/amaanq/tree-sitter-cairo) (maintained by @amaanq)
- [x] [capnp](https://github.com/amaanq/tree-sitter-capnp) (maintained by @amaanq)
- [x] [chatito](https://github.com/ObserverOfTime/tree-sitter-chatito) (maintained by @ObserverOfTime)
diff --git a/lockfile.json b/lockfile.json
index e1eba4e4b..195172133 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -51,7 +51,7 @@
"revision": "82fb86aa544843bd17a9f0f3dc16edf645a34349"
},
"c_sharp": {
- "revision": "e1384e2f132936019b43aaaae154cd780fb497ce"
+ "revision": "f47328563999efb9d6438d8ea28999711fbe473f"
},
"cairo": {
"revision": "6238f609bea233040fe927858156dee5515a0745"
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 169ffea2d..031b2658e 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -224,7 +224,7 @@ list.c_sharp = {
files = { "src/parser.c", "src/scanner.c" },
},
filetype = "cs",
- maintainers = { "@Luxed" },
+ maintainers = { "@amaanq" },
}
list.cairo = {
diff --git a/queries/c_sharp/folds.scm b/queries/c_sharp/folds.scm
index 80ae4e44b..16967b69d 100644
--- a/queries/c_sharp/folds.scm
+++ b/queries/c_sharp/folds.scm
@@ -10,5 +10,8 @@ initializer: (initializer_expression) @fold
[
(block)
+ (preproc_if)
+ (preproc_elif)
+ (preproc_else)
(using_directive)+
] @fold
diff --git a/queries/c_sharp/highlights.scm b/queries/c_sharp/highlights.scm
index 7d2621bcc..20cc80747 100644
--- a/queries/c_sharp/highlights.scm
+++ b/queries/c_sharp/highlights.scm
@@ -1,12 +1,15 @@
-(identifier) @variable
+[
+ (identifier)
+ (preproc_arg)
+] @variable
+
+((preproc_arg) @constant.macro
+ (#lua-match? @constant.macro "^[_A-Z][_A-Z0-9]*$"))
((identifier) @keyword
(#eq? @keyword "value")
(#has-ancestor? @keyword accessor_declaration))
-((identifier) @variable.builtin
- (#eq? @variable.builtin "_"))
-
(method_declaration
name: (identifier) @function.method)
@@ -14,8 +17,23 @@
name: (identifier) @function.method)
(method_declaration
+ returns: [
+ (identifier) @type
+ (generic_name
+ (identifier) @type)
+ ])
+
+(event_declaration
type: (identifier) @type)
+(event_declaration
+ name: (identifier) @variable.member)
+
+(event_field_declaration
+ (variable_declaration
+ (variable_declarator
+ name: (identifier) @variable.member)))
+
(declaration_pattern
type: (identifier) @type)
@@ -46,11 +64,16 @@
(identifier) @type)
(namespace_declaration
- name: [
- (qualified_name
- (identifier) @module)
- (identifier) @module
- ])
+ name: (identifier) @module)
+
+(file_scoped_namespace_declaration
+ name: (identifier) @module)
+
+(qualified_name
+ (identifier) @module
+ (#not-has-ancestor? @module method_declaration)
+ (#not-has-ancestor? @module record_declaration)
+ (#has-ancestor? @module namespace_declaration file_scoped_namespace_declaration))
(invocation_expression
(identifier) @function.method.call)
@@ -64,13 +87,16 @@
(assignment_expression
left: (identifier) @variable.member))
+(parameter
+ name: (identifier) @variable.parameter)
+
(parameter_list
- (parameter
- name: (identifier) @variable.parameter))
+ name: (identifier) @variable.parameter)
-(implicit_parameter_list
- (parameter
- name: (identifier) @variable.parameter))
+(bracketed_parameter_list
+ name: (identifier) @variable.parameter)
+
+(implicit_parameter) @variable.parameter
(parameter_list
(parameter
@@ -82,6 +108,15 @@
(null_literal) @constant.builtin
+(calling_convention
+ [
+ (identifier)
+ "Cdecl"
+ "Stdcall"
+ "Thiscall"
+ "Fastcall"
+ ] @attribute.builtin)
+
(character_literal) @character
[
@@ -93,7 +128,10 @@
(escape_sequence) @string.escape
-(boolean_literal) @boolean
+[
+ "true"
+ "false"
+] @boolean
(predefined_type) @type.builtin
@@ -114,8 +152,7 @@
(identifier) @type)
(using_directive
- (name_equals
- (identifier) @type.definition))
+ (type) @type.definition)
(property_declaration
name: (identifier) @property)
@@ -124,7 +161,16 @@
type: (identifier) @type)
(nullable_type
- (identifier) @type)
+ type: (identifier) @type)
+
+(array_type
+ type: (identifier) @type)
+
+(ref_type
+ type: (identifier) @type)
+
+(pointer_type
+ type: (identifier) @type)
(catch_declaration
type: (identifier) @type)
@@ -138,15 +184,48 @@
(record_declaration
name: (identifier) @type)
+(struct_declaration
+ name: (identifier) @type)
+
(enum_declaration
name: (identifier) @type)
(enum_member_declaration
name: (identifier) @variable.member)
+(operator_declaration
+ type: (identifier) @type)
+
+(conversion_operator_declaration
+ type: (identifier) @type)
+
+(explicit_interface_specifier
+ [
+ (identifier) @type
+ (generic_name
+ (identifier) @type)
+ ])
+
+(explicit_interface_specifier
+ (identifier) @type)
+
+(primary_constructor_base_type
+ type: (identifier) @type)
+
+[
+ "assembly"
+ "module"
+ "this"
+ "base"
+ (discard)
+] @variable.builtin
+
(constructor_declaration
name: (identifier) @constructor)
+(destructor_declaration
+ name: (identifier) @constructor)
+
(constructor_initializer
"base" @constructor)
@@ -157,7 +236,7 @@
(identifier) @type)
; Generic Types.
-(type_of_expression
+(typeof_expression
(generic_name
(identifier) @type))
@@ -169,9 +248,13 @@
(generic_name
(identifier) @type))
-(type_constraint
- (generic_name
- (identifier) @type))
+(type_parameter_constraint
+ [
+ (identifier) @type
+ (type
+ (generic_name
+ (identifier) @type))
+ ])
(object_creation_expression
(generic_name
@@ -205,15 +288,26 @@
(type_parameter_list
(type_parameter) @type)
+(type_parameter
+ name: (identifier) @type)
+
(type_parameter_constraints_clause
- target: (identifier) @type)
+ "where"
+ .
+ (identifier) @type)
(attribute
name: (identifier) @attribute)
-(for_each_statement
+(foreach_statement
type: (identifier) @type)
+(goto_statement
+ (identifier) @label)
+
+(labeled_statement
+ (identifier) @label)
+
(tuple_element
type: (identifier) @type)
@@ -222,43 +316,48 @@
(declaration_expression
type: (identifier) @type)))
+(cast_expression
+ type: (identifier) @type)
+
+(lambda_expression
+ type: (identifier) @type)
+
(as_expression
right: (identifier) @type)
-(type_of_expression
+(typeof_expression
(identifier) @type)
-(name_colon
- (identifier) @variable.parameter)
+(preproc_error) @keyword.exception
-(warning_directive) @comment.warning
-
-(error_directive) @keyword.exception
-
-(define_directive
- (identifier) @constant) @constant.macro
-
-(undef_directive
- (identifier) @constant) @constant.macro
-
-(line_directive) @constant.macro
-
-(line_directive
- (preproc_integer_literal) @constant
- (preproc_string_literal)? @string)
-
-(pragma_directive
- (identifier) @constant) @constant.macro
+[
+ "#define"
+ "#undef"
+] @keyword.directive.define
-(pragma_directive
- (preproc_string_literal) @string) @constant.macro
+[
+ "#if"
+ "#elif"
+ "#else"
+ "#endif"
+ "#region"
+ "#endregion"
+ "#line"
+ "#pragma"
+ "#nullable"
+ "#error"
+ (shebang_directive)
+] @keyword.directive
[
- (nullable_directive)
- (region_directive)
- (endregion_directive)
+ (preproc_line)
+ (preproc_pragma)
+ (preproc_nullable)
] @constant.macro
+(preproc_pragma
+ (identifier) @constant)
+
[
"if"
"else"
@@ -266,16 +365,15 @@
"break"
"case"
"when"
- (if_directive)
- (elif_directive)
- (else_directive)
- (endif_directive)
] @keyword.conditional
-(if_directive
+(preproc_pragma
(identifier) @constant)
-(elif_directive
+(preproc_if
+ (identifier) @constant)
+
+(preproc_if
(identifier) @constant)
[
@@ -335,6 +433,7 @@
"=>"
"??"
"??="
+ ".."
] @operator
[
@@ -359,6 +458,8 @@
")"
] @punctuation.bracket
+(interpolation_brace) @punctuation.special
+
(type_argument_list
[
"<"
@@ -366,12 +467,6 @@
] @punctuation.bracket)
[
- (this_expression)
- (base_expression)
- "this"
-] @variable.builtin
-
-[
"using"
"as"
] @keyword.import
@@ -390,6 +485,9 @@
"or"
"not"
"stackalloc"
+ "__makeref"
+ "__reftype"
+ "__refvalue"
"in"
"out"
"ref"
@@ -413,8 +511,14 @@
"unchecked"
"fixed"
"alias"
+ "file"
+ "unsafe"
] @keyword
+(attribute_target_specifier
+ .
+ _ @keyword)
+
[
"enum"
"record"
@@ -438,9 +542,9 @@
"static"
"volatile"
"required"
-] @keyword.modifier
-
-[
+ "managed"
+ "unmanaged"
+ "notnull"
"abstract"
"private"
"protected"
@@ -449,9 +553,11 @@
"partial"
"sealed"
"virtual"
+ "global"
] @keyword.modifier
-(parameter_modifier) @operator
+(scoped_type
+ "scoped" @keyword.modifier)
(query_expression
(_
diff --git a/queries/c_sharp/locals.scm b/queries/c_sharp/locals.scm
index 33df9bb37..bef094007 100644
--- a/queries/c_sharp/locals.scm
+++ b/queries/c_sharp/locals.scm
@@ -10,10 +10,10 @@
(declaration_expression
name: (identifier) @local.definition.var)
-(for_each_statement
+(foreach_statement
left: (identifier) @local.definition.var)
-(for_each_statement
+(foreach_statement
left: (tuple_pattern
(identifier) @local.definition.var))