From 648437aafae63eda06097113c836a8d9ad6f23c1 Mon Sep 17 00:00:00 2001 From: William Boman Date: Fri, 7 Jan 2022 12:18:47 +0100 Subject: feat: integrate gh-cli for GitHub API calls (#403) Closes #248. --- lua/nvim-lsp-installer/core/fetch.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lua/nvim-lsp-installer/core/fetch.lua') diff --git a/lua/nvim-lsp-installer/core/fetch.lua b/lua/nvim-lsp-installer/core/fetch.lua index 3e601cb6..981ad376 100644 --- a/lua/nvim-lsp-installer/core/fetch.lua +++ b/lua/nvim-lsp-installer/core/fetch.lua @@ -4,7 +4,9 @@ local platform = require "nvim-lsp-installer.platform" ---@param url string The url to fetch. ---@param callback fun(err: string|nil, raw_data: string) -local function fetch(url, callback) +---@param opts {custom_fetcher: { cmd: string, args: string[] }} +local function fetch(url, callback, opts) + opts = opts or {} local stdio = process.in_memory_sink() log.fmt_debug("Fetching URL %s", url) local on_exit = function(success) @@ -45,6 +47,17 @@ local function fetch(url, callback) ) end + if opts.custom_fetcher then + table.insert( + job_variants, + 1, + process.lazy_spawn(opts.custom_fetcher.cmd, { + args = opts.custom_fetcher.args, + stdio_sink = stdio.sink, + }) + ) + end + process.attempt { jobs = job_variants, on_iterate = function() -- cgit v1.2.3-70-g09d2