-
-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add snippets via function only. #338
Conversation
@L3MON4D3 I think it will be good to tag the last commit before the change, so users can use the tag if they wanna delay moving to the new api. |
Oh yes, that makes sense. Maybe a branch would also work? That could be created right now and kept up-to-date during the deprecation-period. |
I'm currently removing duplicate snippets after all snippets have been loaded (both |
yes, that will work as well |
Anyway, I think adding a helper function that accepts a table (like the one we expose now) and calls |
Ah, right. I think the best way would be invalidating the snippet-objects, so they won't match and won't show up in lists, eg. cmp (Basically set hidden and prevent matching the snippet during expand). Then you could get all snippets and iterate over those, invalidating the ones that match. |
Yess, that's true. I'm a tiny bit unsure about the changed semantics (current |
Removing should work now. |
This makes sense, thanks! |
Change doc to refer to these functions for adding snippets.
Makes more sense, config has to require some of the modules for the default-config, while they themselves only need access to the config at runtime. Basically prevent circular dependencies.
Set via `config.snip_env`.
before: { snippets = {<snippets>}, autosnippets = {<autosnippets>} } now: {<snippets>}, {<autosnippets>} As autosnippets are used much less than snippets, this should make writing these files a bit more comfortable. Bonus: it also keeps this format compatible with the one used previously.
This can almost be merged, I'll add some improvements to |
Also use that function in lua-loader.
Described in DOC.md.
pre: also shows ignored files.
Merged! But rebased, so closing this manually. |
Breaking change documented here: L3MON4D3/LuaSnip#338
The goal of this PR is to switch from directly setting/getting snippets via
ls.snippets
to doing so via some function.This is necessary to decouple the user-api from the internal structure of the snippet-storage (and should've been done a long time ago!), thereby enabling us to improve the internals (eg. in #334) without breaking changes in the future.
Adding snippets works fine using the functions, the on-demand-loading of snippets described in the wiki will not work any longer, and should be replaced by an (imo) autocommand-based implementation, similar to
lazy_load
inloaders
.After this is merged there will be a short deprecation-period (I'm thinking of two weeks, but feel free to suggest otherwise) during which existing direct access to the
ls.snippet
orls.autosnippet
-tables should be replaced by calls toadd_snippets(ft, snippets, opts)
orget_snippets(ft, opts)
.As always, feel free to discuss these proposed changes.
If you have any workflows that rely on the current layout of the snippet-tables, please mention them here so we can find a solution.