-
-
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
Snippet Priority. #334
Snippet Priority. #334
Conversation
One rather subtle problem: the current approach to lazy loading lua-snippets ( |
That's because our loaders are a hack on top of the original implementation that was thought to only have lua written snippets 😉. What do you think of adding a different table for the loaders and keeping |
I mean, using the |
Oh, I meant the other I think having all snippets in one table is a bit nicer, but you're right about the downside of heavily utilizing |
The idea seems nice, we could provide a function that takes a table just like the one we have now so users can replace do: ls.snippets = { ... } with ls.define_snippets{...} -- or any other name And maybe a |
Great, it won't look as nice though, we'll still need some arguments, I'm currency thinking of The best way to introduce that change would probably be to deprecate direct-adding soon while introducing the new functions everywhere (and maybe printing a depreciation-warning via |
Before this can be merged, we'll have to switch to only adding snippets via a function, at least that will make the merge much smoother and allow us a deprecation-period where plugins that depend on luasnip can adapt to the changes. |
hi, just a question (might be a bit related to this PR), do you think it would be possible to implement a "noremap" option to a trigger, meaning that it will override the others snippets loaded from external sources for exemple, and not "coexist" feeling like it's duplicated because it has the same trigger. |
Yeah that could be doable. The underlying problem is that duplicate trigger lead to duplicate entries in eg. |
Yes, so there's two cases which cause that, first it's when I create my own
snippet, for exemple if have my own console.log snippet with same trigger
as the one loaded from vscode snippets, there's a duplicate, and the second
one is from extended_types which can often bring duplicates.
|
Would changing the label in cmp to the snippets name (which can be changed already, it just defaults to the trigger) work for you? |
What do you mean ? do you have an example ? |
Currently s({trig = "trigger", name = "name"}, {...}) the |
Oh, with menu I meant the PUM in the screenshot. One snippet could show up as eg. Duplicate snippets from loaders can be prevented by iterating over all snippets and removing the duplicates, but that won't be possible with snippets from |
86aa341
to
890200c
Compare
if nil is the default, accessing it in snippetProxy will lead to instantiation.
plugins shouldn't rely on indices into snippet-collections.
I probably won't be able to properly resolve all merge conflicts today, so no Breaking Changes for now :( |
This PR will not yet add priority to the |
Hi, sorry I forgot to answer you, but the priority feature actually did the job, and also used filetype_set instead of extend. |
Allow giving snippets a priority.
For now, only the groundwork is implemented, I'm thinking of adding functions like
add_snippets(filetype, snippets, opts)
, where opts can be used to specify priority, autosnippets and similar, but it'll still be possible to set snippets with a default-priority (1000, for now) directly vials.snippets
.This PR will also include patches for passing a priority to(lazy_)load