Something went wrong. Try again.
Neovim plugin for working with Github pull request comments
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445local GhPrUtils = {}
---@param input_str string---@return table<string>GhPrUtils.split_newlines = function(input_str) local lines = {} -- add each split newline found in string for str in string.gmatch(input_str, "([^\n]+)") do table.insert(lines, str) end return linesend
---@return string[]local function construct_headers() return { "-H", "Accept: application/vnd.github+json", "-H", "X-GitHub-Api-Version: 2022-11-28", "-H", "Authorization: Bearer " .. vim.env["GITHUB_TOKEN"], }end
GhPrUtils.http_get = function(url, cb) local cmd = { "curl", "-sL" } vim.list_extend(cmd, construct_headers()) vim.list_extend(cmd, { url }) vim.system(cmd, { text = true }, function(res) vim.schedule(function() if res == "" or res.code ~= 0 then cb(nil, res.stderr) return end cb(res.stdout, nil) end) end)end
---@param err stringGhPrUtils.err_notify = function(err) vim.notify(err, vim.log.levels.ERROR, { title = "gh-pr-comments.nvim" })end
return GhPrUtils