Skip to content

Commit bee02fb

Browse files
authored
feat(keymaps): add descriptions to winbar keymaps (#183)
* feat(keymaps): add descriptions to winbar keymaps * feat(keymaps): handle function labels as descriptions
1 parent ce8f15a commit bee02fb

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lua/dap-view/options/winbar/init.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,23 @@ M.set_action_keymaps = function(bufnr)
9999
if bufnr or state.bufnr then
100100
local winbar = setup.config.winbar
101101

102+
local win_width = api.nvim_win_get_width(state.winnr)
103+
102104
for k, view in pairs(winbar.sections) do
103105
local section = winbar.custom_sections[view] or winbar.base_sections[view]
104106

105107
if section == nil then
106108
vim.notify_once("View '" .. view .. "' not found, skipping setup", log.WARN)
107109
winbar.sections[k] = nil
108110
else
111+
local desc = type(section.label) == "function" and section.label(win_width, state.current_section)
112+
or section.label
113+
114+
---@cast desc string
115+
109116
vim.keymap.set("n", section.keymap, function()
110117
M.wrapped_action(view)
111-
end, { buffer = bufnr or state.bufnr })
118+
end, { buffer = bufnr or state.bufnr, desc = desc })
112119
end
113120
end
114121
end

0 commit comments

Comments
 (0)