function get_active_snip()
-> any
returns the currently active snippet (not node!).
function match_snippet(line: any, type: any)
-> any
returns matching snippet (needs to be copied before usage!) and its expand- parameters(trigger and captures). params are returned here because there's no need to recalculate them.
function get_snippets(ft: any, opts: any)
-> table
ft:
- string: interpreted as filetype, return corresponding snippets.
- nil: return snippets for all filetypes:
{
lua = {...},
cpp = {...},
...
}
opts: optional args, can contain
type
, either "snippets" or "autosnippets".
return table, may be empty.
function get_context(snip: any)
-> table
function available()
-> table
function safe_jump(node: any, dir: any, no_move: any)
-> any
function jump(dir: -1|1)
-> boolean
check if the jump was successful.
dir: direction
| -1 -- for previous
| 1 -- for next
function jumpable(dir: -1|1)
-> boolean
check if it's possible to jump forward or backward to another node.
dir: direction
| -1 -- for previous
| 1 -- for next
function expandable()
-> boolean
check if a snippet can be expanded at the current cursor position.
function expand_or_jumpable()
-> any
function in_snippet()
-> boolean
returns true if the cursor is inside the current snippet.
function expand_or_locally_jumpable()
-> any
function snip_expand(snippet: any, opts: any)
-> any
opts.clear_region: table, keys from
and to
, both (0,0)-indexed.
function expand()
-> boolean
expands the snippet at(before) the cursor
function expand_auto()
function expand_repeat()
function expand_or_jump()
-> boolean
return true and expand snippet if expandable, return false if not.
function lsp_expand(body: any, opts: any)
function choice_active()
-> boolean
returns true if inside a choiceNode.
function change_choice(val: any)
function unlink_current()
function active_update_dependents()
function store_snippet_docstrings(snippet_table: any)
function load_snippet_docstrings(snippet_table: any)
function unlink_current_if_deleted()
Checks if the current snippet was deleted, if so, it is removed from the jumplist This is not 100% reliable as luasnip only sees the extmarks and their begin/end may not be on the same position, even if all the text between them was deleted
function exit_out_of_region(node: any)
-> boolean
function filetype_extend(ft: any, extend_ft: any)
ft string, extend_ft table of strings.
function filetype_set(ft: any, fts: any)
ft string, fts table of strings.
function cleanup()
clears all snippets. Not useful for regular usage, only when authoring and testing snippets
function refresh_notify(ft: string)
Triggers an autocmd that other plugins can hook into to perform various cleanup for the refreshed filetype
Useful for signaling that new snippets were added for the filetype ft
@param ft
— filetype
function setup_snip_env()
function get_id_snippet(id: any)
-> any
returns snippet corresponding to id
function add_snippets(ft: any, snippets: any, opts: any)
function clean_invalidated(opts: any)
clean invalidated snippets from internal snippet storage. Invalidated snippets are still stored, it might be useful to actually remove them, as they still have to be iterated during expansion.
opts
may contain:
inv_limit
: how many invalidated snippets are allowed. If the number of invalid snippets doesn't exceed this threshold, they are not yet cleaned up.
A small number of invalidated snippets (<100) probably doesn't affect runtime at all, whereas recreating the internal snippet storage might.