aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/eval.txt4
-rw-r--r--runtime/doc/if_lua.txt32
2 files changed, 36 insertions, 0 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 1eb873a5b4..79bf81dc0e 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1737,6 +1737,10 @@ v:lnum Line number for the 'foldexpr' |fold-expr|, 'formatexpr' and
expressions is being evaluated. Read-only when in the
|sandbox|.
+ *v:lua* *lua-variable*
+v:lua Prefix for calling lua functions from expressions.
+ See |v:lua-call| for more information.
+
*v:mouse_win* *mouse_win-variable*
v:mouse_win Window number for a mouse click obtained with |getchar()|.
First window has number 1, like with |winnr()|. The value is
diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt
index 7eef5d3903..911197acd4 100644
--- a/runtime/doc/if_lua.txt
+++ b/runtime/doc/if_lua.txt
@@ -327,6 +327,38 @@ Return value is also always converted. When converting,
|msgpack-special-dict|s are treated specially.
==============================================================================
+v:lua function calls *v:lua-call*
+
+The special prefix `v:lua` can be used in vimL expressions to call lua
+functions which are global or nested inside global tables. The expression
+`v:lua.func(arg1, arg2)` is equivalent to executing the lua code
+`return func(...)` where the args have been converted to lua values. In addition
+`v:lua.somemod.func(args)` will work like `return somemod.func(...)` .
+
+`v:lua` can also be used in function options like 'omnifunc'. As an
+example, consider the following lua implementation of an omnifunc: >
+
+ function mymod.omnifunc(findstart, base)
+ if findstart == 1 then
+ return 0
+ else
+ return {'stuff', 'steam', 'strange things'}
+ end
+ end
+ vim.api.nvim_buf_set_option(0, 'omnifunc', 'v:lua.mymod.omnifunc')
+
+A limitation is that the plugin module ("mymod" in this case) must
+be made available as a global.
+
+Note: `v:lua` without a call is not allowed in a vimL expression. Funcrefs
+to lua functions cannot be created. The following are errors: >
+
+ let g:Myvar = v:lua.myfunc
+ call SomeFunc(v:lua.mycallback)
+ let g:foo = v:lua
+ let g:foo = v:['lua']
+
+==============================================================================
Lua standard modules *lua-stdlib*
The Nvim Lua "standard library" (stdlib) is the `vim` module, which exposes