diff options
Diffstat (limited to 'runtime/doc/lua.txt')
-rw-r--r-- | runtime/doc/lua.txt | 63 |
1 files changed, 23 insertions, 40 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 0472c11a15..32e89bd237 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -2029,7 +2029,8 @@ 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 + Prompts the user for input, allowing arbitrary (potentially asynchronous) + work until `on_confirm`. Example: >lua @@ -2054,7 +2055,8 @@ input({opts}, {on_confirm}) *vim.ui.input()* entered), or `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 + Prompts the user to pick from a list of items, allowing arbitrary + (potentially asynchronous) work until `on_choice`. Example: >lua @@ -2253,57 +2255,38 @@ del({modes}, {lhs}, {opts}) *vim.keymap.del()* |vim.keymap.set()| set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()* - Add a new |mapping|. Examples: >lua + Adds a new |mapping|. Examples: >lua - -- Can add mapping to Lua functions + -- Map to a Lua function: vim.keymap.set('n', 'lhs', function() print("real lua function") end) - - -- Can use it to map multiple modes + -- Map to multiple modes: vim.keymap.set({'n', 'v'}, '<leader>lr', vim.lsp.buf.references, { buffer=true }) - - -- Can add mapping for specific buffer + -- Buffer-local mapping: vim.keymap.set('n', '<leader>w', "<cmd>w<cr>", { silent = true, buffer = 5 }) - - -- Expr mappings + -- Expr mapping: vim.keymap.set('i', '<Tab>', function() return vim.fn.pumvisible() == 1 and "<C-n>" or "<Tab>" end, { expr = true }) - -- <Plug> mappings + -- <Plug> mapping: vim.keymap.set('n', '[%', '<Plug>(MatchitNormalMultiBackward)') < - Note that in a mapping like: >lua - - vim.keymap.set('n', 'asdf', require('jkl').my_fun) -< - - the `require('jkl')` gets evaluated during this call in order to access the function. If you - want to avoid this cost at startup you can wrap it in a function, for - example: >lua - - vim.keymap.set('n', 'asdf', function() return require('jkl').my_fun() end) -< - Parameters: ~ - • {mode} string|table Same mode short names as |nvim_set_keymap()|. Can + • {mode} string|table Mode short-name, see |nvim_set_keymap()|. Can also be list of modes to create mapping on multiple modes. • {lhs} (string) Left-hand side |{lhs}| of the mapping. - • {rhs} string|function Right-hand side |{rhs}| of the mapping. Can - also be a Lua function. - • {opts} (table|nil) A table of |:map-arguments|. - • Accepts options accepted by the {opts} parameter in - |nvim_set_keymap()|, with the following notable differences: - • replace_keycodes: Defaults to `true` if "expr" is `true`. - • noremap: Always overridden with the inverse of "remap" - (see below). - - • In addition to those options, the table accepts the - following keys: - • buffer: (number or boolean) Add a mapping to the given - buffer. When `0` or `true`, use the current buffer. - • remap: (boolean) Make the mapping recursive. This is the - inverse of the "noremap" option from |nvim_set_keymap()|. - Defaults to `false`. + • {rhs} string|function Right-hand side |{rhs}| of the mapping, can be + a Lua function. + • {opts} (table|nil) Table of |:map-arguments|. + • Same as |nvim_set_keymap()| {opts}, except: + • "replace_keycodes" defaults to `true` if "expr" is `true`. + • "noremap": inverse of "remap" (see below). + + • Also accepts: + • "buffer" number|boolean Creates buffer-local mapping, `0` + or `true` for current buffer. + • remap: (boolean) Make the mapping recursive. Inverses + "noremap". Defaults to `false`. See also: ~ |nvim_set_keymap()| |