aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_meta/vimfn.lua
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/_meta/vimfn.lua')
-rw-r--r--runtime/lua/vim/_meta/vimfn.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua
index 300210b296..4665f71052 100644
--- a/runtime/lua/vim/_meta/vimfn.lua
+++ b/runtime/lua/vim/_meta/vimfn.lua
@@ -5713,6 +5713,7 @@ function vim.fn.mkdir(name, flags, prot) end
--- If [expr] is supplied and it evaluates to a non-zero Number or
--- a non-empty String (|non-zero-arg|), then the full mode is
--- returned, otherwise only the first letter is returned.
+--- Also see |state()|.
---
--- n Normal
--- no Operator-pending
@@ -8744,6 +8745,34 @@ function vim.fn.sqrt(expr) end
--- @return any
function vim.fn.srand(expr) end
+--- Return a string which contains characters indicating the
+--- current state. Mostly useful in callbacks that want to do
+--- work that may not always be safe. Roughly this works like:
+--- - callback uses state() to check if work is safe to do.
+--- If yes, then do it right away.
+--- Otherwise add to work queue and add SafeState autocommand.
+--- - When SafeState is triggered, check with state() if the work
+--- can be done now, and if yes remove it from the queue and
+--- execute.
+--- Also see |mode()|.
+---
+--- When {what} is given only characters in this string will be
+--- added. E.g, this checks if the screen has scrolled: >vim
+--- if state('s') != ''
+---
+--- These characters indicate the state:
+--- m halfway a mapping, :normal command, feedkeys() or
+--- stuffed command
+--- o operator pending or waiting for a command argument
+--- a Insert mode autocomplete active
+--- x executing an autocommand
+--- c callback invoked (repeats for recursiveness up to "ccc")
+--- s screen has scrolled for messages
+---
+--- @param what? string
+--- @return any
+function vim.fn.state(what) end
+
--- With |--headless| this opens stdin and stdout as a |channel|.
--- May be called only once. See |channel-stdio|. stderr is not
--- handled by this function, see |v:stderr|.