Skip to content

Removed 'let' from session file content#87

Open
JetSetIlly wants to merge 2 commits into
tpope:masterfrom
JetSetIlly:vim9script_compatibility
Open

Removed 'let' from session file content#87
JetSetIlly wants to merge 2 commits into
tpope:masterfrom
JetSetIlly:vim9script_compatibility

Conversation

@JetSetIlly

Copy link
Copy Markdown

Reecent releases of vim specify Session files to be vim9script. 'let' is no longer allowed as the assignment operator in vim9script

This change is all that's needed for Obsession to function without warning messages in recent builds or vim. It would be further improved if the plugin could somehow discern that the session file is using vim9script. That way, people who are still using older versions of vim can still use the most recent version of the plugin.

However, I'm not sure how to do that best so I've not attempted it.

I raised the issue in the main vim repository vim/vim#20588

recent releases of vim specify Session files to be vim9script. 'let' is
no longer allowed as the assignment operator in vim9script
@tpope

tpope commented Jun 20, 2026

Copy link
Copy Markdown
Owner

It would be further improved if the plugin could somehow discern that the session file is using vim9script. That way, people who are still using older versions of vim can still use the most recent version of the plugin.

"Older" as in a month or two. I don't even have any machines running the new version yet. Plus there's Neovim compatibility. This needs to be backwards compatible.

There's also a hard-coded check for the old-style file that needs to be addressed:

\ && readfile(file, '', 1)[0] !=# 'let SessionLoad = 1'

That check in and of itself may offer a clue how to distinguish between the old format and new.

if the first line of the session file is vim9script then use
the appropriate assignment syntax. if vim9script is not
present then use the original vimscript syntax
@JetSetIlly

Copy link
Copy Markdown
Author

"Older" as in a month or two. I don't even have any machines running the new version yet. Plus there's Neovim compatibility. This needs to be backwards compatible.

I've added a check for the vim9script directive in the persist() function.

I've tested with an older version (from a couple of months ago)

  1. A vimscript session file is produced. The let keyword is used
  2. Running the current github version of vim successfully loads the vimscript session file
  3. Quitting vim updates the session file. The vim9script directive is added. The let keyword is not used
  4. Loading the new session file works as expected

Of course, loading a new session file with an older version of vim does not work. But that's expected and not something we can account for.

I don't have access to neovim so that remains untested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants