@@ -47,43 +47,26 @@ function M.toggle(keymap, actions, hls, zindex, preview_keymaps, preview_mode, h
4747 for _ , m in ipairs ({ " builtin" , " fzf" }) do
4848 for k , v in pairs (keymap [m ]) do
4949 if not keymap_ignore [k ] then
50- -- value can be defined as a table with addl properties (help string)
51- if type (v ) == " table" then
52- v = v .desc or v [1 ]
53- end
50+ v = config .get_action_helpstr (v )
5451 -- only add preview keybinds respective of
5552 -- the current preview mode
56- if v and ( not preview_keymaps [v ] or m == preview_mode ) then
53+ if not preview_keymaps [v ] or m == preview_mode then
5754 if m == " builtin" then
5855 k = utils .neovim_bind_to_fzf (k )
5956 end
60- v = type (v ) == " function" and config .get_action_helpstr (v ) or tostring (v )
6157 table.insert (keymaps ,
6258 format_bind (m , k , v , opts .mode_width , opts .keybind_width , opts .name_width ))
6359 end
6460 end
6561 end
6662 end
6763
68- --- TODO: we can always parse the action into table to avoid this duplicated logic
69- --- (e.g. profile/hide.lua, config.lua)
70- --- @param v fzf-lua.ActionSpec
71- --- @return string ?
72- local get_desc = function (v )
73- if type (v ) == " table" then
74- return v .desc or config .get_action_helpstr (v [1 ]) or config .get_action_helpstr (v .fn ) or
75- v .header or tostring (v )
76- elseif v then
77- return config .get_action_helpstr (v ) or tostring (v )
78- end
79- end
80-
8164 -- action keymaps
8265 if actions then
8366 for k , v in pairs (actions ) do
8467 if v then -- skips 'v == false'
8568 if k == " default" then k = " enter" end
86- local desc = get_desc (v )
69+ local desc = config . get_action_helpstr (v )
8770 table.insert (keymaps ,
8871 format_bind (" action" , k ,
8972 (" %s" ):format (desc ):gsub (" " , " " ),
0 commit comments