feat(vim._with): keepcwd

This commit is contained in:
Justin M. Keyes
2026-08-06 13:16:48 +02:00
parent 1c1dc0558f
commit eb19a52b7c
5 changed files with 92 additions and 40 deletions

View File

@@ -1480,6 +1480,7 @@ end
--- @field go? table<string, any>
--- @field hide? boolean
--- @field keepalt? boolean
--- @field keepcwd? boolean
--- @field keepjumps? boolean
--- @field keepmarks? boolean
--- @field keeppatterns? boolean
@@ -1537,9 +1538,6 @@ end
--- indicated by the spec is restored.
---
--- Notes:
--- - If `buf`/`win` is specified, CWD state (win/buf/tab-local dirs) is restored after execution.
--- Any :cd/:tcd/:lcd/:bcd during execution is undone.
--- - TODO: allow opt-out? Workaround: use nvim_buf_call()/nvim_win_call().
--- - Context `{ buf = buf }` has no guarantees about current window when
--- inside context.
--- - Context `{ buf = buf, win = win }` is yet not allowed, but this seems
@@ -1571,6 +1569,7 @@ function vim._with(context, f)
vim.validate('context.go', context.go, 'table', true)
vim.validate('context.hide', context.hide, 'boolean', true)
vim.validate('context.keepalt', context.keepalt, 'boolean', true)
vim.validate('context.keepcwd', context.keepcwd, 'boolean', true)
vim.validate('context.keepjumps', context.keepjumps, 'boolean', true)
vim.validate('context.keepmarks', context.keepmarks, 'boolean', true)
vim.validate('context.keeppatterns', context.keeppatterns, 'boolean', true)