Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
2.1.0 source code.tar.gz | 2023-11-13 | 296.0 kB | |
2.1.0 source code.zip | 2023-11-13 | 363.6 kB | |
README.md | 2023-11-13 | 5.7 kB | |
Totals: 3 Items | 665.3 kB | 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)
https://github.com/L3MON4D3/LuaSnip/assets/41961280/7dea57aa-17da-4ce4-b0cd-d214d6b30e93
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:
:::lua
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 https://github.com/L3MON4D3/LuaSnip/pull/966
- docs: fix snip-env-src by @b0ae989c in https://github.com/L3MON4D3/LuaSnip/pull/975
- Update DOC.md Troubleshooting section by @kylefhartzenberg in https://github.com/L3MON4D3/LuaSnip/pull/981
- feat: Allow
desc
to set snippet description by @bew in https://github.com/L3MON4D3/LuaSnip/pull/1005 - [WIP] Treesitter-postfix Support by @TwIStOy in https://github.com/L3MON4D3/LuaSnip/pull/980
- Add nil for type opt for parse_snippet by @philolo1 in https://github.com/L3MON4D3/LuaSnip/pull/1016
- Fix lazy install tag in README.md by @pockethook in https://github.com/L3MON4D3/LuaSnip/pull/1024
- Improve snippet-insertion. by @L3MON4D3 in https://github.com/L3MON4D3/LuaSnip/pull/941
- Fix links to DOC.md in README.md by @treequin in https://github.com/L3MON4D3/LuaSnip/pull/1043
- Use event.buf directly to get bufnr by @xu-cheng in https://github.com/L3MON4D3/LuaSnip/pull/1047
- Consistent backtick use by @Stevenjin8 in https://github.com/L3MON4D3/LuaSnip/pull/1054
- Use builtin methods for getting selection. by @L3MON4D3 in https://github.com/L3MON4D3/LuaSnip/pull/1013
- feat: publish tagged releases to luarocks by @mrcjkb in https://github.com/L3MON4D3/LuaSnip/pull/1050
New Contributors
- @troiganto made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/966
- @b0ae989c made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/975
- @kylefhartzenberg made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/981
- @bew made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/1005
- @TwIStOy made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/980
- @philolo1 made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/1016
- @pockethook made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/1024
- @treequin made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/1043
- @xu-cheng made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/1047
- @Stevenjin8 made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/1054
- @mrcjkb made their first contribution in https://github.com/L3MON4D3/LuaSnip/pull/1050
A big Thank You! to all contributors to LuaSnip :heart: :)
Full Changelog: https://github.com/L3MON4D3/LuaSnip/compare/v2.0.0...v2.1.0