2.1.0
Deprecations and Breaking Changes
Only a deprecation in this release: the history
-option is superseded by the more granular keep_roots
, link_roots
, and link_children
. Take a look at the documentation for more information on the new options.
Highlights
Snippet-insertion (#941)
Before this PR, a newly-expanded snippet was always set up such that after jumping through it, the node that was active during expansion was entered again. This was very easy to implement, but unfortunately can cause annoying issues when the active node is not close to the expanded snippet (jumping across the whole buffer).
The improved snippet-insertion prevents issues like this by linking the jumps of newly-expanded snippets not based on active node, but based on buffer-position. There is some information on it here.
The following recording shows the new behaviour, for example how snippets are traversed based on buffer-position, and how inserting snippets into a node properly activates it (visible due to orange dots indicating an active choiceNode)
1699875457.mp4
Another nice feature enabled by the datastructures that have to be maintained to allow this behaviour is that given some buffer-position (for example the cursor), we can look for the node that is located there. See this entry in the wiki for an example of this.
Treesitter-postfix (#980)
Another pretty cool feature: where previously postfix-snippets could only capture text matching some pattern, treesitter-postfix-snippets can capture text from treesitter-queries!
Since captures from the query are also made available to the snippet (via snippet.env
), this may be a quick way to quickly refactor, see for example the following:
ts_post({
matchTSNode = {
query = [[
(function_declaration
name: (identifier) @fname
parameters: (parameters) @params
body: (block) @body
) @prefix
]],
query_lang = "lua",
},
trig = ".var"
}, fmt([[
local {} = function{}
{}
end
]], {
l(l.LS_TSCAPTURE_FNAME),
l(l.LS_TSCAPTURE_PARAMS),
l(l.LS_TSCAPTURE_BODY),
}))
The documentation has another example, and describes the various options.
Luasnip-Luarock (#1050)
Finally, luasnip is now available as a luarock, which means it can be added by rocks.nvim
.
What's Changed
- fix: catch undocumented edge case in scandir() by @troiganto in #966
- docs: fix snip-env-src by @b0ae989c in #975
- Update DOC.md Troubleshooting section by @kylefhartzenberg in #981
- feat: Allow
desc
to set snippet description by @bew in #1005 - [WIP] Treesitter-postfix Support by @TwIStOy in #980
- Add nil for type opt for parse_snippet by @philolo1 in #1016
- Fix lazy install tag in README.md by @pockethook in #1024
- Improve snippet-insertion. by @L3MON4D3 in #941
- Fix links to DOC.md in README.md by @treequin in #1043
- Use event.buf directly to get bufnr by @xu-cheng in #1047
- Consistent backtick use by @Stevenjin8 in #1054
- Use builtin methods for getting selection. by @L3MON4D3 in #1013
- feat: publish tagged releases to luarocks by @mrcjkb in #1050
New Contributors
- @troiganto made their first contribution in #966
- @b0ae989c made their first contribution in #975
- @kylefhartzenberg made their first contribution in #981
- @bew made their first contribution in #1005
- @TwIStOy made their first contribution in #980
- @philolo1 made their first contribution in #1016
- @pockethook made their first contribution in #1024
- @treequin made their first contribution in #1043
- @xu-cheng made their first contribution in #1047
- @Stevenjin8 made their first contribution in #1054
- @mrcjkb made their first contribution in #1050
A big Thank You! to all contributors to LuaSnip ❤️ :)
Full Changelog: v2.0.0...v2.1.0