[feature request] Save the buffer list to file
tiagoprn opened this issue · 6 comments
Just installed your plugin today, and thanks to you now I have a saner way to deal with buffers on nvim. Awesome work!
Can you implement a function to save the buffer_manager list to a file, so that we can map it? It would be awesome if it prompted for the file name to save (so I could save anywhere on my filesystem) - autocomplete filesystem paths would be fantastic, but if too hard to code I could live without that.
That would really help me ditch the session plugins on my configuration, and use your plugin solely for all my buffer needs. =D
Thank you!
Hi! Thanks for your feedback, I am glad you like the plugin.
Regarding the feature, I think it would be easy to add a function to write the buffer_manager list to a file. However, is this all you need? Once you save it, how do you read it to restore the session?
Hey! Oh, I see your point, you're right. For the feature to be completely useful out-of-the-box, I think 2 functions are needed:
-
Save the current buffer list to file (e.g.
list.bm
) -
Load buffers from the file created on 1 (it would be great if it ignored a buffer if it is already opened) - You must prompt for the list file to load from (e.g.
list.bm
)
It would be great if we could map both functions to custom bindings.
I wouldn't try to integrate with nvim "sessions" feature - I think buffers makes things simpler and give the flexibility needed (I could save the buffers list to anywhere on the filesystem I wish, and even have different lists for a given directory).
What does that sound to you?
It sounds good to me, I just have to figure out how to do it.
Hi! Sorry for the delay. I had not had time this past month to implement this feature. I just added it now (see 20914f3).
What I did is the following. I added two functions, one for saving and the other for loading the buffer list. Both functions have an optional argument: the filename. If the argument is nil, then the program prompts you to enter the file name manually.
Here is an example in Lua:
-- Prompt to manually introduce the file name
require'buffer_manager.ui'.save_menu_to_file()
require'buffer_manager.ui'.load_menu_from_file()
-- File name directly as an argument
require'buffer_manager.ui'.save_menu_to_file('bm')
require'buffer_manager.ui'.load_menu_from_file('bm')
I agree with you that this functionality is useful. I hope it meets your needs.
Thanks again for the feedback. I will close the issue once it is confirmed that everything is working properly.
No need to be sorry @j-morano , I understand we all have lifes after all. =D
I've tested it already mapped on my dot files, and all is working!
Thanks a bunch for your time, this plugin is now vital to my setup. Great work and keep rocking!
PS: if you need someone to test any other feature, just mention me and I 'll be happy to help.
Glad to hear you find it useful. And thanks for volunteering to test new features, I'll keep that in mind. Regards!