aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/core
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-05-01 22:16:51 +0200
committerGitHub <noreply@github.com>2022-05-01 22:16:51 +0200
commit5b4b790f40794d9579b6330aa8cccadf5e0e50ed (patch)
tree2e498d7d2cbc87f9f83435019fef787810af49db /lua/nvim-lsp-installer/core
parentadd hoon_ls (#570) (diff)
downloadmason-5b4b790f40794d9579b6330aa8cccadf5e0e50ed.tar
mason-5b4b790f40794d9579b6330aa8cccadf5e0e50ed.tar.gz
mason-5b4b790f40794d9579b6330aa8cccadf5e0e50ed.tar.bz2
mason-5b4b790f40794d9579b6330aa8cccadf5e0e50ed.tar.lz
mason-5b4b790f40794d9579b6330aa8cccadf5e0e50ed.tar.xz
mason-5b4b790f40794d9579b6330aa8cccadf5e0e50ed.tar.zst
mason-5b4b790f40794d9579b6330aa8cccadf5e0e50ed.zip
fix(hls): download archive from downloads.haskell.org (#651)
Diffstat (limited to 'lua/nvim-lsp-installer/core')
-rw-r--r--lua/nvim-lsp-installer/core/managers/std/init.lua27
-rw-r--r--lua/nvim-lsp-installer/core/receipt.lua10
2 files changed, 33 insertions, 4 deletions
diff --git a/lua/nvim-lsp-installer/core/managers/std/init.lua b/lua/nvim-lsp-installer/core/managers/std/init.lua
index 05495573..ded0361a 100644
--- a/lua/nvim-lsp-installer/core/managers/std/init.lua
+++ b/lua/nvim-lsp-installer/core/managers/std/init.lua
@@ -120,19 +120,25 @@ end
---@async
---@param file string
-function M.untarxz(file)
+---@param opts {strip_components:integer}
+function M.untarxz(file, opts)
+ opts = opts or {}
local ctx = installer.context()
platform.when {
unix = function()
- M.untar(file)
+ M.untar(file, opts)
end,
win = function()
Result.run_catching(function()
win_extract(file) -- unpack .tar.xz to .tar
local uncompressed_tar = file:gsub(".xz$", "")
- M.untar(uncompressed_tar)
+ M.untar(uncompressed_tar, opts)
end):recover(function()
- ctx.spawn.arc { "unarchive", file }
+ ctx.spawn.arc {
+ "unarchive",
+ opts.strip_components and { "--strip-components", opts.strip_components } or vim.NIL,
+ file,
+ }
pcall(function()
ctx.fs:unlink(file)
end)
@@ -165,4 +171,17 @@ function M.chmod(flags, files)
end
end
+---@async
+---Wrapper around vim.ui.select.
+---@param items table
+---@params opts
+function M.select(items, opts)
+ assert(not platform.is_headless, "Tried to prompt for user input while in headless mode.")
+ if vim.in_fast_event() then
+ a.scheduler()
+ end
+ local async_select = a.promisify(vim.ui.select)
+ return async_select(items, opts)
+end
+
return M
diff --git a/lua/nvim-lsp-installer/core/receipt.lua b/lua/nvim-lsp-installer/core/receipt.lua
index 4517256a..b2300774 100644
--- a/lua/nvim-lsp-installer/core/receipt.lua
+++ b/lua/nvim-lsp-installer/core/receipt.lua
@@ -126,6 +126,16 @@ InstallReceiptBuilder.opam = package_source "opam"
InstallReceiptBuilder.unmanaged = { type = "unmanaged" }
+---@param repo string
+---@param release string
+function InstallReceiptBuilder.github_release(repo, release)
+ return {
+ type = "github_release",
+ repo = repo,
+ release = release,
+ }
+end
+
---@param dependency string
function InstallReceiptBuilder.system(dependency)
return { type = "system", dependency = dependency }