Skip to content

Commit 24d84c6

Browse files
L3MON4D3github-actions[bot]
authored andcommitted
Auto generate docs
1 parent 9cef330 commit 24d84c6

File tree

1 file changed

+67
-5
lines changed

1 file changed

+67
-5
lines changed

doc/luasnip.txt

+67-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*luasnip.txt* For NVIM v0.8.0 Last change: 2023 March 13
1+
*luasnip.txt* For NVIM v0.8.0 Last change: 2023 March 19
22

33
==============================================================================
44
Table of Contents *luasnip-table-of-contents*
@@ -36,6 +36,7 @@ Table of Contents *luasnip-table-of-contents*
3636
- Filetype-Functions |luasnip-extras-filetype-functions|
3737
- Postfix-Snippet |luasnip-extras-postfix-snippet|
3838
- Snippet List |luasnip-extras-snippet-list|
39+
- Snippet Location |luasnip-extras-snippet-location|
3940
16. Extend Decorator |luasnip-extend-decorator|
4041
17. LSP-Snippets |luasnip-lsp-snippets|
4142
- Snipmate Parser |luasnip-lsp-snippets-snipmate-parser|
@@ -56,8 +57,9 @@ Table of Contents *luasnip-table-of-contents*
5657
24. Events |luasnip-events|
5758
25. Cleanup |luasnip-cleanup|
5859
26. Logging |luasnip-logging|
59-
27. Config-Options |luasnip-config-options|
60-
28. API |luasnip-api|
60+
27. Source |luasnip-source|
61+
28. Config-Options |luasnip-config-options|
62+
29. API |luasnip-api|
6163
>
6264
__ ____
6365
/\ \ /\ _`\ __
@@ -1674,6 +1676,26 @@ Let’s recreate the custom display example above:
16741676
<
16751677

16761678

1679+
SNIPPET LOCATION *luasnip-extras-snippet-location*
1680+
1681+
This module can consume a snippets |luasnip-source|, more specifically, jump to
1682+
the location referred by it. This is primarily implemented for snippet which
1683+
got their source from one of the loaders, but might also work for snippets
1684+
where the source was set manually.
1685+
1686+
`require("luasnip.extras.snip_location")`: *
1687+
`snip_location.jump_to_snippet(snip, opts)` Jump to the definition of `snip`. *
1688+
`snip`: a snippet with attached source-data. * `opts`: `nil|table`, optional
1689+
arguments, valid keys are: * `hl_duration_ms`: `number`, duration for which the
1690+
definition should be highlighted, in milliseconds. 0 disables the highlight. *
1691+
`edit_fn`: `function(file)`, this function will be called with the file the
1692+
snippet is located in, and is responsible for jumping to it. We assume that
1693+
after it has returned, the current buffer contains `file`. *
1694+
`snip_location.jump_to_active_snippet(opts)` Jump to definition of active
1695+
snippet. * `opts`: `nil|table`, accepts the same keys as the `opts`-parameter
1696+
of `jump_to_snippet`.
1697+
1698+
16771699
==============================================================================
16781700
16. Extend Decorator *luasnip-extend-decorator*
16791701

@@ -2762,7 +2784,43 @@ print a short message to the log.
27622784

27632785

27642786
==============================================================================
2765-
27. Config-Options *luasnip-config-options*
2787+
27. Source *luasnip-source*
2788+
2789+
It is possible to attach, to a snippet, information about its source. This can
2790+
be done either by the various loaders (if it is enabled in `ls.setup`
2791+
(|luasnip-config-options|, `loaders_store_source`)), or manually. The attached
2792+
data can be used by |luasnip-extras-snippet-location| to jump to the definition
2793+
of a snippet.
2794+
2795+
It is also possible to get/set the source of a snippet via API:
2796+
2797+
`ls.snippet_source`:
2798+
2799+
2800+
- `get(snippet) -> source_data`:
2801+
Retrieve the source-data of `snippet`. `source_data` always contains the key
2802+
`file`, the file in which the snippet was defined, and may additionally
2803+
contain `line` or `line_end`, the first and last line of the definition.
2804+
- `set(snippet, source)`:
2805+
Set the source of a snippet.
2806+
- `snippet`: a snippet which was added via `ls.add_snippets`.
2807+
- `source`: a `source`-object, obtained from either `from_debuginfo` or
2808+
`from_location`.
2809+
- `from_location(file, opts) -> source`:
2810+
- `file`: `string`, The path to the file in which the snippet is defined.
2811+
- `opts`: `table|nil`, optional parameters for the source.
2812+
- `line`: `number`, the first line of the definition. 1-indexed.
2813+
- `line_end`: `number`, the final line of the definition. 1-indexed.
2814+
- `from_debuginfo(debuginfo) -> source`:
2815+
Generates source from the table returned by `debug.getinfo` (from now on
2816+
referred to as `debuginfo`). `debuginfo` has to be of a frame of a function
2817+
which is backed by a file, and has to contain this information, ie. has to be
2818+
generated by `debug.get_info(*, "Sl")` (at least `"Sl"`, it may also contain
2819+
more info).
2820+
2821+
2822+
==============================================================================
2823+
28. Config-Options *luasnip-config-options*
27662824

27672825
These are the settings you can provide to `luasnip.setup()`:
27682826

@@ -2829,10 +2887,14 @@ These are the settings you can provide to `luasnip.setup()`:
28292887
warnings, consider adding the undefined globals to the globals recognized by
28302888
`lua-language-server` or add `---@diagnostic disable: undefined-global`
28312889
somewhere in the affected files.
2890+
- `loaders_store_source`, boolean, whether loaders should store the source of the
2891+
loaded snippets. Enabling this means that the definition of any snippet can be
2892+
jumped to via |luasnip-extras-snippet-location|, but also entails slightly
2893+
increased memory consumption (and load-time, but it’s not really noticeable).
28322894

28332895

28342896
==============================================================================
2835-
28. API *luasnip-api*
2897+
29. API *luasnip-api*
28362898

28372899
`require("luasnip")`:
28382900

0 commit comments

Comments
 (0)