neovim-session-manager
neovim-session-manager copied to clipboard
Research: Avoid closing buffers before saving session
This is a thread to discuss possible ways to avoid doing this.
Failed approaches
Approach 1: Using vim.o.sessionoptions to exclude certain filetypes
As experiment, we have tried to remove help from
vim.o.sessionoptions="blank,buffers,curdir,folds,help,tabpages,winsize,terminal,localoptions,winpos"
and then setting the fitetype and buftype of a file to help, and save session.
RESULT: Doesn't work, it still save the buffer. It seems mksession has a way to recognize help files other than its type.
FUTURE ROADMAP
Once this neovim bug is fixed, we can temporaly set the buffers we don't want to save as nofile to exclude them from mksession without having to close them.
Yes, this is why I had to add conditions.
I'm gonna be experimenting changes, feel free to unsubscribe if get sick of getting many notifications 🫂
Said that: I'm reading buffers with buftype nofile are excluded from mksession. Assuming this is true, it might be possible to
- Store the original buftype of every buffer.
- Set any buffer that is not restorable to buftype nofile, so it's not stored by
mksession. - Restore the original buftype of every buffer.
I'm gonna try.
My assumption was incorrect: This is a open bug in neovim from 2020. You were right, it doesn't seem neovim currently provide a way to do this. But I'll keep researching.