From e06678278267a76a1d9e29b36d4734bcb39eabec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Bogar=C3=ADn?= Date: Sat, 27 Aug 2022 10:24:47 -0400 Subject: [PATCH] Add c-sharp textobjects (#3494) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gustavo Bogarín Co-authored-by: Gustavo Bogarín --- book/src/generated/lang-support.md | 2 +- languages.toml | 2 +- runtime/queries/c-sharp/highlights.scm | 15 +++++++++++++-- runtime/queries/c-sharp/textobjects.scm | 21 +++++++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 runtime/queries/c-sharp/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 8d8275ab6..9a1d5b924 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -4,7 +4,7 @@ | bash | ✓ | | | `bash-language-server` | | beancount | ✓ | | | | | c | ✓ | ✓ | ✓ | `clangd` | -| c-sharp | ✓ | | | `OmniSharp` | +| c-sharp | ✓ | ✓ | | `OmniSharp` | | cairo | ✓ | | | | | clojure | ✓ | | | `clojure-lsp` | | cmake | ✓ | ✓ | ✓ | `cmake-language-server` | diff --git a/languages.toml b/languages.toml index 986b927e3..d125ae886 100644 --- a/languages.toml +++ b/languages.toml @@ -235,7 +235,7 @@ language-server = { command = "OmniSharp", args = [ "--languageserver" ] } [[grammar]] name = "c-sharp" -source = { git = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "53a65a908167d6556e1fcdb67f1ee62aac101dda" } +source = { git = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "9c494a503c8e2044bfffce57f70b480c01a82f03" } [[language]] name = "go" diff --git a/runtime/queries/c-sharp/highlights.scm b/runtime/queries/c-sharp/highlights.scm index 6b94dd8cd..dbb7c7783 100644 --- a/runtime/queries/c-sharp/highlights.scm +++ b/runtime/queries/c-sharp/highlights.scm @@ -228,8 +228,19 @@ "let" ] @keyword -(preprocessor_call) @keyword.directive -(preprocessor_call (_) @keyword.directive) +(nullable_directive) @keyword.directive +(define_directive) @keyword.directive +(undef_directive) @keyword.directive +(if_directive) @keyword.directive +(else_directive) @keyword.directive +(elif_directive) @keyword.directive +(endif_directive) @keyword.directive +(region_directive) @keyword.directive +(endregion_directive) @keyword.directive +(error_directive) @keyword.directive +(warning_directive) @keyword.directive +(line_directive) @keyword.directive +(pragma_directive) @keyword.directive ;; Linq (from_clause (identifier) @variable) diff --git a/runtime/queries/c-sharp/textobjects.scm b/runtime/queries/c-sharp/textobjects.scm new file mode 100644 index 000000000..c5afe5f4e --- /dev/null +++ b/runtime/queries/c-sharp/textobjects.scm @@ -0,0 +1,21 @@ +[ + (class_declaration body: (_) @class.inside) + (struct_declaration body: (_) @class.inside) + (interface_declaration body: (_) @class.inside) + (enum_declaration body: (_) @class.inside) + (delegate_declaration) + (record_declaration body: (_) @class.inside) + (record_struct_declaration body: (_) @class.inside) +] @class.around + +(constructor_declaration body: (_) @function.inside) @function.around + +(destructor_declaration body: (_) @function.inside) @function.around + +(method_declaration body: (_) @function.inside) @function.around + +(property_declaration (_) @function.inside) @function.around + +(parameter (_) @parameter.inside) @parameter.around + +(comment)+ @comment.around