From 98a3d46912be7dcc650c54ea417d7f00ab6d05a3 Mon Sep 17 00:00:00 2001 From: Mathieu Agopian Date: Sat, 25 Feb 2023 19:55:44 +0100 Subject: [PATCH] Add elm treesitter textobjects (#6084) --- book/src/generated/lang-support.md | 2 +- runtime/queries/elm/textobjects.scm | 63 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/elm/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 4011aa114..e997b3e81 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -30,7 +30,7 @@ | eex | ✓ | | | | | ejs | ✓ | | | | | elixir | ✓ | ✓ | ✓ | `elixir-ls` | -| elm | ✓ | | | `elm-language-server` | +| elm | ✓ | ✓ | | `elm-language-server` | | elvish | ✓ | | | `elvish` | | env | ✓ | | | | | erb | ✓ | | | | diff --git a/runtime/queries/elm/textobjects.scm b/runtime/queries/elm/textobjects.scm new file mode 100644 index 000000000..d212e9c3b --- /dev/null +++ b/runtime/queries/elm/textobjects.scm @@ -0,0 +1,63 @@ +(line_comment) @comment.inside +(line_comment)+ @comment.around +(block_comment) @comment.inside +(block_comment)+ @comment.around + +((type_annotation)? + (value_declaration + (function_declaration_left (lower_case_identifier)) + (eq) + (_) @function.inside + ) +) @function.around + +(parenthesized_expr + (anonymous_function_expr + ( + (arrow) + (_) @function.inside + ) + ) +) @function.around + +(value_declaration + (function_declaration_left + (lower_pattern + (lower_case_identifier) @parameter.inside @parameter.around + ) + ) +) + +(value_declaration + (function_declaration_left + (pattern) @parameter.inside @parameter.around + ) +) + +(value_declaration + (function_declaration_left + (tuple_pattern + (pattern) @parameter.inside + ) @parameter.around + ) +) + +(value_declaration + (function_declaration_left + (record_pattern + (lower_pattern + (lower_case_identifier) @parameter.inside + ) + ) @parameter.around + ) +) + +(parenthesized_expr + (anonymous_function_expr + ( + (backslash) + (pattern) @parameter.inside + (arrow) + ) + ) +)