From e9f4ceeb7467364554ecef770fd3380e89457abb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 6 Dec 2024 20:01:28 +0800 Subject: fix(events): don't expand `args.file` for Lua callback (#31473) Problem: In an autocommand Lua callback whether `args.file` is expanded depends on whether `expand('')` has been called. Solution: Always use the unexpanded file name for `args.file`. Related to #31306 and vim/vim#16106. This doesn't provide `sfname`, but at least makes `args.file` have a consistent value. --- runtime/doc/api.txt | 6 +++--- runtime/lua/vim/_meta/api.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 9cb8f72348..cb3b2a3f77 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -3494,9 +3494,9 @@ nvim_create_autocmd({event}, {opts}) *nvim_create_autocmd()* • event: (string) name of the triggered event |autocmd-events| • group: (number|nil) autocommand group id, if any - • match: (string) expanded value of - • buf: (number) expanded value of - • file: (string) expanded value of + • file: (string) (not expanded to a full path) + • match: (string) (expanded to a full path) + • buf: (number) • data: (any) arbitrary data passed from |nvim_exec_autocmds()| *event-data* • command (string) optional: Vim command to execute on event. diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua index d74ee11b46..b2385197bd 100644 --- a/runtime/lua/vim/_meta/api.lua +++ b/runtime/lua/vim/_meta/api.lua @@ -963,9 +963,9 @@ function vim.api.nvim_create_augroup(name, opts) end --- - id: (number) autocommand id --- - event: (string) name of the triggered event `autocmd-events` --- - group: (number|nil) autocommand group id, if any ---- - match: (string) expanded value of [] ---- - buf: (number) expanded value of [] ---- - file: (string) expanded value of [] +--- - file: (string) [] (not expanded to a full path) +--- - match: (string) [] (expanded to a full path) +--- - buf: (number) [] --- - data: (any) arbitrary data passed from [nvim_exec_autocmds()] [event-data]() --- - command (string) optional: Vim command to execute on event. Cannot be used with --- {callback} -- cgit