Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add c-sharp textobjects #3494

Merged
merged 4 commits into from
Aug 27, 2022
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
2 changes: 1 addition & 1 deletion book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
| bash | ✓ | | | `bash-language-server` |
| beancount | ✓ | | | |
| c | ✓ | ✓ | ✓ | `clangd` |
| c-sharp | ✓ | | | `OmniSharp` |
| c-sharp | ✓ | | | `OmniSharp` |
| cairo | ✓ | | | |
| clojure | ✓ | | | `clojure-lsp` |
| cmake | ✓ | ✓ | ✓ | `cmake-language-server` |
Expand Down
2 changes: 1 addition & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,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"
Expand Down
15 changes: 13 additions & 2 deletions runtime/queries/c-sharp/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions runtime/queries/c-sharp/textobjects.scm
Original file line number Diff line number Diff line change
@@ -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