Shatur / neovim-session-manager

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

Flickering and annoying experience during opening `nvim` #28

Closed MuhammadSawalhy closed 5 months ago

MuhammadSawalhy commented 2 years ago

Bug description

When I open a directory that has a stored session, this plugin loads the session but the start window opens first. I thought that this issue comes from startify plugin, but I disabled it and the issue is still happening with the default neovim start window. [[see videos below]]

Steps to reproduce

Just open a neovim in a directory with saved session

Expected behavior

To sync load the session

Screen recordings

simplescreenrecorder-2022-02-20_12 07 08

simplescreenrecorder-2022-02-20_12 07 52

Environment

Shatur commented 2 years ago

Not sure if it possible to fix since sessions are sourced after Neovim startup (VimEnter autocmd).

MuhammadSawalhy commented 2 years ago

I think you can block execution using so while (session not loaded) loop, and read the session loading status using some variables or read from a file such as /tmp/neovim-session-manager/(random-id), and the random-id will be generated before the while loop and session no loaded is read from this file with this random id. When the aysnc loading is done, some text will be written in that file. Finally, delete the file.

We as programmers can find some indirect workaround, I hope you will find one.

Shatur commented 2 years ago

No, this won't work, the problem is that Neovim is loaded first, and then the session. If you have any ideas, please send a PR.

k1rowashere commented 5 months ago

I have found the cause: By removing the vim.schedule from utils.load_session, it removes the slight flicker of the intro screen.

But this may causes a slowdown when starting vim (the entire ui waits for loading buffers and starting lazy-load plugins). It required some tweaking to get working fast. Maybe it should be an option where there is a load_startup_session with no vim.schedule and docs explaining how to make it faster.

(I've used some scheduling shenanigans to get it load this fast.) (you can take a look at my config, used a User aucmd to defer running the plugins)

Screencast from 2024-04-30 04-26-18.webm

Shatur commented 5 months ago

Feel free to open a PR to update the readme.