Release (#254)
- fix: an autocommand issue when creating an MR - feat: adds a keybinding for copying the URL of the current discussion to the system clipboard This is a #MINOR release
This commit is contained in:
committed by
GitHub
parent
7c3ee0530b
commit
49f2451e59
@@ -837,6 +837,9 @@ M.set_tree_keymaps = function(tree, bufnr, unlinked)
|
||||
vim.keymap.set("n", state.settings.discussion_tree.open_in_browser, function()
|
||||
M.open_in_browser(tree)
|
||||
end, { buffer = bufnr, desc = "Open the note in your browser" })
|
||||
vim.keymap.set("n", state.settings.discussion_tree.copy_node_url, function()
|
||||
M.copy_node_url(tree)
|
||||
end, { buffer = bufnr, desc = "Copy the URL of the current node to clipboard" })
|
||||
vim.keymap.set("n", "<leader>p", function()
|
||||
M.print_node(tree)
|
||||
end, { buffer = bufnr, desc = "Print current node (for debugging)" })
|
||||
@@ -953,7 +956,7 @@ M.add_reply_to_tree = function(tree, note, discussion_id)
|
||||
end
|
||||
|
||||
---@param tree NuiTree
|
||||
M.open_in_browser = function(tree)
|
||||
M.get_url = function(tree)
|
||||
local current_node = tree:get_node()
|
||||
local note_node = M.get_note_node(tree, current_node)
|
||||
if note_node == nil then
|
||||
@@ -964,10 +967,28 @@ M.open_in_browser = function(tree)
|
||||
u.notify("Could not get URL of note", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
return url
|
||||
end
|
||||
|
||||
---@param tree NuiTree
|
||||
M.open_in_browser = function(tree)
|
||||
local url = M.get_url(tree)
|
||||
if url == nil then
|
||||
return
|
||||
end
|
||||
u.open_in_browser(url)
|
||||
end
|
||||
|
||||
---@param tree NuiTree
|
||||
M.copy_node_url = function(tree)
|
||||
local url = M.get_url(tree)
|
||||
if url == nil then
|
||||
return
|
||||
end
|
||||
u.notify("Copied '" .. url .. "' to clipboard", vim.log.levels.INFO)
|
||||
vim.fn.setreg("+", url)
|
||||
end
|
||||
|
||||
M.add_emoji_to_note = function(tree, unlinked)
|
||||
local node = tree:get_node()
|
||||
local note_node = M.get_note_node(tree, node)
|
||||
|
||||
@@ -51,6 +51,7 @@ M.settings = {
|
||||
edit_comment = "e",
|
||||
delete_comment = "dd",
|
||||
open_in_browser = "b",
|
||||
copy_node_url = "u",
|
||||
reply = "r",
|
||||
toggle_node = "t",
|
||||
add_emoji = "Ea",
|
||||
@@ -280,9 +281,9 @@ M.set_popup_keymaps = function(popup, action, linewise_action, opts)
|
||||
local text = u.get_buffer_text(popup.bufnr)
|
||||
if opts.action_before_close then
|
||||
action(text, popup.bufnr)
|
||||
exit(popup, opts)
|
||||
vim.api.nvim_buf_delete(popup.bufnr, {})
|
||||
else
|
||||
exit(popup, opts)
|
||||
vim.api.nvim_buf_delete(popup.bufnr, {})
|
||||
action(text, popup.bufnr)
|
||||
end
|
||||
end, { buffer = popup.bufnr, desc = "Perform action" })
|
||||
|
||||
Reference in New Issue
Block a user