Skip to content

Commit fb40198

Browse files
committed
Fix: Add opts to help popup
1 parent 4fc1bbd commit fb40198

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

lua/gitlab/actions/discussions/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ M.set_tree_keymaps = function(tree, bufnr, unlinked)
725725

726726
if keymaps.help then
727727
vim.keymap.set("n", keymaps.help, function()
728-
help.open()
728+
help.open({ discussion_tree = true })
729729
end, { buffer = bufnr, desc = "Open help popup", nowait = keymaps.help_nowait })
730730
end
731731

lua/gitlab/actions/help.lua

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ local state = require("gitlab.state")
66
local List = require("gitlab.utils.list")
77
local 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

Comments
 (0)