vim.snippet
Methods4
function M.expand(input: string) -> nil
Expands the given snippet text. Refer to https://microsoft.github.io/language-server-protocol/specification/#snippet_syntax for the specification of valid input.
Tabstops are highlighted with |hl-SnippetTabstop| and |hl-SnippetTabstopActive|.
function M.jump(direction: vim.snippet.Direction) -> nil
Jumps to the next (or previous) placeholder in the current snippet, if possible.
By default <Tab> is setup to jump if a snippet is active. The default mapping looks like:
vim.keymap.set({ 'i', 's' }, '<Tab>', function()
if vim.snippet.active({ direction = 1 }) then
return '<Cmd>lua vim.snippet.jump(1)<CR>'
else
return '<Tab>'
end
end, { desc = '...', expr = true, silent = true })
Parameters
directionvim.snippet.DirectionNavigation direction. -1 for previous, 1 for next.
Returns
- nil
function M.active(filter: vim.snippet.ActiveFilter | nil) -> boolean
Returns true if there's an active snippet in the current buffer, applying the given filter if provided.
Parameters
filtervim.snippet.ActiveFilter | nilFilter to constrain the search with:
direction(vim.snippet.Direction): Navigation direction. Will returntrueif the snippet
can be jumped in the given direction.
Returns
- boolean
function M.stop() -> nil
Exits the current snippet.
Fields2
M._sessions: table
M._session : vim.snippet.Session