Skip to content

Commit 6ca90a2

Browse files
committed
feat(ui): added mapping descriptions
1 parent 5473e3d commit 6ca90a2

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

lua/lazy/view/float.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function M:mount()
166166
self:augroup(true)
167167
end, { win = true })
168168
self:focus()
169-
self:on_key(ViewConfig.keys.close, self.close)
169+
self:on_key(ViewConfig.keys.close, self.close, "Close")
170170
self:on({ "BufDelete", "BufHidden" }, self.close)
171171

172172
if vim.bo[self.buf].buftype == "" then

lua/lazy/view/init.lua

+14-12
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function M.create()
8585
require("lazy.manage.process").abort()
8686
require("lazy.async").abort()
8787
return ViewConfig.keys.abort
88-
end, { silent = true, buffer = self.buf, expr = true })
88+
end, { silent = true, buffer = self.buf, expr = true, desc = "Abort" })
8989

9090
vim.keymap.set("n", "gx", "K", { buffer = self.buf, remap = true })
9191

@@ -110,7 +110,7 @@ function M.create()
110110
self.state.plugin = open and selected or nil
111111
self:update()
112112
end
113-
end)
113+
end, "Details")
114114

115115
self:on_key(ViewConfig.keys.next, function()
116116
local cursor = vim.api.nvim_win_get_cursor(self.view.win)
@@ -121,7 +121,7 @@ function M.create()
121121
return
122122
end
123123
end
124-
end)
124+
end, "Next Plugin")
125125

126126
self:on_key(ViewConfig.keys.prev, function()
127127
local cursor = vim.api.nvim_win_get_cursor(self.view.win)
@@ -132,14 +132,14 @@ function M.create()
132132
return
133133
end
134134
end
135-
end)
135+
end, "Prev Plugin")
136136

137137
self:on_key(ViewConfig.keys.profile_sort, function()
138138
if self.state.mode == "profile" then
139139
self.state.profile.sort_time_taken = not self.state.profile.sort_time_taken
140140
self:update()
141141
end
142-
end)
142+
end, "Sort Profile")
143143

144144
self:on_key(ViewConfig.keys.profile_filter, function()
145145
if self.state.mode == "profile" then
@@ -159,17 +159,18 @@ function M.create()
159159
end
160160
end)
161161
end
162-
end)
162+
end, "Filter Profile")
163163

164164
for lhs, rhs in pairs(Config.options.ui.custom_keys) do
165165
if rhs then
166166
local handler = type(rhs) == "table" and rhs[1] or rhs
167+
local desc = type(rhs) == "table" and rhs.desc or nil
167168
self:on_key(lhs, function()
168169
local plugin = self.render:get_plugin()
169170
if plugin then
170171
handler(plugin)
171172
end
172-
end)
173+
end, desc)
173174
end
174175
end
175176

@@ -219,17 +220,17 @@ function M:setup_patterns()
219220
["(https?://%S+)"] = function(url)
220221
Util.open(url)
221222
end,
222-
}, self.hover)
223+
}, self.hover, "Hover")
223224
self:on_pattern(ViewConfig.keys.diff, {
224225
[commit_pattern] = function(hash)
225226
self:diff({ commit = hash })
226227
end,
227-
}, self.diff)
228+
}, self.diff, "Diff")
228229
self:on_pattern(ViewConfig.commands.restore.key_plugin, {
229230
[commit_pattern] = function(hash)
230231
self:restore({ commit = hash })
231232
end,
232-
}, self.restore)
233+
}, self.restore, "Restore")
233234
end
234235

235236
---@param opts? {commit:string}
@@ -294,7 +295,8 @@ end
294295
---@param key string
295296
---@param patterns table<string, fun(str:string)>
296297
---@param fallback? fun(self)
297-
function M:on_pattern(key, patterns, fallback)
298+
---@param desc? string
299+
function M:on_pattern(key, patterns, fallback, desc)
298300
self:on_key(key, function()
299301
local line = vim.api.nvim_get_current_line()
300302
local pos = vim.api.nvim_win_get_cursor(0)
@@ -316,7 +318,7 @@ function M:on_pattern(key, patterns, fallback)
316318
if fallback then
317319
fallback(self)
318320
end
319-
end)
321+
end, desc)
320322
end
321323

322324
function M:setup_modes()

0 commit comments

Comments
 (0)