From 39aacea23578f2a656f2832ffbeca841027b94ec Mon Sep 17 00:00:00 2001 From: Jaakko Paju Date: Mon, 8 Jan 2024 04:05:10 +0200 Subject: [PATCH] Add textobject queries for Scala (#9191) --- book/src/generated/lang-support.md | 2 +- runtime/queries/scala/textobjects.scm | 59 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 runtime/queries/scala/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index ba68e206a90b..d068f91c0dc8 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -145,7 +145,7 @@ | ruby | ✓ | ✓ | ✓ | `solargraph` | | rust | ✓ | ✓ | ✓ | `rust-analyzer` | | sage | ✓ | ✓ | | | -| scala | ✓ | | ✓ | `metals` | +| scala | ✓ | ✓ | ✓ | `metals` | | scheme | ✓ | | ✓ | | | scss | ✓ | | | `vscode-css-language-server` | | slint | ✓ | | ✓ | `slint-lsp` | diff --git a/runtime/queries/scala/textobjects.scm b/runtime/queries/scala/textobjects.scm new file mode 100644 index 000000000000..fe0b8c255fe6 --- /dev/null +++ b/runtime/queries/scala/textobjects.scm @@ -0,0 +1,59 @@ +; Function queries + +(function_definition + body: (_) @function.inside) @function.around + +; Does not match block lambdas or Scala 3 braceless lambdas +(lambda_expression + (_) @function.inside) @function.around + + +; Class queries + +(object_definition + body: (_)? @class.inside) @class.around + +(class_definition + body: (_)? @class.inside) @class.around + +(trait_definition + body: (_)? @class.inside) @class.around + +(type_definition) @class.around + +(enum_case_definitions) @class.around + +(enum_definition + body: (_)? @class.inside) @class.around + + +; Parameter queries + +(parameters + ((_) @parameter.inside . ","? @parameter.around) @parameter.around) + +(parameter_types + ((_) @parameter.inside . ","? @parameter.around) @parameter.around) + +(bindings + ((_) @parameter.inside . ","? @parameter.around) @parameter.around) + +; Does not match context bounds or higher-kinded types +(type_parameters + ((_) @parameter.inside . ","? @parameter.around) @parameter.around) + +(arguments + ((_) @parameter.inside . ","? @parameter.around) @parameter.around) + +(type_arguments + ((_) @parameter.inside . ","? @parameter.around) @parameter.around) + + +; Comment queries + +(comment) @comment.inside +(comment) @comment.around ; Does not match consecutive block comments + + +; Test queries +; Not supported