btv.keymap
btv.keymap.set(mode, lhs, rhs, opts)
btv.keymap.set(mode, lhs, rhs, opts): map lhs to rhs in mode.
rhs is a function (stored in btv._keymap_fns) or a string (fed as keys).
Maps are non-recursive by default (the btv.keymap.set convention); pass
opts.remap = true for a recursive map whose RHS keys are re-fed through the
mapping layer (or, equivalently, opts.noremap = false). opts.desc is stored
but unused; opts.buffer ties the map to one buffer (0 = current), opts.default
marks an overridable built-in — both feed the precedence ladder the server applies.
opts.buffer may also be a btv.view handle: the map binds to the view’s buffer,
and when that buffer doesn’t exist yet (it is created after the chunk that creates
the view) it binds as soon as it does. A view’s :bufnr() reads false until then,
and buffer = false is refused, so a map meant for one buffer never lands globally.
A view that is already closed is refused; one closed while the bind waits drops it.
There is no <Cmd> key: a string rhs spelling one raises E5806 (it would type
<, C, m, d, >). To run a command, map to a function, or to :Command<CR>:
btv.keymap.set("n", "<leader>w", function() btv.cmd("write") end)
btv.keymap.set("n", "<leader>q", ":quit<CR>")
Defined in keymap.lua.
btv.keymap.expand_leader(lhs)
btv.keymap.expand_leader(lhs): the lhs with <leader> / <localleader> replaced
by the CURRENT vim.g.mapleader / vim.g.maplocalleader (each "\" when unset),
matching the set-time expansion btv.keymap.set performs on every LHS it registers.
Call this when you need the concrete key sequence a map is registered under — most
often to feed it back through btv._feedkeys, which parses raw vim key-notation and
does NOT know <leader>. Expand once, at the moment you set the map, and reuse that
string: the leader in force then is the one baked into the registration.
Defined in keymap.lua.
btv.keymap.del(mode, lhs, opts)
btv.keymap.del(mode, lhs, opts): remove the mapping(s) for lhs in mode.
opts.buffer (0 = current) targets a buffer-local map; absent targets globals.
Defined in keymap.lua.
btv.keymap.raw_buf_set(buffer, mode, lhs, rhs, opts)
btv.keymap.raw_buf_set(buffer, mode, lhs, rhs, opts) [alias nvim_buf_set_keymap].
Defined in keymap.lua.
btv.keymap.raw_set(mode, lhs, rhs, opts)
btv.keymap.raw_set(mode, lhs, rhs, opts) [alias nvim_set_keymap]: the global form
of the raw setter (a buffer-less raw_buf_set).
Defined in keymap.lua.
btv.keymap.buf_del(buffer, mode, lhs)
btv.keymap.buf_del(buffer, mode, lhs) [alias nvim_buf_del_keymap]: remove a
buffer-local mapping. The global form, nvim_del_keymap, aliases btv.keymap.del
directly — its (mode, lhs) call already matches btv.keymap.del’s signature.
Defined in keymap.lua.
btv.keymap.get(mode)
btv.keymap.get(mode) [alias nvim_get_keymap]: every GLOBAL mapping that applies
in mode, as maparg dicts. Buffer-local maps are excluded (btv.keymap.buf_get
returns those).
Defined in keymap.lua.
btv.keymap.buf_get(buffer, mode)
btv.keymap.buf_get(buffer, mode) [alias nvim_buf_get_keymap]: the BUFFER-LOCAL
mappings of buffer (0 = current) that apply in mode, as maparg dicts.
Defined in keymap.lua.
btv.keymap.arg(name, mode, _abbr, dict)
btv.keymap.arg(name, mode, abbr, dict) [alias vim.fn.maparg]: the mapping bound to
name in mode. With dict truthy returns the full maparg dict (or {} when
unmapped); else the rhs string (“” when unmapped, or for a function RHS). abbr
(abbreviation lookup) is accepted and ignored — bemtvi has no abbreviations. A
buffer-local map for the current buffer shadows a global one at the same lhs.
Defined in keymap.lua.