Skip to content
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

Order options for Buftabline #74

Open
ewengillies opened this issue Jul 21, 2020 · 4 comments
Open

Order options for Buftabline #74

ewengillies opened this issue Jul 21, 2020 · 4 comments

Comments

@ewengillies
Copy link

Hi! Love buftabline, its great.

#61 already mentioned something similar, but is it possible to order the buffer-tabs alphabetically by file name? So, opening a new tab would just insert the buffer into the correct, ordered space. That, or a function that orders the tabs.

Is this possible already? Or would we need a new PR?

Thanks for the plugin :)

@ap ap added the enhancement label Sep 29, 2020
@ap
Copy link
Owner

ap commented Sep 29, 2020

Sorry I missed this issue entirely.

There is no such feature currently.

There are requests for several related features that so far I’ve not accepted, for reasons outlined in #8 (though only a few of those reasons apply to this issue or #61).

But your phrasing is making me think it might be doable as a hook for reordering the return value of the user_buffers function. which is an angle I don’t remember considering before, and is making me wonder whether they might all be doable in the kind of lightweight way I’d want this to be.

@ewengillies
Copy link
Author

ewengillies commented Sep 29, 2020

I'm not too up on my vimscript, but it looks like user_buffers filters out quickfix buffers from the buftabline display. It then returns an array of buffer numbers we want to display.

From your previous MRs, your aversion to a reordering of buffers is rooted in simplicity, and rightly so! Maintaining a registry of buffer orders would be overkill for a 200 line plugin.

If we did instead put a hook in that reordered user_buffers, I guess we still might run into limitations with bnext, bprevious, etc. in that they wouldn't know about any hook we put into user_buffers. At that point, the utility of buffers that look like tabs diminishes significantly. Is that right, or did I miss something?

@ap
Copy link
Owner

ap commented Sep 30, 2020

Mainly user_buffers filters out unlisted buffers. The point of the function is to get the list of buffers that actually represent something the user is editing – without the special-purpose buffers used by various plugins and whatnot, which should not be displayed as tabs. The utility of that should be clear.

The point is that buffers are displayed in the order that the function returns them, and it returns them in increasing buffer number order. This is the same order Vim uses anywhere it needs an ordering for buffers (such as bnext/bprevious) – so the plugin doesn’t need to provide any functionality to manage or navigate buffers. All it does is display the buffer list.

This isn’t about code bloat so much as it is about minimising the amount of user-visible functionality.

What I am now thinking is that if there was simply a hook to return the list of buffers in a user-defined order, that alone would be enough – not just to configure the display order in the plugin, but also to let users define in .vimrc whatever buffer management/navigation maps or commands they want. However, everywhere a next/previous buffer is needed, one would have to write some boilerplate code to derive it from the list, so the cherry on top would be a pair of utility functions to encapsulate that. That’s a nicely limited amount of surface area, and only exposed to users who seek it out.

Now I need to try to implement one of the requested custom orderings to see whether this design pans out in practice like it promises to in my head, and what the details should look like. (In particular whether the hook should sit inside or outside the filter in user_buffers.)

@ap ap pinned this issue Oct 7, 2020
@gegnew
Copy link

gegnew commented Apr 7, 2021

It would be nice to allow i.e. alphabetical ordering of buftabs 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants