feat(:restart): v:starttime, v:exitreason #39319

This commit is contained in:
Justin M. Keyes
2026-04-22 14:58:47 -04:00
committed by GitHub
parent c407e3e67b
commit fd1b193d51
16 changed files with 265 additions and 117 deletions

View File

@@ -42,10 +42,10 @@ M.restart_canonical_addr = nil ---@type string?
--- Windows named pipes can't be rebound immediately, so the new server starts on a
--- temporary bootstrap address and polls until the canonical address is reclaimable.
--- @param canonical_addr string The original --listen address to reclaim.
--- @param bootstrap_addr string Temporary address the new server started on.
--- @param expected_uis integer Number of UIs expected to reattach (0 = don't wait).
function M.rebind_old_addr_after_restart(canonical_addr, bootstrap_addr, expected_uis)
function M.rebind_after_restart(canonical_addr, expected_uis)
M.restart_canonical_addr = canonical_addr
local bootstrap_addr = vim.v.servername -- Temporary autogenerated address.
local poll_ms = 50
local max_wait_ms = 30000
local timer = assert(vim.uv.new_timer())

View File

@@ -244,11 +244,29 @@ vim.v.exception = ...
--- Example:
---
--- ```vim
--- :au VimLeave * echo "Exit value is " .. v:exiting
--- :au VimLeave * echo "Exit code is " .. v:exiting
--- ```
--- @type integer?
vim.v.exiting = ...
--- Reason for the current exit. Set before `QuitPre`. Reset if
--- exit was canceled.
---
--- Possible values:
--- - "" Not exiting, or exit was canceled.
--- - "quit" `:quit`, `:qall`, `:wq`, `ZZ`, `ZQ`, etc.
--- - "restart" `:restart`, `ZR`.
---
--- Example:
---
--- ```vim
--- autocmd ExitPre * if v:exitreason ==# 'restart' | echomsg 'restarting' | endif
--- ```
---
--- Read-only.
--- @type string
vim.v.exitreason = ...
--- Special value used to put "false" in JSON and msgpack. See
--- `json_encode()`. This value is converted to "v:false" when used
--- as a String (e.g. in `expr5` with string concatenation
@@ -281,12 +299,12 @@ vim.v.fcs_choice = ...
--- The reason why the `FileChangedShell` event was triggered.
--- Can be used in an autocommand to decide what to do and/or what
--- to set v:fcs_choice to. Possible values:
--- deleted file no longer exists
--- conflict file contents, mode or timestamp was
--- - deleted file no longer exists
--- - conflict file contents, mode or timestamp was
--- changed and buffer is modified
--- changed file contents has changed
--- mode mode of file changed
--- time only file timestamp changed
--- - changed file contents has changed
--- - mode mode of file changed
--- - time only file timestamp changed
--- @type string
vim.v.fcs_reason = ...
@@ -649,6 +667,19 @@ vim.v.shell_error = ...
--- @type table[]
vim.v.stacktrace = ...
--- Timestamp (monotonic nanoseconds) when the Nvim process
--- started.
---
--- To see the current "uptime":
---
--- ```lua
--- vim.print(('uptime: %d seconds'):format((vim.uv.hrtime() - vim.v.starttime) / 1e9))
--- ```
---
--- Read-only.
--- @type integer
vim.v.starttime = ...
--- Last given status message.
--- Modifiable (can be set).
--- @type string