api-reference.md
July 14, 2025 ยท View on GitHub
API Documentation
The core API is exposed under the paredit.api module
Index
Slurp / Barf
SlurpBarfOpts
{
cursor_behaviour = "auto", -- remain, follow, auto
indent = {
enabled = false,
indentor = require("nvim-paredit.indentation.native").indentor,
},
}
slurp_forwards([opts])
Expands the current form by pulling in the next expression into the form.
opts- see SlurpBarfOpts
slurp_backwards([opts])
Expands the current form by pulling the previous expression into the form.
opts- see SlurpBarfOpts
barf_forwards([opts])
Removes the last expression from the current form, pushing it outwards.
opts- see SlurpBarfOpts
barf_backwards([opts])
Removes the first expression from the current form, pushing it outwards.
opts- see SlurpBarfOpts
Dragging
ElementDragOpts
{
dragging = {
enable_auto_drag = true
}
}
drag_element_forwards([opts])
Moves the current element or pair forwards within its form.
opts- see ElementDragOpts
drag_element_backwards([opts])
Moves the current element or pair backwards within its form.
opts- see ElementDragOpts
drag_pair_forwards()
Moves the current pair of elements forwards within its form.
Inputs:
pair: (Optional) The pair of elements to drag forwards. Defaults to the pair at the current cursor position.
drag_pair_backwards()
Moves the current pair of elements backwards within its form.
Inputs:
pair: (Optional) The pair of elements to drag backwards. Defaults to the pair at the current cursor position.
drag_form_forwards()
Moves the current form forwards within its parent form.
drag_form_backwards()
Moves the current form backwards within its parent form.
Editing
raise_element()
Raises the current element, removing it from its enclosing form.
raise_form()
Raises the current form, removing it from its enclosing form.
delete_form()
Deletes the current form.
delete_in_form()
Deletes the content inside the current form without removing the form itself.
delete_top_level_form()
Deletes the current top-level form.
delete_in_top_level_form()
Deletes the content inside the current top-level form without removing the form itself.
delete_element()
Deletes the current element.
Motions
move_to_next_element_tail()
Moves the cursor to the tail of the next element in the form.
move_to_next_element_head()
Moves the cursor to the head of the next element in the form.
move_to_prev_element_head()
Moves the cursor to the head of the previous element in the form.
move_to_prev_element_tail()
Moves the cursor to the tail of the previous element in the form.
move_to_parent_form_start()
Moves the cursor to the start of the parent form.
move_to_parent_form_end()
Moves the cursor to the end of the parent form.
move_to_top_level_form_head()
Moves the cursor to the head of the top level form.
Selections
select_around_form()
Selects the form surrounding the cursor, including the enclosing delimiters.
select_in_form()
Selects the content inside the form surrounding the cursor, excluding the enclosing delimiters.
select_around_top_level_form()
Selects the top-level form surrounding the cursor, including the enclosing delimiters.
select_in_top_level_form()
Selects the content inside the top-level form surrounding the cursor, excluding the enclosing delimiters.
select_element()
Selects the current element under the cursor.
Wrapping
wrap_element_under_cursor(prefix, suffix)
Wraps the element under the cursor with a prefix and suffix.
prefix: stringsuffix: string
Returns The wrapped TSNode.
wrap_enclosing_form_under_cursor()
Wraps the enclosing form under the cursor with a prefix and suffix.
prefix: stringsuffix: string
Returns The wrapped TSNode.
unwrap_form_under_cursor()
Unwraps the nearest form under the cursor. This is called splice in other paredit implementations.
Cursor Manipulation
These APIs are exposed from paredit.api.cursor.
place_cursor(range_or_node, opts)
Places the cursor at a specific position within a TSNode.
node: TheTSNodeto operate withinoptstableplacement: (Optional) The position relative to the node. Can beleft_edge,inner_start,inner_end, orright_edge. Defaults toleft_edge.mode: (Optional) The mode for cursor placement. Currently onlyinsertis supported, defaults tonormal.