feat: restore buffers after loading a session#3335
Conversation
| end, | ||
| }) | ||
|
|
||
| vim.api.nvim_create_autocmd("SessionLoadPost", { |
There was a problem hiding this comment.
I went with this location since it was the standard, but it might a good idea have this as an eager autocmd. Otherwise, any means of "lazy loading" may end up calling setup too late (sessions could be loaded relatively early, as in, part of the initilization with nvim -S Session.vim).
| if vim.api.nvim_win_is_valid(win) then | ||
| vim.api.nvim_win_call(win, function() | ||
| api.open() | ||
| end) |
There was a problem hiding this comment.
There's an edge case with this approach: if nvim-tree was the only buf from a tabpage, it will not be restored. I think that's fine, as it's sort of unlikely. Could add a comment as a reference, or otherwise look into it. The vim api is not very tab friendly, but I guess it should be possible to hook an unholy :[N]tabnew...
|
Am I missing something or is the CI failure unrelated? |
|
We've had a lot of problems with session integration in the past e.g. #1992, with nodeterministic issues surrounding plogin load and event order etc. The outcome was that we elected not to support sessions, using a recipe instead. First question: is an error thrown on startup, or does the session simply fail to correctly load? Options:
Are the above possible using API? |
Apologies, an upstream Nvim change broke the build, fixed on master #3337 |
Hello,
I'm on a quest to make all of my plugins (vim) "session friendly". For nvim-tree this sounds pretty straightforward, so I went ahead and implemented it myself.
Problem: nvim-tree leaves stale empty buffers after restoring a session
Solution: detect these buffers on
SessionLoadPostand reopen them.