Skip to content

Add SessionLoadPre autocmd #19084

@ColinKennedy

Description

@ColinKennedy

Is your feature request about something that is currently impossible or hard to do? Please describe the problem.
When loading Vim using -S, a Session.vim (+ Sessionx.vim) is loaded from-disk. Sometimes, these files are invalid or out of date and need to be updated / recovered before the session can load safely.

If we had an autocmd that runs just before the session is sourced, we could run some callback to intervene and do something to fix those files are read. But currently the required SessionLoadPre autocmd doesn't exist.

Describe the solution you'd like
A new SessionLoadPre autocmd. SessionLoadPre could come with no information and still be useful. But I think it'd be nice to expose the session that's about to be loaded. We already do expose the session during SessionLoadPost, called v:this_session, but it's a bit weird to reuse that variable name because "this" session hasn't actually been applied yet.

We could just use v:this_session anyway even though the name isn't ideal or we could use a new variable name that's more clear.

Describe alternatives you've considered
If we only needed this command on-start-up then we could do some kind of query on-start-up but that still wouldn't help us in the situation where we want to run something before-each-session-load. I think a SessionLoadPre is the only way.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions