j-morano / buffer_manager.nvim

A simple plugin to easily manage Neovim buffers.
MIT License
232 stars 12 forks source link

Feature Request: Alphabetical Sort of Buffers #29

Closed DennisTheMenace780 closed 4 months ago

DennisTheMenace780 commented 10 months ago

Hey there! Still continuing to use this plugin and it's been fantastic so far!

As I've progressed in use, i've found that in our orgs code base that I might often need to have 2-3 different file types up, with various extensions on them. An example would be like this in the buffer manager:

Reviews.tsx
Comms.test.tsx
Reviews.loader.tsx
Reviews.test.tsx
Comms.loader.tsx

And you can imagine that as you're going to and from buffers, deleting them, working, etc, that this can become somewhat chaotic. I do know that you have an option to move buffers around with remaps, but i'm curious if it would be much work to extend the manager to do some kind of default sort when its updated?

I think this takes some agency away from the user, which can be great, but when I am in the thick of things and exploring around, I find that it would actually be really helpful if these were presorted.

Would this be a feature that is difficult to introduce? I envision that a user could set the sort order as Ascending or Descending as part of the configuration. Thoughts on this suggestion?

j-morano commented 9 months ago

Thanks for your feedback. I think it is a good idea. I have not had time to look into it. I hope to have time to implement it by the end of the year.

phenax commented 9 months ago

I wonder if something like this would be good enough here -

vim.keymap.set({ 't', 'n' }, '<localleader>b', function()
  require('buffer_manager.ui').toggle_quick_menu()
  vim.defer_fn(function() vim.cmd'%sort' end, 50) -- %sort! for descending
end, { noremap = true })
j-morano commented 4 months ago

Hello. I have created the branch order-buffers with this feature. If you could give it a try to see if it works as expected, I would appreciate it.