mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
fix(keymap): don't coerce false to ''
This commit is contained in:
@@ -2025,7 +2025,7 @@ set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()*
|
|||||||
{rhs} string|function Right-hand side |{rhs}| of the
|
{rhs} string|function Right-hand side |{rhs}| of the
|
||||||
mapping. Can also be a Lua function. If a Lua
|
mapping. Can also be a Lua function. If a Lua
|
||||||
function and `opts.expr == true`, returning `nil`
|
function and `opts.expr == true`, returning `nil`
|
||||||
or `false` is equivalent to an empty string.
|
is equivalent to an empty string.
|
||||||
{opts} table A table of |:map-arguments| such as
|
{opts} table A table of |:map-arguments| such as
|
||||||
"silent". In addition to the options listed in
|
"silent". In addition to the options listed in
|
||||||
|nvim_set_keymap()|, this table also accepts the
|
|nvim_set_keymap()|, this table also accepts the
|
||||||
|
@@ -35,8 +35,8 @@ local keymap = {}
|
|||||||
--- Can also be list of modes to create mapping on multiple modes.
|
--- Can also be list of modes to create mapping on multiple modes.
|
||||||
---@param lhs string Left-hand side |{lhs}| of the mapping.
|
---@param lhs string Left-hand side |{lhs}| of the mapping.
|
||||||
---@param rhs string|function Right-hand side |{rhs}| of the mapping. Can also be a Lua function.
|
---@param rhs string|function Right-hand side |{rhs}| of the mapping. Can also be a Lua function.
|
||||||
--- If a Lua function and `opts.expr == true`, returning `nil` or `false`
|
--- If a Lua function and `opts.expr == true`, returning `nil` is
|
||||||
--- is equivalent to an empty string.
|
--- equivalent to an empty string.
|
||||||
--
|
--
|
||||||
---@param opts table A table of |:map-arguments| such as "silent". In addition to the options
|
---@param opts table A table of |:map-arguments| such as "silent". In addition to the options
|
||||||
--- listed in |nvim_set_keymap()|, this table also accepts the following keys:
|
--- listed in |nvim_set_keymap()|, this table also accepts the following keys:
|
||||||
@@ -62,7 +62,7 @@ function keymap.set(mode, lhs, rhs, opts)
|
|||||||
local user_rhs = rhs
|
local user_rhs = rhs
|
||||||
rhs = function ()
|
rhs = function ()
|
||||||
local res = user_rhs()
|
local res = user_rhs()
|
||||||
if not res then
|
if res == nil then
|
||||||
-- TODO(lewis6991): Handle this in C?
|
-- TODO(lewis6991): Handle this in C?
|
||||||
return ''
|
return ''
|
||||||
elseif opts.replace_keycodes ~= false then
|
elseif opts.replace_keycodes ~= false then
|
||||||
|
Reference in New Issue
Block a user