[BUG] `auto_restore_enabled = true` not working
Describe the bug
When I open nvim without any arguments, I expect auto-session to automatically restore the previous session for the directory that I'm in. Instead, neovim just starts with the standard intro screen.
To Reproduce
- Set auto-session config as (using kickstart.nvim project setup):
return {
'rmagatti/auto-session',
event = 'VeryLazy',
opts = {
auto_save_enabled = true,
auto_restore_enabled = true,
},
}
- Ensure that
sessionsdirectory is empty so there are no existing sessions. - Run
nvim - Open "a.txt"
- I can see session file being created for the directory I ran
nvimin - Run
:qain neovim - Run
nvimagain - Expect "a.txt" to be opened automatically. Instead I get the standard neovim welcome screen.
- If I manually run
:SessionRestore, then "a.txt" is opened as expected
Screenshots If applicable, add screenshots to help explain your problem.
Baseline (please complete the following information):
- Result of
set sessionoptions?:sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize,terminal - OS. e.g
uname -a: MacOS - Neovim version
nvim --version:v0.10.0 - URL to your current config (if public)
Additional context
Can you add log_level = 'debug' to your opts and paste what it shows?
I second what @cameronr said but also I wouldn't recommend using VeryLazy with auto-session necessarily. auto-session does some things that themselves depend on events that are fired after plugins are loaded but way before the VeryLazy event from lazy. This might even be the cause of your issues.
Just noticed that your config has event = 'VeryLazy'. That will break session auto-restore because the VeryLazy event happens after the VimEnter event we use to trigger session loading. It will work if you change the config to:
return {
'rmagatti/auto-session',
lazy = false,
opts = {
-- auto_restore and auto_save are true by default so don't have to set them here
},
}
I'm going to look into adding a checkhealth alert if event = VeryLazy and auto_restore = true