From 91572ddad185c2c4f6d266543d66919543c5bb2a Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 7 Jul 2020 10:55:40 +0200 Subject: doc: mention that defer_fn applies schedule_wrap (#12601) --- runtime/doc/lua.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'runtime/doc/lua.txt') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 0ee63eb523..af0ac6ca9f 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -415,6 +415,8 @@ To avoid the error use |vim.schedule_wrap()| to defer the callback: > vim.api.nvim_command('echomsg "test"') end)) +(For one-shot timers, see |vim.defer_fn()|, which automatically adds the wrapping.) + Example: repeating timer 1. Save this code to a file. 2. Execute it with ":luafile %". > @@ -859,6 +861,9 @@ vim.defer_fn({fn}, {timeout}) *vim.defer_fn* Defers calling {fn} until {timeout} ms passes. Use to do a one-shot timer that calls {fn}. + Note: The {fn} is |schedule_wrap|ped automatically, so API functions are + safe to call. + Parameters: ~ {fn} Callback to call once {timeout} expires {timeout} Time in ms to wait before calling {fn} -- cgit