Skip to content

About ts

ts_list_parsers()
List installed tree-sitter parsers

Create tree-sitter trees

ts_tree_new()
Create tree-sitter tree from file or string

Selection

ts_tree_select()
Select elements of a tree-sitter tree

Editing

ts_tree_delete()
Delete selected elements from a tree-sitter tree
ts_tree_format()
Format the selected elements of a tree sitter tree for printing
ts_tree_insert()
Insert a new element into a tree-sitter tree
ts_tree_update()
Replace selected elements with a new element in a tree-sitter tree

Manipulation

Another way to edit a tree-sitter tree is “in place”, using the ts_tre_select<-() replacement function or the [[<- replacement operator.

`ts_tree_select<-`()
Edit parts of a tree-sitter tree
`[[<-`(<ts_tree>)
Edit parts of a tree-sitter tree

Formatting and printing

print(<ts_tree>)
Print a tree-sitter tree
format(<ts_tree>)
Format tree-sitter trees

Unserialize

`[[`(<ts_tree>)
Unserialize parts of a tree-sitter tree
ts_tree_unserialize()
Unserialize selected elements of a tree-sitter tree
ts_tree_write()
Write a tree-sitter tree to a file

Exploring

`[`(<ts_tree>)
Convert ts_tree object to a data frame
ts_tree_ast()
Show the annotated syntax tree of a tree-sitter tree
ts_tree_dom()
Print the document object model (DOM) of a tree-sitter tree
ts_tree_query()
Run tree-sitter queries on tree-sitter trees
ts_tree_sexpr()
Show the syntax tree of a tree-sitter tree

Functions for tree-sitter parser packages

These functions are intended to be used by packages that implement tree-sitter parsers and use the ts package as a backend. It is unlikely that you will need to use these functions directly.

ts_collapse() ts_cnd() ts_caller_arg() as_ts_caller_arg() as.character(<ts_caller_arg>) ts_caller_env() ts_check_named_arg() ts_parse_error_cnd()
Utility functions for ts language implementations (internal)
ts_tree_mark_selection1()
Helper function to decide which AST nodes to highlight for a selection (internal)
ts_tree_select1()
Select nodes from a tree-sitter tree (internal)
ts_tree_selection() ts_tree_selected_nodes()
Helper functions for tree-sitter tree selections (internal)