Skip to content

Commit

Permalink
Add textobject queries for Scala (helix-editor#9191)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpaju authored and Schuyler Mortimer committed Jul 10, 2024
1 parent 4b40d04 commit 1417cc7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
| ruby |||| `solargraph` |
| rust |||| `rust-analyzer` |
| sage ||| | |
| scala || || `metals` |
| scala || || `metals` |
| scheme || || |
| scss || | | `vscode-css-language-server` |
| slint || || `slint-lsp` |
Expand Down
59 changes: 59 additions & 0 deletions runtime/queries/scala/textobjects.scm
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1417cc7

Please sign in to comment.