Skip to content

Commit 49f2451

Browse files
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
1 parent 7c3ee05 commit 49f2451

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ require("gitlab").setup({
149149
toggle_resolved = "p" -- Toggles the resolved status of the whole discussion
150150
position = "left", -- "top", "right", "bottom" or "left"
151151
open_in_browser = "b" -- Jump to the URL of the current note/discussion
152+
copy_node_url = "u", -- Copy the URL of the current node to clipboard
152153
size = "20%", -- Size of split
153154
relative = "editor", -- Position of tree split relative to "editor" or "window"
154155
resolved = '', -- Symbol to show next to resolved discussions

doc/gitlab.nvim.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ you call this function with no values the defaults will be used:
173173
toggle_resolved = "p" -- Toggles the resolved status of the whole discussion
174174
position = "left", -- "top", "right", "bottom" or "left"
175175
open_in_browser = "b" -- Jump to the URL of the current note/discussion
176+
copy_node_url = "u", -- Copy the URL of the current node to clipboard
176177
size = "20%", -- Size of split
177178
relative = "editor", -- Position of tree split relative to "editor" or "window"
178179
resolved = '✓', -- Symbol to show next to resolved discussions
@@ -551,7 +552,7 @@ you can also interact with the Go server like any other process:
551552
LUA API *gitlab.nvim.api*
552553

553554
*gitlab.nvim.setup*
554-
setup() ~
555+
gitlab.setup() ~
555556

556557
Call this first to initialize the plugin. With no arguments, it will use the
557558
default arguments outlined under "Configuring the Plugin".
@@ -563,15 +564,15 @@ default arguments outlined under "Configuring the Plugin".
563564
require("gitlab").setup({ discussion_tree = { blacklist = { "some_bot"} } })
564565
<
565566
*gitlab.nvim.review*
566-
review() ~
567+
gitlab.review() ~
567568

568569
Opens the reviewer pane. Can be used from anywhere within Neovim after the
569570
plugin is loaded. If run twice, will open a second reviewer pane.
570571
>lua
571572
require("gitlab").review()
572573
<
573574
*gitlab.nvim.summary*
574-
summary() ~
575+
gitlab.summary() ~
575576

576577
Opens the summary window with information about the current MR, such as the
577578
description, the author, and the title. Can be configured via the `info` field
@@ -583,7 +584,7 @@ The summary can be edited. Once you have made changes, send them to Gitlab via
583584
the `settings.popup.perform_action` keybinding.
584585

585586
*gitlab.nvim.approve*
586-
approve() ~
587+
gitlab.approve() ~
587588

588589
Approves the current MR. Will error if the current user does not have
589590
permission.
@@ -604,13 +605,13 @@ gitlab.create_comment() ~
604605
Opens a popup to create a comment on the current line. Must be called when focused on the
605606
reviewer pane (see the gitlab.nvim.review command), otherwise it will error.
606607
>lua
607-
require("gitlab").comment()
608+
require("gitlab").create_comment()
608609

609610
After the comment is typed, submit it to Gitlab via the `settings.popup.perform_action`
610611
keybinding, by default `<leader>l`.
611612

612613
*gitlab.nvim.create_multiline_comment*
613-
create_multiline_comment() ~
614+
gitlab.create_multiline_comment() ~
614615

615616
Opens a popup to create a multi-line comment. May only be called in visual
616617
mode, and will use the currently selected lines.
@@ -621,7 +622,7 @@ After the comment is typed, submit it to Gitlab via the |settings.popup.perform_
621622
keybinding, by default `<leader>l`.
622623

623624
*gitlab.nvim.create_comment_suggestion*
624-
create_comment_suggestion() ~
625+
gitlab.create_comment_suggestion() ~
625626

626627
Opens a popup to create a comment suggestion (aka a comment that makes a committable
627628
change suggestion to the currently selected lines).

lua/gitlab/actions/discussions/init.lua

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,9 @@ M.set_tree_keymaps = function(tree, bufnr, unlinked)
837837
vim.keymap.set("n", state.settings.discussion_tree.open_in_browser, function()
838838
M.open_in_browser(tree)
839839
end, { buffer = bufnr, desc = "Open the note in your browser" })
840+
vim.keymap.set("n", state.settings.discussion_tree.copy_node_url, function()
841+
M.copy_node_url(tree)
842+
end, { buffer = bufnr, desc = "Copy the URL of the current node to clipboard" })
840843
vim.keymap.set("n", "<leader>p", function()
841844
M.print_node(tree)
842845
end, { buffer = bufnr, desc = "Print current node (for debugging)" })
@@ -953,7 +956,7 @@ M.add_reply_to_tree = function(tree, note, discussion_id)
953956
end
954957

955958
---@param tree NuiTree
956-
M.open_in_browser = function(tree)
959+
M.get_url = function(tree)
957960
local current_node = tree:get_node()
958961
local note_node = M.get_note_node(tree, current_node)
959962
if note_node == nil then
@@ -964,10 +967,28 @@ M.open_in_browser = function(tree)
964967
u.notify("Could not get URL of note", vim.log.levels.ERROR)
965968
return
966969
end
970+
return url
971+
end
967972

973+
---@param tree NuiTree
974+
M.open_in_browser = function(tree)
975+
local url = M.get_url(tree)
976+
if url == nil then
977+
return
978+
end
968979
u.open_in_browser(url)
969980
end
970981

982+
---@param tree NuiTree
983+
M.copy_node_url = function(tree)
984+
local url = M.get_url(tree)
985+
if url == nil then
986+
return
987+
end
988+
u.notify("Copied '" .. url .. "' to clipboard", vim.log.levels.INFO)
989+
vim.fn.setreg("+", url)
990+
end
991+
971992
M.add_emoji_to_note = function(tree, unlinked)
972993
local node = tree:get_node()
973994
local note_node = M.get_note_node(tree, node)

lua/gitlab/state.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ M.settings = {
5151
edit_comment = "e",
5252
delete_comment = "dd",
5353
open_in_browser = "b",
54+
copy_node_url = "u",
5455
reply = "r",
5556
toggle_node = "t",
5657
add_emoji = "Ea",
@@ -280,9 +281,9 @@ M.set_popup_keymaps = function(popup, action, linewise_action, opts)
280281
local text = u.get_buffer_text(popup.bufnr)
281282
if opts.action_before_close then
282283
action(text, popup.bufnr)
283-
exit(popup, opts)
284+
vim.api.nvim_buf_delete(popup.bufnr, {})
284285
else
285-
exit(popup, opts)
286+
vim.api.nvim_buf_delete(popup.bufnr, {})
286287
action(text, popup.bufnr)
287288
end
288289
end, { buffer = popup.bufnr, desc = "Perform action" })

0 commit comments

Comments
 (0)