Is it possible to store "user's custom metadata" within a snippet, and get that data after the snippet expands? #730
Replies: 7 comments 6 replies
-
Uhh, yeah there is actually a PR for something like this, see #719. What you can do right now, is identify snippets based on their id ( Besides that, I don't quite understand how the time a snippet was created at helps with identifying it, wouldn't it make more sense to where it is defined? |
Beta Was this translation helpful? Give feedback.
-
Well, you'll need to find the start row to end row of that file anyway, so I thought about using
If I can get which file + the row start - row end of that snippet with snippet.id then it's even better. But I'm not sure I can do that.. 🤔 |
Beta Was this translation helpful? Give feedback.
-
Come to think of it, I could just use |
Beta Was this translation helpful? Give feedback.
-
I'm planning to use something like: cs({
trigger = {
trig = "hello",
metadata = {
created_at = "12/12/2022 19:00",
}
},
nodes = fmt(
[=[
hello {}
]=],
{
i(1, "world"),
}
),
}) |
Beta Was this translation helpful? Give feedback.
-
There is a PR in progress for adding custom metadata to snippets #719 maybe you can have a look and bring your opinions/ideas there. |
Beta Was this translation helpful? Give feedback.
-
Thank you @leiserfg @L3MON4D3 for the direction to the PR. I'm thinking of a different approach, please correct me if I'm wrong:
Another approach would be in the user's |
Beta Was this translation helpful? Give feedback.
-
Sorry I missed this part. What I meant was to get the row start - end at the snippet file itself (where it was created, not the expanded snippet). So I can rip that part out and replace with the newly edited snippet (I'm still figuring out a way for the user to edit snippets on the fly, without having to "physically" go to where the snippet was created / defined 😄 ).
Yup, I really don't know a better way to approach this.
Having to manually go to the snippet file, edit it, then jump back to the work you're working on is disruptive, which I'm finding a way to solve. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! Sorry for the convoluted title 😅 , but I'm working on a Nvim plugin to quickly create & edit LuaSnip snippets.
One problem I'm running into is how to identify which already-existing snippet the user wants to edit.
The solution I'm thinking of is something like:
opt
that records the exact time the snippet was created.LAST_TRIGGERED_SNIPPET_CREATION_TIME
global variable is updated.Is there a way in LuaSnip that can solve this problem? I don't really want to pollute the
desc
ordocstring
opts tho 🤔Beta Was this translation helpful? Give feedback.
All reactions