Skip to content

Commit ee95c50

Browse files
authored
Merge pull request #40 from kyoh86/insert-issue-as-markdown-link
Feature: inseert issue as markdown link
2 parents c66aee7 + 35dc855 commit ee95c50

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Telescope gh issues author=windwp label=bug
102102
|---------|----------|
103103
| `<cr>` | insert a reference to the issue |
104104
| `<c-t>` | open web |
105+
| `<c-l>` | insert a markdown-link to the issue |
105106

106107
### Gist
107108
#### Options Filter

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_issue_insert_markdown_link = function(prompt_bufnr)
76+
if not (vim.api.nvim_buf_get_option(vim.api.nvim_get_current_buf(), "modifiable")) then
77+
return
78+
end
79+
local issue_number = close_telescope_prompt(prompt_bufnr)
80+
local text = utils.get_os_command_output {
81+
"gh",
82+
"issue",
83+
"view",
84+
issue_number,
85+
"--json",
86+
"number,title,url",
87+
"--template",
88+
'{{printf "[%s (#%.0f)](%s)" .title .number .url}}',
89+
}
90+
if text then
91+
vim.api.nvim_put(text, "b", true, true)
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_issue_insert_markdown_link)
113114
return true
114115
end,
115116
}):find()

0 commit comments

Comments
 (0)