-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocmd errors when starting a session in a cwd #409
Comments
Thanks for the report. The session isn't getting corrupted but there is an error when nvim tries to load the session related to restoring a fold. I have also seen this on occasion but haven't been able to get it to happen consistently enough to track down (I also don't really use folds). Can you share any fold configuration (values of And the next time it happens, can you post the contents of the session file (e.g. `../Users/rbhanot/.local/share/nvim/sessions/%2FUsers%2Frbhanot%2Fdevelopment%2Fwork%2Fmultiproducts%2Fliscm-satellite-server%2Fliscm-satellite-server%7Cmaster.vim)? |
Here it is; it happened again today, but with a different session.
Here are the contents of the session file
|
That looks like a different error as it's saying |
Oh yeah, you are right. I will keep an eye on it and will update if I encounter the original error again. |
I'm encountering this issue as well. I think it is related at least in part to the speed of the service providing I use an LSP for languages like lua, and set I'm not familiar enough with the internals of this plugin or neovim to know what solutions to this conundrum might be viable. Is it possible to delay loading folds when restoring a session? That might not be a great user experience, but at least the folds would be preserved. Alternatively, since folds currently aren't restored in these cases anyway, I'd prefer that information simply be discarded from the session if foldexpr is provided by a slow service. That way, I'm not interrupted by the error when restoring the session. Thanks very much for this great plugin! |
Ahh, very interesting. I can reproduce this by setting It looks like this is likely a core neovim bug because loading the session via ![]() Possibly related bugs: vim/vim#15813, neovim/neovim#2018, neovim/neovim#28692, with a suggestion to ignore fold "errors" on session restore. That said, we could possibly work around it. Here are the possible options in my mind:
@rmagatti any thoughts? fwiw, as much as I don't like special handling, I lean towards option 2. It would look something like: if not success then
if result and string.find(result, "E490: No fold found") then
Lib.logger.debug "Ignoring fold error"
else
Lib.logger.error([[
Error restoring session, disabling auto save.
Error: ]] .. result)
Config.auto_save = false
return false
end
end |
I don't love the special handling proposed either; what makes an error in restoring folds different than say an error using a nil variable somewhere? I think there are a couple of potentially better options If I understand the issue card correctly:
|
I think the fold errors are "special" in the sense that there's known issue with the underlying session code so "false" errors are likely / expected to be generated. As I think about it a bit more, I think the components are:
At least for me, I always want to restore as much of the session as possible (i.e. never stop on first error). I don't want to see any fold errors (no message, no disabling auto-save) but I do want to see other errors and disable auto-save in that case. But I also understand others might want it to work differently. My proposal is to add config option, edit: coded up my proposal, linked below |
I noticed consistently encountering this issue when I changed from This error could probably be ignored or logged as warn (or at least what error message should be ignored) via option since I prefer the session restored regardless of the fold error. |
@kcayme Same, If you want, you can try my branch by updating your auto-session config (assuming you use lazy.nvim): -- 'rmagatti/auto-session',
'cameronr/auto-session',
branch = 'restore-error-handler', Then you just need to update the plugin and restart nvim. Let me know if it works for you. |
thanks @cameronr ! was able to clone it with |
Whoops, sorry about the paste error (fixed above). Glad to hear it's working! |
Can confirm that @cameronr's fork fixes the issue for me. Root cause was the same i.e. using |
Thanks to a recent post on r/neovim[^1], it seems like nvim-ufo is not really needed anymore. Now the config is set as follows, 1. set `foldexpr` to treesitter in opts.lua 2. use `vim.lsp.foldexpr` when an LSP server is attached and the client supports folding. This commit also removes statuscol.nvim which is replaced by the statuscolumn module in snacks.nvim. Post this change and given neovim v0.11, restoring sessions is broken due to a race condition between restoring and the LSP server being ready[^2]. As a workaround, the version of auto-session is replaced with a fork that has the required fix[^3]. [^1]: https://www.reddit.com/r/neovim/comments/1jmqd7t/sorry_ufo_these_7_lines_replaced_you [^2]: rmagatti/auto-session#409 [^3]: rmagatti/auto-session#409 (comment) Signed-off-by: PrayagS <[email protected]>
Hello, Sometimes I see the following error message when I start neovim in a particular directory, and further session saving does not work. Its only after I delete the session files and start fresh a nbew session is created and things get normal. It looks like session is getting corrupted somehow.
I have not seen a pattern to this but this happens once in a while with me.
The text was updated successfully, but these errors were encountered: