Improve tree-sitter queries for Scala (#9475)

- Simplify function highlighting
- Highlight extension methods
- Textobject query (mia/maa) for class/trait constructor parameters/arguments
- Textobject query (mif/maf) for Scala 3 braceless lambdas
This commit is contained in:
Jaakko Paju 2024-02-04 03:09:42 +02:00 committed by GitHub
parent d1054de3ce
commit 75d61d8149
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 23 deletions

View File

@ -53,28 +53,13 @@
(var_declaration
name: (identifier) @variable)
; method definition
; function definitions/declarations
(class_definition
body: (template_body
[
(function_definition
name: (identifier) @function.method)
(function_declaration
name: (identifier) @function.method)
]))
(trait_definition
body: (template_body
[
(function_definition
name: (identifier) @function.method)
(function_declaration
name: (identifier) @function.method)
]))
(object_definition
body: (template_body
(function_definition
name: (identifier) @function.method)))
(function_declaration
name: (identifier) @function.method)
(function_definition
name: (identifier) @function.method)
; imports/exports

View File

@ -1,12 +1,15 @@
; Function queries
(function_definition
body: (_) @function.inside) @function.around
body: (_) @function.inside) @function.around ; Does not include end marker
; Does not match block lambdas or Scala 3 braceless lambdas
(lambda_expression
(_) @function.inside) @function.around
; Scala 3 braceless lambda
(colon_argument
(_) @function.inside) @function.around
; Class queries
@ -32,6 +35,9 @@
(parameters
((_) @parameter.inside . ","? @parameter.around) @parameter.around)
(class_parameters
((_) @parameter.inside . ","? @parameter.around) @parameter.around)
(parameter_types
((_) @parameter.inside . ","? @parameter.around) @parameter.around)