From a91263d604bd2f9960179386bf2e71627b25d333 Mon Sep 17 00:00:00 2001 From: cornishon <65736309+cornishon@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:59:28 +0100 Subject: [PATCH] Odin textobjects (#12302) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adam Zadrożny --- book/src/generated/lang-support.md | 2 +- runtime/queries/odin/textobjects.scm | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/odin/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index dc4a5c8b7..c1c4dbb10 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -147,7 +147,7 @@ | nunjucks | ✓ | | | | | ocaml | ✓ | | ✓ | `ocamllsp` | | ocaml-interface | ✓ | | | `ocamllsp` | -| odin | ✓ | | ✓ | `ols` | +| odin | ✓ | ✓ | ✓ | `ols` | | ohm | ✓ | ✓ | ✓ | | | opencl | ✓ | ✓ | ✓ | `clangd` | | openscad | ✓ | | | `openscad-lsp` | diff --git a/runtime/queries/odin/textobjects.scm b/runtime/queries/odin/textobjects.scm new file mode 100644 index 000000000..85b0687de --- /dev/null +++ b/runtime/queries/odin/textobjects.scm @@ -0,0 +1,22 @@ +(procedure_declaration (identifier) (procedure (block) @function.inside)) @function.around +(procedure_declaration (identifier) (procedure (uninitialized) @function.inside)) @function.around +(overloaded_procedure_declaration (identifier) @function.inside) @function.around + +(procedure_type (parameters (parameter (identifier) @parameter.inside) @parameter.around)) +(procedure (parameters (parameter (identifier) @parameter.inside) @parameter.around)) + +((procedure_declaration + (attributes (attribute "@" "(" (identifier) @attr_name ")")) + (identifier) (procedure (block) @test.inside)) @test.around + (#match? @attr_name "test")) + +(comment) @comment.inside +(comment)+ @comment.around +(block_comment) @comment.inside +(block_comment)+ @comment.around + +(struct_declaration (identifier) "::") @class.around +(enum_declaration (identifier) "::") @class.around +(union_declaration (identifier) "::") @class.around +(bit_field_declaration (identifier) "::") @class.around +(const_declaration (identifier) "::" [(array_type) (distinct_type) (bit_set_type) (pointer_type)]) @class.around