barbar.nvim icon indicating copy to clipboard operation
barbar.nvim copied to clipboard

[Request] buffer order by frequency

Open skt041959 opened this issue 5 years ago • 3 comments

Thanks for create this great bufferline tool! It has been much more flexible than airline. I tend to open a lot of buffers in my workspace and save the session with Startify. It would be neat if barbar had a feature to

  1. put the most frequently used buffers together
  2. persist the order with a global variable.

I'm new to Lua, but quiet familiar with vim. Just post here for discussion. I will study it too.

Thanks

skt041959 avatar Jan 07 '21 07:01 skt041959

It would be interesting. Could you open separate issues for each request and provide more details on the first one? Like how do you see it working, and what rules it would follow.

romgrk avatar Jan 07 '21 21:01 romgrk

We can choose from following two methods:

  1. Use autocmd for BufEnter to count the times that we jump into the buffers
  2. Use timer to check which buffer is visible and raise the score of those buffers. It could be hard to determinate whether vim is idle

I think the plugin should not automatically change the buffer order, but provide a command like BufferReorderByFreq to let the user use it.

skt041959 avatar Jan 11 '21 09:01 skt041959

I see. I don't have enough time to implement this but I'll leave open, if I have more time in the future I may revisit, or if you wanna submit a PR I'd accept it.

Comments:

  • For BufEnter, there would need to be a small delay before increasing score, some people use BufferNext/Previous repeatedly to switch and that can fuck the score without the delay
  • Scoring function needs to take in account time of visit

romgrk avatar Jan 15 '21 01:01 romgrk