@@ -6,7 +6,12 @@ local state = require("gitlab.state")
66local List = require (" gitlab.utils.list" )
77local Popup = require (" nui.popup" )
88
9- M .open = function ()
9+ --- @class HelpPopupOpts
10+ --- @field discussion_tree boolean | nil Whether help popup is for the discussion tree
11+
12+ --- @param opts HelpPopupOpts | nil Table with options for the help popup
13+ M .open = function (opts )
14+ local help_opts = opts or {}
1015 local bufnr = vim .api .nvim_get_current_buf ()
1116 local keymaps = vim .api .nvim_buf_get_keymap (bufnr , " n" )
1217 local help_content_lines = List .new (keymaps ):reduce (function (agg , keymap )
@@ -17,26 +22,28 @@ M.open = function()
1722 return agg
1823 end , {})
1924
20- table.insert (help_content_lines , " " )
21- table.insert (
22- help_content_lines ,
23- string.format (
24- " %s = draft; %s = unlinked comment; %s = resolved" ,
25- state .settings .discussion_tree .draft ,
26- state .settings .discussion_tree .unlinked ,
27- state .settings .discussion_tree .resolved
25+ if help_opts .discussion_tree then
26+ table.insert (help_content_lines , " " )
27+ table.insert (
28+ help_content_lines ,
29+ string.format (
30+ " %s = draft; %s = unlinked comment; %s = resolved" ,
31+ state .settings .discussion_tree .draft ,
32+ state .settings .discussion_tree .unlinked ,
33+ state .settings .discussion_tree .resolved
34+ )
2835 )
29- )
36+ end
3037
3138 local longest_line = u .get_longest_string (help_content_lines )
32- local opts = { " Help" , state .settings .popup .help , longest_line + 3 , # help_content_lines , 70 }
33- local help_popup = Popup (popup .create_popup_state (unpack (opts )))
39+ local popup_opts = { " Help" , state .settings .popup .help , longest_line + 3 , # help_content_lines , 70 }
40+ local help_popup = Popup (popup .create_popup_state (unpack (popup_opts )))
3441
3542 help_popup :on (event .BufLeave , function ()
3643 help_popup :unmount ()
3744 end )
3845
39- popup .set_up_autocommands (help_popup , nil , vim .api .nvim_get_current_win (), opts )
46+ popup .set_up_autocommands (help_popup , nil , vim .api .nvim_get_current_win (), popup_opts )
4047
4148 help_popup :mount ()
4249
0 commit comments