github L3MON4D3/LuaSnip v2.0.0
2.0.0

latest releases: v2.3.0, v2.2.0, v2.1.1...
16 months ago

Breaking Changes

Drop support for neovim < 0.7.
Since this probably affects very few users, and enables access to some better api, this decision was obvious.

Highlights

Multi-Context snippets

This essentially makes it possible to trigger one snippet in different ways. For example, one may want to trigger a snippet with a short trigger manually, but use a longer one as an autotrigger. Or, expand a snippet automatically in comments, and manually otherwise (or, and maybe more likely, vice versa).

The DOC.md-entry is pretty comprehensive, so I won't repeat it here.

Snippet-Source

If loaders_store_source is set to true in ls.setup, the loaders will attach information about the source of a snippet (like file, row, column of its definition).
We of course also include a consumer for this information: luasnip.extras.snip_location can jump to the source of the current snippet!
Combined with auto-reload provided by the loaders, this allows quick edits of the current snippet, for example if it does not behave correctly.

For easy access, create a command for calling the function.

vim.api.nvim_create_user_command("LuaSnipEditS", require("luasnip.extras.snip_location").jump_to_active_snippet, {})
1689692600.mp4

To work correctly for all loaders, this needs treesitter, and parsers for json (jsonc if there are snippet-files in that format) and lua.

More details here and here

Key-indexer

This can be used to easily refer to nodes (for example, if their text should be passed to a dynamic/functionNode) several levels deep in a snippet, simply by a unique identifier. Once again, the documentation has some details+examples.

.code-snippets

Support for the .code-snippets-format used by vscode was also added since the last release. It is useful for project-specific snippets, and a bit more compact than the other formats, since only a single file has to be added, not a directory (and god forbid, not a package.json which has to correctly list all files).
More here.

More trigger-types!!

Finally, support for actual regexes as snippet-triggers. Supports ecma and vim-flavoured regex, as well as completely custom behaviour. The documentation (look for the trigEngine-entry in the first list) has some more details.

PR's since last release:

Big Thank You! to all new contributors :)

Full Changelog: v1.2.1...v1.3

Don't miss a new LuaSnip release

NewReleases is sending notifications on new releases.