aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2026-09-10 03:42:20 +0800
committerGitHub <noreply@github.com>2026-09-09 15:42:20 -0400
commit08dd3adffb60ae6c031f9b8310febd65bb14604e (patch)
tree4c692cc37fa752ec0c6c4735865286f43cf756d6 /runtime/lua/vim
parentac167f943a905669b29f337f18d22a1efefeca92 (diff)
downloadrneovim-08dd3adffb60ae6c031f9b8310febd65bb14604e.tar.gz
rneovim-08dd3adffb60ae6c031f9b8310febd65bb14604e.tar.bz2
rneovim-08dd3adffb60ae6c031f9b8310febd65bb14604e.zip
feat(api): add ev.win to autocmd callback args #39826
Problem: Autocmd callbacks currently have to rely on curwin, which may already have changed by the time they run. This is especially noticeable for WinNew, WinClosed, WinResized and WinScrolled. Solution: Track the window in the autocmd context and expose it as ev.win. Pass it explicitly for the window events that need it.
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/_meta/api.gen.lua7
-rw-r--r--runtime/lua/vim/_meta/api_keysets_extra.lua1
2 files changed, 5 insertions, 3 deletions
diff --git a/runtime/lua/vim/_meta/api.gen.lua b/runtime/lua/vim/_meta/api.gen.lua
index 1b1311c498..ed323861b1 100644
--- a/runtime/lua/vim/_meta/api.gen.lua
+++ b/runtime/lua/vim/_meta/api.gen.lua
@@ -969,13 +969,14 @@ function vim.api.nvim_create_augroup(name, opts) end
--- - callback (`function|string?`) Lua function (or Vimscript function name, if string)
--- called when the event(s) is triggered. Lua callback can return `lua-truthy` to delete
--- the autocommand. Callback receives one argument, a table with keys: [event-args]()
---- - buf: (`number`) [<abuf>]
+--- - buf: (`integer`) [<abuf>]
--- - data: (`any`) Arbitrary data passed from [nvim_exec_autocmds()] [event-data]()
--- - event: (`vim.api.keyset.events`) Name of the triggered event `autocmd-events`
--- - file: (`string`) [<afile>] (not expanded to a full path)
---- - group: (`number?`) Group id, if any
---- - id: (`number`) Autocommand id
+--- - group: (`integer?`) Group id, if any
+--- - id: (`integer`) Autocommand id
--- - match: (`string`) [<amatch>] (expanded to a full path)
+--- - win: (`integer`) id of the window for the event, see `window-ID`
--- - command (string?) Vim command executed on event. Not allowed with {callback}.
--- - desc (`string?`) Description (for documentation and troubleshooting).
--- - group (`string|integer?`) Group name or id to match against.
diff --git a/runtime/lua/vim/_meta/api_keysets_extra.lua b/runtime/lua/vim/_meta/api_keysets_extra.lua
index acc23be54e..c1d574707d 100644
--- a/runtime/lua/vim/_meta/api_keysets_extra.lua
+++ b/runtime/lua/vim/_meta/api_keysets_extra.lua
@@ -76,6 +76,7 @@ error('Cannot require a meta file')
--- @field match string expanded value of <amatch>
--- @field buf integer expanded value of <abuf>
--- @field file string expanded value of <afile>
+--- @field win integer id of the window for the event, see |window-ID|
--- @field data? any arbitrary data passed from |nvim_exec_autocmds()|
--- @class vim.api.keyset.create_user_command.command_args