Module bex.keymap

Lua keymap API.

This module provides a more convenient API for manipulating keymaps than using Ex commands (which is also supported) or raw NVIM API calls.

Use bex.keymap.set to set keymap entries, and bex.keymap.delete to remove them.

Functions

set (tbl, bufnr) Set keymap entries.
delete (entry, bufnr) Delete keymap entry.


Functions

set (tbl, bufnr)
Set keymap entries.

Sets all entries in tbl, which should conform to the following format:

 {
     <option>: <value>,
     ...,
     ["<modes> <lhs>"] = <rhs>,
     ...
 }

Each option may be a valid keymap option, all of which take boolean values:

  • buffer
  • expr
  • noremap
  • nowait
  • script
  • silent
  • unique

In each map entry, <modes> should be one or more of the usual map modes, e.g. xo for both x and o mappings.

<lhs> should be the usual sequence of key presses as you would use with the standard Ex commands.

<rhs> may be a string, in which case it behaves as the <rhs> in the standard Ex commands. It may instead be a callable object, in which case the mapping will call it with no parameters.

If <rhs> is a table, its first entry (index 1) is treated as above, with additional option keys in the table overriding those from the outer table.

Parameters:

  • tbl The binding table as described above.
  • bufnr If the buffer option is specified, which buffer to apply mappings to. Defaults to 0, the current buffer.

Usage:

    -- Print "Hello, world!" when pressing key sequence in
    -- normal or visual mode in the current buffer
    keymap = require('bex.keymap')
    keymap.set {
        buffer = true,
        ["nx <Leader>zzz"] = function() print("Hello, world!") end
    }
delete (entry, bufnr)
Delete keymap entry.

Deletes the given keymap entry.

Parameters:

  • entry The entry to unmap, which is the same format used in bex.keymap.set: "<modes> <lhs>"
  • bufnr If nil, delete from the global keymap. Otherwise, delete from the keymap for that buffer. 0 specifies the current buffer.
generated by LDoc 1.4.6 Last updated 2021-06-29 21:08:43