-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(extras): added open_snippet_list #652
Conversation
Nice!
Oh, yes that would be great. Could extract the common part of getting available snippets, and then have the two functions collecting the information depend on that.
regex 🤮 :P
Good choice, very unfortunate that folding is per-window, that's a bit annoying (at least for us :D) |
Yeah! I don't know if you want to do this in this PR or in a separate one.
Yeah regex makes me puke too :(. Seems that setting the foldmethod to indent fixed everything. I never use folding so I'm in uncharted waters here haha. If foldmethod set to indent is not enough I'll take a look into manual folding (I hope indent is enough lol) |
Doing that in this one should be fine, we introduce the potential for this abstraction here, I think that justifies it :D
Yeah, manual folding would probably be overcomplicating it 👍 |
Sounds good! I would like to get some of the stuff above resolved first since I feel stuff is piling up. But my initial thoughts on this was to 'inject' the get_context into the available function so something like: This would be in function available(get_context)
get_context = get_context or 'default function here'
end Then we can use whatever get_context function we want while keeping the available function untouched. |
Oh yeah, nice!! 👍 |
(Sorry for the force pushes lol) Ok so I bring some updates! Hopefully I'm heading in the right direction here Changesluasnip/init.luaIn the available function I added a opts = opts or {}
opts.get_context = opts.get_context or get_context Using the former would mean that if someone passes in an empty object for example Edit: Done in 22e2370 But with that we have flexibility to use whatever get_context function we want extras/snippet_list.luaI added an opts = opts or {
get_name = get_name,
printer = printer,
win_opts = win_opts,
buf_opts = buf_opts
} Same issue was above, it might be better to do something like opts = opts or {}
opts.get_name = opts.get_name or get_name
etc... Edit: Done in 22e2370 get_name functionIt's as we discussed, asimple function that takes in a bufnr and returns the name for the buffer, you can pass in whatever function you would like that returns a string printer functionTakes in snippets and returns a string. At the moment we are only using win_optsTable of extra options to be set on the window. set_win_opts sets these options. I use these 2 to set the folding at the moment buf_optsTable of extra options to set on the buffer. set_buf_opts sets these options. I use these 2 to set the filetype to lua. (I know you want something like nvim tree but in the meantime I kept this here just to get syntax highlighting) make_scratch_buffer functionJust moved the setting options for the scratch buffer to this function to clean up the open_snippet_list function So hopefully this is looking more like you were picturing in terms of configuration capability. Discussion PointsPretty Print Stuff
I think I get it now! Similar to what packer does when you sync/update plugins. Gotcha. That would definitely be awesome, atm it's a little over my head though. I'm not sure how nvim-tree or packer make stuff collapsible and get highlighting/icons for example. I would have to go dig in their repos and see what they are doing. In the meantime I left the folding method and the filetype to lua (For syntax highlighting purposes). With the configuration options we have now though it would be really easy to add whatever pretty-printer/buffer options/window options that you would like. |
Oh, do not worry about that at all
Nice! 👍
Good idea to make buf/win-options configurable
Ahhh, yeah syntax highlighting makes sense.
Yeeeeeeeeah right, that's even more common 👍
Don't worry about that, this doesn't have to be perfect from the get-go. Updates to this can be done as non-breaking changes, so we're pretty flexible here imo.
Very clean! I'll take a look at the code now :D |
Okay, small things all, I like the general direction, nice work 👍 |
😂 Hmm just brainstorming here |
MHMM |
Sorry for the inactivity. Have been a little busier. I made the modifications suggested! Hopefully it's closer to what we want 😎 |
Oh, that's far from inactive, don't worry :D |
Okay, I think this should be it, now.. Documentation :D |
Added some docs for Snippet List! Let me know what you think. Once everything is ready to go I can squash the previous commits having to do with implementing snippet_list so it looks like |
Hey, very sorry for not getting back earlier, I must've missed your previous messages somehow, and didn't think to check on this PR until now😅 |
No worries! Thought you might be busy haha. I'll be travelling tomorrow but I'll take a look over the next few days see if we can finish this off before christmas or new years. We're almost there! |
Nice, sounds good 👍 :D |
Squashing of commits is done! |
Okay I'm so sorry, I missed two minor issues:
I'm taking another 10000%-close look to make sure those are the last roadblocks, would you clear them? :D |
Okay, 10000%-close look done, everything else looks great :) |
Done! Edit: I'll squash those commits once it's approved. |
Pictures look good, doc too except that small nit, thanks for taking care of it :) |
Haa okay, that's it, perfect, I've got nothing more to ask, you're free xD |
Hah, nice xD Okay, thank you sooo much for sticking through this entire process. I feel like I've asked a bit too much, and those small redesigns we did halfway through could've been separate PRs, but I'm very happy with this being the initial result because it's very flexible and we should be able to extend it without any breaking changes. |
No problem! Glad I could contribute a small part to this plugin. Thank you for your work! |
Implements functionality discussed in #607
Here's a showcase of what it looks like:

A couple of thoughts:
The available and the get_context function are essentially the same as the ones in
luasnip/init.lua
the only difference is adding the docstring in get_context and using that new get_context in the available function. There might be a way to refactor something so that there is less code repetition if that's something you would be interested in.I'm not great at regexes so I did the best I could with the folding stuff haha. I think it's fine right now but it can be a little finnicky, for example if you try to use telescopes buffer fuzzy finder in that window you can get something like this:

At first I was just looking to open a new buffer and making that the current one, but making so that folding is available makes that hard since it's a per window and not a per buffer setting. So I went back to the vertical split implementation.
Let me know what you think, if everything seems good to you the only thing missing would be adding it to the documentation.