From 08dd3adffb60ae6c031f9b8310febd65bb14604e Mon Sep 17 00:00:00 2001 From: glepnir Date: Thu, 10 Sep 2026 03:42:20 +0800 Subject: 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. --- runtime/lua/vim/_meta/api.gen.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'runtime/lua/vim/_meta/api.gen.lua') 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`) [] +--- - buf: (`integer`) [] --- - 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`) [] (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`) [] (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. -- cgit