From f413597f44f62a62675a3a7149e34a63f16e4821 Mon Sep 17 00:00:00 2001 From: Oliver Marriott Date: Thu, 21 Sep 2023 15:53:05 +1000 Subject: docs: clarify vim.schedule_wrap behaviour - Remove the usage of the term "defer" to avoid confusion with `vim.defer_fn`, which also calls `vim.schedule_wrap` internally. - Explicitly state that `vim.schedule_wrap` returns a function in the text. - Mention that arguments are passed along. - Include a usage example. - Rename param to `fn`. --- runtime/doc/lua.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index efba10b86f..14df45cc8c 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1714,11 +1714,20 @@ vim.region({bufnr}, {pos1}, {pos2}, {regtype}, {inclusive}) `endcol` is exclusive, and whole lines are returned as `{startcol,endcol} = {0,-1}`. -vim.schedule_wrap({cb}) *vim.schedule_wrap()* - Defers callback `cb` until the Nvim API is safe to call. +vim.schedule_wrap({fn}) *vim.schedule_wrap()* + Returns a function which calls {fn} via |vim.schedule()|. + + The returned function passes all arguments to {fn}. + + Example: >lua + function notify_readable(_err, readable) + vim.notify("readable? " .. tostring(readable)) + end + vim.uv.fs_access(vim.fn.stdpath("config"), "R", vim.schedule_wrap(notify_readable)) +< Parameters: ~ - • {cb} (function) + • {fn} (function) Return: ~ (function) -- cgit From 44f698bb1afccb90fd8835fa7e35bfcebbd6d828 Mon Sep 17 00:00:00 2001 From: Oliver Marriott Date: Thu, 21 Sep 2023 22:34:56 +1000 Subject: docs: update vim.schedule param name and type Per https://github.com/neovim/neovim/pull/25286#discussion_r1332861721 and https://github.com/neovim/neovim/pull/25286#discussion_r1334318352 --- runtime/doc/lua.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 14df45cc8c..ddf11fd966 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -956,12 +956,12 @@ vim.rpcrequest({channel}, {method}, {args}, {...}) *vim.rpcrequest()* • {args} any[]|nil • {...} any|nil -vim.schedule({callback}) *vim.schedule()* - Schedules {callback} to be invoked soon by the main event-loop. Useful to - avoid |textlock| or other temporary restrictions. +vim.schedule({fn}) *vim.schedule()* + Schedules {fn} to be invoked soon by the main event-loop. Useful to avoid + |textlock| or other temporary restrictions. Parameters: ~ - • {callback} fun() + • {fn} (function) vim.str_byteindex({str}, {index}, {use_utf16}) *vim.str_byteindex()* Convert UTF-32 or UTF-16 {index} to byte index. If {use_utf16} is not -- cgit