mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-20 12:20:02 -04:00
Add C/C++ textobjects
This commit is contained in:
parent
d685d82682
commit
5e83307a43
2 changed files with 53 additions and 0 deletions
|
|
@ -6,3 +6,50 @@
|
||||||
|
|
||||||
(function_definition
|
(function_definition
|
||||||
body: (compound_statement) @function.inner) @function.outer
|
body: (compound_statement) @function.inner) @function.outer
|
||||||
|
|
||||||
|
(struct_specifier
|
||||||
|
body: (_) @class.inner) @class.outer
|
||||||
|
|
||||||
|
; conditional
|
||||||
|
(if_statement
|
||||||
|
consequence: (_)? @conditional.inner
|
||||||
|
alternative: (_)? @conditional.inner
|
||||||
|
) @conditional.outer
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
condition: (_) @conditional.inner)
|
||||||
|
|
||||||
|
; loops
|
||||||
|
(for_statement
|
||||||
|
(_)? @loop.inner) @loop.outer
|
||||||
|
(while_statement
|
||||||
|
(_)? @loop.inner) @loop.outer
|
||||||
|
(do_statement
|
||||||
|
(_)? @loop.inner) @loop.outer
|
||||||
|
|
||||||
|
|
||||||
|
(compound_statement) @block.outer
|
||||||
|
(comment) @comment.outer
|
||||||
|
|
||||||
|
(call_expression) @call.outer
|
||||||
|
(call_expression (_) @call.inner)
|
||||||
|
|
||||||
|
; Statements
|
||||||
|
|
||||||
|
;(expression_statement ;; this is what we actually want to capture in most cases (";" is missing) probaly
|
||||||
|
;(_) @statement.inner) ;; the otther statement like node type is declaration but declaration has a ";"
|
||||||
|
|
||||||
|
(compound_statement
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
(field_declaration_list
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
(preproc_if
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
(preproc_elif
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
||||||
|
(preproc_else
|
||||||
|
(_) @statement.outer)
|
||||||
|
|
|
||||||
6
queries/cpp/textobjects.scm
Normal file
6
queries/cpp/textobjects.scm
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
(class_specifier
|
||||||
|
body: (_) @class.inner) @class.outer
|
||||||
|
|
||||||
|
(for_range_loop
|
||||||
|
(_)? @loop.inner) @loop.outer
|
||||||
Loading…
Add table
Add a link
Reference in a new issue