Shatur / neovim-session-manager

A simple wrapper around :mksession.
GNU General Public License v3.0
530 stars 52 forks source link

Research: Avoid closing buffers before saving session #98

Open Zeioth opened 1 year ago

Zeioth commented 1 year ago

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.

Shatur commented 1 year ago

Yes, this is why I had to add conditions.

Zeioth commented 1 year ago

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

I'm gonna try.

Zeioth commented 1 year ago

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.