Skip to content

Commit 33f28e3

Browse files
committed
Feature: insert issue as Markdown link
1 parent c66aee7 commit 33f28e3

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

lua/telescope/_extensions/gh_actions.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ A.gh_issue_insert = function(prompt_bufnr)
7272
end
7373
end
7474

75+
A.gh_insert_markdown_link = function(prompt_bufnr)
76+
local issue_number = close_telescope_prompt(prompt_bufnr)
77+
local output = utils.get_os_command_output {
78+
"gh",
79+
"issue",
80+
"view",
81+
issue_number,
82+
"--json",
83+
"number,title,url",
84+
"--template",
85+
'{{printf "%.0f\\x1f%s\\x1f%s" .number .title .url}}',
86+
}
87+
if output then
88+
local tmp_table = vim.split(output[1], "\x1f")
89+
if vim.api.nvim_buf_get_option(vim.api.nvim_get_current_buf(), "modifiable") then
90+
vim.api.nvim_put({ string.format("[%s (#%s)](%s)", tmp_table[2], tmp_table[1], tmp_table[3]) }, "b", true, true)
91+
end
92+
end
93+
end
94+
7595
A.gh_pr_checkout = function(prompt_bufnr)
7696
local pr_number = close_telescope_prompt(prompt_bufnr)
7797
gh_qf_action(pr_number, "checkout", "Checking out pull request #")

lua/telescope/_extensions/gh_builtin.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ B.gh_issues = function(opts)
110110
attach_mappings = function(_, map)
111111
actions.select_default:replace(gh_a.gh_issue_insert)
112112
map("i", "<c-t>", gh_a.gh_web_view "issue")
113+
map("i", "<c-l>", gh_a.gh_insert_markdown_link)
113114
return true
114115
end,
115116
}):find()

0 commit comments

Comments
 (0)