mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-27 19:24:13 +00:00
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> ```
This commit is contained in:
parent
b97ee167f5
commit
6bd07d0b71
1 changed files with 5 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue