From 6bd07d0b71582dce6c15cadc3dea3b5585dad66e Mon Sep 17 00:00:00 2001 From: Yaroslav Chvanov Date: Wed, 11 Dec 2024 01:28:56 +0300 Subject: [PATCH] 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 `{ "f", "FzfLua files" },` `:map` now shows: ``` n f * FzfLua files ``` How `:map` looks after the plugin is loaded: ``` n f * FzfLua files ``` --- lua/lazy/core/handler/keys.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua index 57fbc181..fb3fce3a 100644 --- a/lua/lazy/core/handler/keys.lua +++ b/lua/lazy/core/handler/keys.lua @@ -112,6 +112,11 @@ function M:_add(keys) local lhs = keys.lhs local opts = M.opts(keys) + local rhs = keys.rhs -- Work-around lua-language-server type inference. + -- Pass string rhs to desc to make it visible before loading the plugin, or we will only see file path to closure + -- below. + opts.desc = opts.desc or type(rhs) == "string" and rhs or nil + ---@param buf? number local function add(buf) if M.is_nop(keys) then