aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/cmp-gh-source.lua
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-10-17 21:26:40 +0200
committersrdusr <trevorgray@srdusr.com>2023-10-17 21:26:40 +0200
commit54a7c1bf02da30c353ddb4af51b065d895801f47 (patch)
tree08dfaa302a7c7018d0dc03fe00518c8129c87c7b /.config/nvim/lua/plugins/cmp-gh-source.lua
parent1938838a043b13169a550af5ea37239adfc75293 (diff)
parentc3c0307c2fc26410249df9578c7bf16eb0caa9df (diff)
downloaddotfiles-54a7c1bf02da30c353ddb4af51b065d895801f47.tar.gz
dotfiles-54a7c1bf02da30c353ddb4af51b065d895801f47.zip
Merge commit '67d475c7259bf2448fa3f1d330885ea88036668d'
Diffstat (limited to '.config/nvim/lua/plugins/cmp-gh-source.lua')
-rw-r--r--.config/nvim/lua/plugins/cmp-gh-source.lua74
1 files changed, 36 insertions, 38 deletions
diff --git a/.config/nvim/lua/plugins/cmp-gh-source.lua b/.config/nvim/lua/plugins/cmp-gh-source.lua
index 05bba55..4990c35 100644
--- a/.config/nvim/lua/plugins/cmp-gh-source.lua
+++ b/.config/nvim/lua/plugins/cmp-gh-source.lua
@@ -1,4 +1,4 @@
-local ok, Job = pcall(require, "plenary.job")
+local ok, Job = pcall(require, 'plenary.job')
if not ok then
return
end
@@ -19,54 +19,52 @@ source.complete = function(self, _, callback)
-- You could remove this if you wanted, but this just makes it so we're
-- good programming citizens.
if not self.cache[bufnr] then
- Job
- :new({
- -- Uses `gh` executable to request the issues from the remote repository.
- "gh",
- "issue",
- "list",
- "--limit",
- "1000",
- "--json",
- "title,number,body",
+ Job:new({
+ -- Uses `gh` executable to request the issues from the remote repository.
+ 'gh',
+ 'issue',
+ 'list',
+ '--limit',
+ '1000',
+ '--json',
+ 'title,number,body',
- on_exit = function(job)
- local result = job:result()
- local ok, parsed = pcall(vim.json.decode, table.concat(result, ""))
- if not ok then
- vim.notify "Failed to parse gh result"
- return
- end
+ on_exit = function(job)
+ local result = job:result()
+ local ok, parsed = pcall(vim.json.decode, table.concat(result, ''))
+ if not ok then
+ vim.notify('Failed to parse gh result')
+ return
+ end
- local items = {}
- for _, gh_item in ipairs(parsed) do
- gh_item.body = string.gsub(gh_item.body or "", "\r", "")
+ local items = {}
+ for _, gh_item in ipairs(parsed) do
+ gh_item.body = string.gsub(gh_item.body or '', '\r', '')
- table.insert(items, {
- label = string.format("#%s", gh_item.number),
- documentation = {
- kind = "markdown",
- value = string.format("# %s\n\n%s", gh_item.title, gh_item.body),
- },
- })
- end
+ table.insert(items, {
+ label = string.format('#%s', gh_item.number),
+ documentation = {
+ kind = 'markdown',
+ value = string.format('# %s\n\n%s', gh_item.title, gh_item.body),
+ },
+ })
+ end
- callback { items = items, isIncomplete = false }
- self.cache[bufnr] = items
- end,
- })
- :start()
+ callback({ items = items, isIncomplete = false })
+ self.cache[bufnr] = items
+ end,
+ }):start()
else
- callback { items = self.cache[bufnr], isIncomplete = false }
+ callback({ items = self.cache[bufnr], isIncomplete = false })
end
end
source.get_trigger_characters = function()
- return { "#" }
+ return { '#' }
end
source.is_available = function()
- return vim.bo.filetype == "gitcommit"
+ return vim.bo.filetype == 'gitcommit'
end
-require("cmp").register_source("gh_issues", source.new())
+require('cmp').register_source('gh_issues', source.new())