aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/lua.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/lua.txt')
-rw-r--r--runtime/doc/lua.txt60
1 files changed, 47 insertions, 13 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index a6ccf9f35c..ef2d87949d 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -393,6 +393,14 @@ where the args are converted to Lua values. The expression >
is equivalent to the Lua chunk >
return somemod.func(...)
+In addition, functions of packages can be accessed like >
+ v:lua.require'mypack'.func(arg1, arg2)
+ v:lua.require'mypack.submod'.func(arg1, arg2)
+Note: only single quote form without parens is allowed. Using
+`require"mypack"` or `require('mypack')` as prefixes do NOT work (the latter
+is still valid as a function call of itself, in case require returns a useful
+value).
+
The `v:lua` prefix may be used to call Lua functions as |method|s. For
example: >
arg1->v:lua.somemod.func(arg2)
@@ -409,7 +417,8 @@ For example consider the following Lua omnifunc handler: >
end
vim.api.nvim_buf_set_option(0, 'omnifunc', 'v:lua.mymod.omnifunc')
-Note: the module ("mymod" in the above example) must be a Lua global.
+Note: the module ("mymod" in the above example) must either be a Lua global,
+or use the require syntax as specified above to access it from a package.
Note: `v:lua` without a call is not allowed in a Vimscript expression:
|Funcref|s cannot represent Lua functions. The following are errors: >
@@ -689,15 +698,14 @@ vim.diff({a}, {b}, {opts}) *vim.diff()*
------------------------------------------------------------------------------
VIM.MPACK *lua-mpack*
-The *vim.mpack* module provides packing and unpacking of lua objects to
-msgpack encoded strings. |vim.NIL| and |vim.empty_dict()| are supported.
+The *vim.mpack* module provides encoding and decoding of Lua objects to and
+from msgpack-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|.
-vim.mpack.pack({obj}) *vim.mpack.pack*
- Packs a lua object {obj} and returns the msgpack representation as
- a string
+vim.mpack.encode({obj}) *vim.mpack.encode*
+ Encodes (or "packs") Lua object {obj} as msgpack in a Lua string.
-vim.mpack.unpack({str}) *vim.mpack.unpack*
- Unpacks the msgpack encoded {str} and returns a lua object
+vim.mpack.decode({str}) *vim.mpack.decode*
+ Decodes (or "unpacks") the msgpack-encoded {str} to a Lua object.
------------------------------------------------------------------------------
VIM *lua-builtin*
@@ -928,6 +936,7 @@ Example: >
vim.g.foo = 5 -- Set the g:foo Vimscript variable.
print(vim.g.foo) -- Get and print the g:foo Vimscript variable.
vim.g.foo = nil -- Delete (:unlet) the Vimscript variable.
+ vim.b[2].foo = 6 -- Set b:foo for buffer 2
vim.g *vim.g*
Global (|g:|) editor variables.
@@ -935,15 +944,18 @@ vim.g *vim.g*
vim.b *vim.b*
Buffer-scoped (|b:|) variables for the current buffer.
- Invalid or unset key returns `nil`.
+ Invalid or unset key returns `nil`. Can be indexed with
+ an integer to access variables for a specific buffer.
vim.w *vim.w*
Window-scoped (|w:|) variables for the current window.
- Invalid or unset key returns `nil`.
+ Invalid or unset key returns `nil`. Can be indexed with
+ an integer to access variables for a specific window.
vim.t *vim.t*
Tabpage-scoped (|t:|) variables for the current tabpage.
- Invalid or unset key returns `nil`.
+ Invalid or unset key returns `nil`. Can be indexed with
+ an integer to access variables for a specific tabpage.
vim.v *vim.v*
|v:| variables.
@@ -1518,7 +1530,7 @@ tbl_flatten({t}) *vim.tbl_flatten()*
Flattened copy of the given list-like table.
See also: ~
- Fromhttps://github.com/premake/premake-core/blob/master/src/base/table.lua
+ From https://github.com/premake/premake-core/blob/master/src/base/table.lua
tbl_isempty({t}) *vim.tbl_isempty()*
Checks if a table is empty.
@@ -1554,7 +1566,7 @@ tbl_keys({t}) *vim.tbl_keys()*
list of keys
See also: ~
- Fromhttps://github.com/premake/premake-core/blob/master/src/base/table.lua
+ From https://github.com/premake/premake-core/blob/master/src/base/table.lua
tbl_map({func}, {t}) *vim.tbl_map()*
Apply a function to all values of a table.
@@ -1685,6 +1697,28 @@ uri_to_fname({uri}) *vim.uri_to_fname()*
==============================================================================
Lua module: ui *lua-ui*
+input({opts}, {on_confirm}) *vim.ui.input()*
+ Prompts the user for input
+
+ Parameters: ~
+ {opts} table Additional options. See |input()|
+ • prompt (string|nil) Text of the prompt.
+ Defaults to `Input:` .
+ • default (string|nil) Default reply to the
+ input
+ • completion (string|nil) Specifies type of
+ completion supported for input. Supported
+ types are the same that can be supplied to
+ a user-defined command using the
+ "-complete=" argument. See
+ |:command-completion|
+ • highlight (function) Function that will be
+ used for highlighting user inputs.
+ {on_confirm} function ((input|nil) -> ()) Called once the
+ user confirms or abort the input. `input` is
+ what the user typed. `nil` if the user
+ aborted the dialog.
+
select({items}, {opts}, {on_choice}) *vim.ui.select()*
Prompts the user to pick a single item from a collection of
entries