diff options
| author | William Boman <william@redwill.se> | 2022-04-11 01:04:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-11 01:04:06 +0200 |
| commit | 89abfcd2fbd56c3246772726a85ed0e548d77d3b (patch) | |
| tree | 5a90c3277ee853fe6c1c04be09982b94472f45ab /lua/nvim-lsp-installer/core/managers/git | |
| parent | sumneko_lua: support Linux arm64 (#391) (diff) | |
| download | mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar.gz mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar.bz2 mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar.lz mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar.xz mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.tar.zst mason-89abfcd2fbd56c3246772726a85ed0e548d77d3b.zip | |
make install context available via coroutine context (#586)
Diffstat (limited to 'lua/nvim-lsp-installer/core/managers/git')
| -rw-r--r-- | lua/nvim-lsp-installer/core/managers/git/init.lua | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/lua/nvim-lsp-installer/core/managers/git/init.lua b/lua/nvim-lsp-installer/core/managers/git/init.lua index bdd79917..f3c6ee65 100644 --- a/lua/nvim-lsp-installer/core/managers/git/init.lua +++ b/lua/nvim-lsp-installer/core/managers/git/init.lua @@ -1,23 +1,34 @@ local spawn = require "nvim-lsp-installer.core.spawn" local Result = require "nvim-lsp-installer.core.result" +local installer = require "nvim-lsp-installer.core.installer" + local M = {} ----@param opts {[1]:string} @The first item in the table is the repository to clone. -function M.clone(opts) - ---@async - ---@param ctx InstallContext - return function(ctx) - local repo = assert(opts[1], "No git URL provided.") - ctx.spawn.git { "clone", "--depth", "1", repo, "." } - ctx.requested_version:if_present(function(version) - ctx.spawn.git { "fetch", "--depth", "1", "origin", version } - ctx.spawn.git { "checkout", "FETCH_HEAD" } - end) +---@param repo string +local function with_receipt(repo) + return function() + local ctx = installer.context() ctx.receipt:with_primary_source(ctx.receipt.git_remote(repo)) end end ---@async +---@param opts {[1]:string} @The first item in the table is the repository to clone. +function M.clone(opts) + local ctx = installer.context() + local repo = assert(opts[1], "No git URL provided.") + ctx.spawn.git { "clone", "--depth", "1", repo, "." } + ctx.requested_version:if_present(function(version) + ctx.spawn.git { "fetch", "--depth", "1", "origin", version } + ctx.spawn.git { "checkout", "FETCH_HEAD" } + end) + + return { + with_receipt = with_receipt(repo), + } +end + +---@async ---@param receipt InstallReceipt ---@param install_dir string function M.check_outdated_git_clone(receipt, install_dir) |
