Skip to content

Commit

Permalink
Add info on the load/store-functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
L3MON4D3 committed Aug 20, 2021
1 parent 07a00c8 commit 2f009c0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,25 @@ Other issues will have to be handled manually by checking the contents of eg.
`snip.env` or predefining the docstring for the snippet:

```lua
s({trig = "(%d)", regTrig = true, docstring = "repeatmerepeatmerepatme"}, {
s({trig = "(%d)", regTrig = true, docstring = "repeatmerepeatmerepeatme"}, {
f(function(args)
return string.rep("repeatme ", tonumber(args[1].captures[1]))
end, {})
}),
```

# DOCSTRING-CACHE

Although generation of docstrings is pretty fast, it's preferable to not
redo it as long as the snippets haven't changed. Using
`ls.store_snippet_docstrings(ls.snippets)` and its counterpart
`ls.load_snippet_docstrings(ls.snippets)`, they may be serialized from or
deserialized into the snippets.
Both functions accept a table structured like `ls.snippets`, ie.
`{ft1={snippets}, ft2={snippets}}`.
`load` should be called before any of the `loader`-functions as snippets loaded
from vscode-style packages already have their `docstring` set (`docstrings`
wouldn't be overwritten, but there'd be unnecessary calls).

The cache is located at `stdpath("cache")/luasnip/docstrings.json` (probably
`~/.cache/nvim/luasnip/docstrings.json`).

0 comments on commit 2f009c0

Please sign in to comment.