Lua-in-Vim 9.0: backupcopy divergence for zero-downtime migration
0 reputation · 12 Jun 2022, 23:45 UTC
0 reputation · 12 Jun 2022, 23:45 UTC
This question examines the interaction between Vim 9.0 Lua integration and the backupcopy option when migrating a small application without service interruption. The objective is to achieve configuration changes while the application remains operational.
A key uncertainty is the presence of the +lua feature in the target Vim build, which is not guaranteed across all distributions, and the documented variance of set backupcopy=yes between Unix and Windows platforms, where file-copy semantics may differ and affect Lua state retention.
To what extent can backupcopy=yes preserve Lua-sourced edits during cross-platform migration, and does the undocumented migrate command present a viable path or a data-loss risk? How does view mode session persistence support continuous operation when Vim is restarted on a different system?
35275 reputation · 13 Jun 2022, 03:59 UTC
backupcopy=yes cannot preserve Lua-sourced edits or Lua state during a cross-platform migration, and there is no core Vim 9.0 :migrate command to use for zero-downtime hand-off. Lua state lives in memory and is lost on Vim restart. Continuous operation across a Vim restart on a different system is not supported by Vim itself; you must re-initialise Lua configuration and restore editor state from session/view files.
backupcopy=yes helps avoid a truncate-then-write race for tools watching the file. On Unix the copy-then-rename pattern preserves inode expectations for some watchers. On Windows the copy semantics differ and Vim may use different write paths, so the observable effect is not identical cross-platform. Neither behavior affects Lua state retention.
Zero-downtime migration of a Vim-driven application is a mis-match: Vim is an editor, not a daemon. Restarting Vim on another host necessarily drops Lua state. The only portable artifacts are files on disk, session/view files, and your init.lua/vim9 script.
vim --version | grep -E '\+lua|\-lua'If the target lacks +lua, any Lua-sourced configuration will fail on startup.
:set backupcopy?:mksession! /path/to/session.vim and :mkview for each buffer.:source /path/to/session.vim then manually re-source init.lua if session does not reload it.Missing diagnostic that changes recommendation: confirm the target Vim build is Vim 9.0+ with +lua and the same patchlevel as source. Without +lua you must fall back to Vim script, and without matching patchlevel Lua API differences can break plugins.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.