Skip to content

Commit 6bd07d0

Browse files
feat(keys): add mapping rhs as description for temporary lazy mappings
Fixes `:map` not showing what the mapping does until the plugin is loaded. With lazy mapping `{ "<Leader>f", "<Cmd>FzfLua files<CR>" },` `:map` now shows: ``` n <Space>f * <Lua 79: ~/.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/keys.lua:126> <Cmd>FzfLua files<CR> ``` How `:map` looks after the plugin is loaded: ``` n <Space>f * <Cmd>FzfLua files<CR> ```
1 parent b97ee16 commit 6bd07d0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lua/lazy/core/handler/keys.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ function M:_add(keys)
112112
local lhs = keys.lhs
113113
local opts = M.opts(keys)
114114

115+
local rhs = keys.rhs -- Work-around lua-language-server type inference.
116+
-- Pass string rhs to desc to make it visible before loading the plugin, or we will only see file path to closure
117+
-- below.
118+
opts.desc = opts.desc or type(rhs) == "string" and rhs or nil
119+
115120
---@param buf? number
116121
local function add(buf)
117122
if M.is_nop(keys) then

0 commit comments

Comments
 (0)