Skip to content

Commit

Permalink
add loop and conditional textobjects for c, rust, and python
Browse files Browse the repository at this point in the history
  • Loading branch information
p00f authored and meain committed Dec 22, 2023
1 parent 9a9edd4 commit 220ceae
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions treesit-queries/c/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@
(comment) @comment.inner

(comment)+ @comment.outer

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

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

(do_statement
body: (_) @loop.inner) @loop.outer

(if_statement
consequence: (_) @conditional.inner) @conditional.outer
9 changes: 9 additions & 0 deletions treesit-queries/python/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@
name: (identifier) @_name
body: (block)? @test.inner) @test.outer
(#match "^test_" @_name))

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

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

(if_statement
consequence: (_) @conditional.inner) @conditional.outer
12 changes: 12 additions & 0 deletions treesit-queries/rust/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@
(function_item
body: (_) @test.inner) @test.outer
(#equal @_test_attribute "test"))

(loop_expression
body: (_) @loop.inner) @loop.outer

(while_expression
body: (_) @loop.inner) @loop.outer

(for_expression
body: (_) @loop.inner) @loop.outer

(if_expression
consequence: (_) @conditional.inner) @conditional.outer

0 comments on commit 220ceae

Please sign in to comment.