Skip to content

Commit

Permalink
Update tree-sitter queries to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
meain authored Feb 9, 2024
1 parent 220ceae commit 205fcb9
Show file tree
Hide file tree
Showing 13 changed files with 695 additions and 27 deletions.
2 changes: 2 additions & 0 deletions queries/astro/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; inherits: html

29 changes: 19 additions & 10 deletions queries/c/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,32 @@
(enum_specifier
body: (_) @class.inner) @class.outer

; conditional
; conditionals
(if_statement
consequence: (_)? @conditional.inner
alternative: (_)? @conditional.inner
) @conditional.outer
consequence: (compound_statement . "{" . (_) @conditional.inner._start @conditional.inner._end (_)? @conditional.inner._end . "}"
)) @conditional.outer

(if_statement
condition: (_) @conditional.inner)
alternative: (else_clause (compound_statement . "{" . (_) @conditional.inner._start @conditional.inner._end (_)? @conditional.inner._end . "}"
))) @conditional.outer

(if_statement) @conditional.outer

; loops
(for_statement
(_)? @loop.inner) @loop.outer
(while_statement) @loop.outer
(while_statement
(_)? @loop.inner) @loop.outer
(do_statement
(_)? @loop.inner) @loop.outer
body: (compound_statement . "{" . (_) @loop.inner._start @loop.inner._end (_)? @loop.inner._end . "}"
)) @loop.outer

(for_statement) @loop.outer
(for_statement
body: (compound_statement . "{" . (_) @loop.inner._start @loop.inner._end (_)? @loop.inner._end . "}"
)) @loop.outer

(do_statement) @loop.outer
(do_statement
body: (compound_statement . "{" . (_) @loop.inner._start @loop.inner._end (_)? @loop.inner._end . "}"
)) @loop.outer

(compound_statement) @block.outer
(comment) @comment.outer
Expand Down
4 changes: 4 additions & 0 deletions queries/c_sharp/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
body: (block . "{" . (_) @function.inner._start @function.inner._end (_)? @function.inner._end . "}"
)) @function.outer

(method_declaration
body: (arrow_expression_clause . (_) @function.inner._start @function.inner._end (_)? @function.inner._end
)) @function.outer

(constructor_declaration
body: (block . "{" . (_) @function.inner._start @function.inner._end (_)? @function.inner._end . "}"
)) @function.outer
Expand Down
6 changes: 4 additions & 2 deletions queries/cpp/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
type: (enum_specifier)
default_value: (initializer_list) @class.inner) @class.outer

(for_range_loop
(_)? @loop.inner) @loop.outer
(for_range_loop)@loop.outer
(for_range_loop
body: (compound_statement . "{" . (_) @loop.inner._start @loop.inner._end (_)? @loop.inner._end . "}"
))

(template_declaration
(function_definition) @function.outer) @function.outer.start
Expand Down
21 changes: 19 additions & 2 deletions queries/ecma/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(function_declaration
body: (statement_block)) @function.outer

(function
(function_expression
body: (statement_block)) @function.outer

(function_declaration
body: (statement_block . "{" . (_) @function.inner._start @function.inner._end (_)? @function.inner._end . "}"
))

(function
(function_expression
body: (statement_block . "{" . (_) @function.inner._start @function.inner._end (_)? @function.inner._end . "}"
))

Expand Down Expand Up @@ -55,6 +55,12 @@
consequence: (statement_block . "{" . (_) @conditional.inner._start @conditional.inner._end (_)? @conditional.inner._end . "}"
)) @conditional.outer

(if_statement
alternative: (else_clause (statement_block . "{" . (_) @conditional.inner._start @conditional.inner._end (_)? @conditional.inner._end . "}"
))) @conditional.outer

(if_statement) @conditional.outer

(switch_statement
body: (_)? @conditional.inner) @conditional.outer

Expand All @@ -63,6 +69,12 @@
arguments: (arguments . "(" . (_) @call.inner._start (_)? @call.inner._end . ")"
))

((new_expression
constructor: (identifier) @_cons
arguments: (arguments . "(" . (_) @call.inner._start (_)? @call.inner._end . ")") @_args)

)

;; blocks
(_ (statement_block) @block.inner) @block.outer

Expand Down Expand Up @@ -120,3 +132,8 @@
(variable_declarator
name: (_) @assignment.inner)

(object
(pair
key: (_) @assignment.lhs
value: (_) @assignment.inner @assignment.rhs) @assignment.outer)

8 changes: 7 additions & 1 deletion queries/fish/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
(function_definition) @function.outer
;; assignment
(command
name: (word) @_command
argument: (word) @_varname @assignment.lhs @assignment.inner
argument: (_)* @assignment.rhs
(#not-lua-match? @_varname "[-].*")
(#eq? @_command "set")) @assignment.outer

(command
name: (word) @_name
Expand Down
59 changes: 59 additions & 0 deletions queries/gdscript/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
(function_definition
body: (_) @function.inner) @function.outer

(constructor_definition
body: (_) @function.inner) @function.outer

(class_definition
body: (_) @class.inner) @class.outer

(if_statement
body: (_) @conditional.inner) @conditional.outer

(if_statement
alternative: (_ (_) @conditional.inner)?) @conditional.outer

(if_statement
condition: (_) @conditional.inner)

[
(for_statement)
(while_statement)
] @loop.outer

(while_statement body: (_) @loop.inner)

(for_statement body: (_) @loop.inner)

(comment) @comment.outer

(parameters
"," @parameter.outer._start .
(_) @parameter.inner @parameter.outer._end
)

(parameters
. (_) @parameter.inner @parameter.outer._start
. ","? @parameter.outer._end
)

(arguments
"," @parameter.outer._start .
(_) @parameter.inner @parameter.outer._end
)

(arguments
. (_) @parameter.inner @parameter.outer._start
. ","? @parameter.outer._end
)

(array
"," @parameter.outer._start .
(_) @parameter.inner @parameter.outer._end
)

(array
. (_) @parameter.inner @parameter.outer._start
. ","? @parameter.outer._end
)

23 changes: 22 additions & 1 deletion queries/latex/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,28 @@

[
(generic_command)
] @statement.outer
(text_mode)
] @call.outer

(text_mode
(curly_group
"{"
.
(_) @call.inner._start
(_)? @call.inner._end
.
"}")
)

(generic_command
(curly_group
"{"
.
(_) @call.inner._start
(_)? @call.inner._end
.
"}")
)

[
(chapter)
Expand Down
Loading

0 comments on commit 205fcb9

Please sign in to comment.