From 8cd1c9d5aa9eb43a82655d9ea7967fa6a88f9d02 Mon Sep 17 00:00:00 2001 From: msc94 Date: Sat, 26 Aug 2023 23:00:22 +0200 Subject: [PATCH] Add ability to yank url into register --- plugin/openingh.lua | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/plugin/openingh.lua b/plugin/openingh.lua index a6dfa18..4178875 100644 --- a/plugin/openingh.lua +++ b/plugin/openingh.lua @@ -21,8 +21,14 @@ vim.api.nvim_create_user_command("OpenInGHFile", function(opts) url = openingh.get_file_url(opts.args, opts.line1, opts.line2) end - openingh.open_url(url) + if opts.reg == "" then + openingh.open_url(url) + else + vim.fn.setreg(opts.reg, url) + print("URL yanked") + end end, { + register = true, range = true, nargs = '?', complete = complete_func, @@ -37,16 +43,30 @@ vim.api.nvim_create_user_command("OpenInGHFileLines", function(opts) url = openingh.get_file_url(opts.args, opts.line1, opts.line2) end - openingh.open_url(url) + if opts.reg == "" then + openingh.open_url(url) + else + vim.fn.setreg(opts.reg, url) + print("URL yanked") + end end, { + register = true, range = true, nargs = '?', complete = complete_func, }) vim.api.nvim_create_user_command("OpenInGHRepo", function(opts) - openingh.open_url(openingh.get_repo_url(opts.args)) + local url = openingh.get_repo_url(opts.args) + + if opts.reg == "" then + openingh.open_url(url) + else + vim.fn.setreg(opts.reg, url) + print("URL yanked") + end end, { + register = true, nargs = '?', complete = complete_func, })