Make Popups Configurable (#129)

This makes the popups in the plugin (those for editing and creating comments, replies, the pipeline, etc) configurable. Users can change the default width, height, transparency, and border properties, and set overrides per popup.
This commit is contained in:
Jakub F. Bortlík
2023-12-05 14:06:32 +01:00
committed by GitHub
parent 02db3e4b0e
commit cc68476b15
8 changed files with 75 additions and 37 deletions

View File

@@ -13,8 +13,6 @@ local reviewer = require("gitlab.reviewer")
local miscellaneous = require("gitlab.actions.miscellaneous")
local discussions_tree = require("gitlab.actions.discussions.tree")
local edit_popup = Popup(u.create_popup_state("Edit Comment", "80%", "80%"))
local reply_popup = Popup(u.create_popup_state("Reply", "80%", "80%"))
local discussion_sign_name = "gitlab_discussion"
local discussion_helper_sign_start = "gitlab_discussion_helper_start"
local discussion_helper_sign_mid = "gitlab_discussion_helper_mid"
@@ -470,6 +468,7 @@ end
-- The reply popup will mount in a window when you trigger it (settings.discussion_tree.reply) when hovering over a node in the discussion tree.
M.reply = function(tree)
local reply_popup = Popup(u.create_popup_state("Reply", state.settings.popup.reply))
local node = tree:get_node()
local discussion_node = M.get_root_node(tree, node)
local id = tostring(discussion_node.id)
@@ -536,6 +535,7 @@ end
-- This function (settings.discussion_tree.edit_comment) will open the edit popup for the current comment in the discussion tree
M.edit_comment = function(tree, unlinked)
local edit_popup = Popup(u.create_popup_state("Edit Comment", state.settings.popup.edit))
local current_node = tree:get_node()
local note_node = M.get_note_node(tree, current_node)
local root_node = M.get_root_node(tree, current_node)
@@ -811,37 +811,37 @@ M.set_tree_keymaps = function(tree, bufnr, unlinked)
if M.is_current_node_note(tree) then
M.edit_comment(tree, unlinked)
end
end, { buffer = bufnr })
end, { buffer = bufnr, desc = "Edit comment" })
vim.keymap.set("n", state.settings.discussion_tree.delete_comment, function()
if M.is_current_node_note(tree) then
M.delete_comment(tree, unlinked)
end
end, { buffer = bufnr })
end, { buffer = bufnr, desc = "Delete comment" })
vim.keymap.set("n", state.settings.discussion_tree.toggle_resolved, function()
if M.is_current_node_note(tree) then
M.toggle_discussion_resolved(tree)
end
end, { buffer = bufnr })
end, { buffer = bufnr, desc = "Toggle resolved" })
vim.keymap.set("n", state.settings.discussion_tree.toggle_node, function()
M.toggle_node(tree)
end, { buffer = bufnr })
end, { buffer = bufnr, desc = "Toggle node" })
vim.keymap.set("n", state.settings.discussion_tree.reply, function()
if M.is_current_node_note(tree) then
M.reply(tree)
end
end, { buffer = bufnr })
end, { buffer = bufnr, desc = "Reply" })
if not unlinked then
vim.keymap.set("n", state.settings.discussion_tree.jump_to_file, function()
if M.is_current_node_note(tree) then
M.jump_to_file(tree)
end
end, { buffer = bufnr })
end, { buffer = bufnr, desc = "Jump to file" })
vim.keymap.set("n", state.settings.discussion_tree.jump_to_reviewer, function()
if M.is_current_node_note(tree) then
M.jump_to_reviewer(tree)
end
end, { buffer = bufnr })
end, { buffer = bufnr, desc = "Jump to reviewer" })
end
end