aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-05-28 16:17:14 +0200
committerGitHub <noreply@github.com>2022-05-28 16:17:14 +0200
commit46afeab99a29b083f27abae71b0a530bb855f609 (patch)
tree4d4e973b7a82e164812381ef8c53600dc1939462 /lua
parenttest(luarock): stub std.ensure_executable (#725) (diff)
downloadmason-46afeab99a29b083f27abae71b0a530bb855f609.tar
mason-46afeab99a29b083f27abae71b0a530bb855f609.tar.gz
mason-46afeab99a29b083f27abae71b0a530bb855f609.tar.bz2
mason-46afeab99a29b083f27abae71b0a530bb855f609.tar.lz
mason-46afeab99a29b083f27abae71b0a530bb855f609.tar.xz
mason-46afeab99a29b083f27abae71b0a530bb855f609.tar.zst
mason-46afeab99a29b083f27abae71b0a530bb855f609.zip
refactor: use new github.download_release_file function (#728)
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer/core/managers/github/init.lua8
-rw-r--r--lua/nvim-lsp-installer/servers/bsl_ls/init.lua7
-rw-r--r--lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua7
-rw-r--r--lua/nvim-lsp-installer/servers/solc/init.lua10
-rw-r--r--lua/nvim-lsp-installer/servers/vls/init.lua8
5 files changed, 21 insertions, 19 deletions
diff --git a/lua/nvim-lsp-installer/core/managers/github/init.lua b/lua/nvim-lsp-installer/core/managers/github/init.lua
index 10c7c049..fe4a4c5a 100644
--- a/lua/nvim-lsp-installer/core/managers/github/init.lua
+++ b/lua/nvim-lsp-installer/core/managers/github/init.lua
@@ -112,6 +112,14 @@ end)
---@async
---@param opts {repo: string, out_file:string, asset_file: string|fun(release: string):string}
+function M.download_release_file(opts)
+ local release_file_source = M.release_file(opts)
+ std.download_file(release_file_source.download_url, assert(opts.out_file, "out_file is required"))
+ return release_file_source
+end
+
+---@async
+---@param opts {repo: string, out_file:string, asset_file: string|fun(release: string):string}
function M.gunzip_release_file(opts)
local release_file_source = M.release_file(opts)
local gzipped_file = ("%s.gz"):format(assert(opts.out_file, "out_file must be specified"))
diff --git a/lua/nvim-lsp-installer/servers/bsl_ls/init.lua b/lua/nvim-lsp-installer/servers/bsl_ls/init.lua
index 4aba52f2..468f3ef6 100644
--- a/lua/nvim-lsp-installer/servers/bsl_ls/init.lua
+++ b/lua/nvim-lsp-installer/servers/bsl_ls/init.lua
@@ -11,15 +11,14 @@ return function(name, root_dir)
languages = { "onescript" },
installer = function()
std.ensure_executable "java"
- local source = github.release_file {
+ github.download_release_file({
repo = "1c-syntax/bsl-language-server",
+ out_file = "bsl-lsp.jar",
asset_file = function(release)
local version = release:gsub("^v", "")
return ("bsl-language-server-%s-exec.jar"):format(version)
end,
- }
- source.with_receipt()
- std.download_file(source.download_url, "bsl-lsp.jar")
+ }).with_receipt()
end,
default_options = {
cmd = {
diff --git a/lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua b/lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua
index 05a37e6e..b89e0d3e 100644
--- a/lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua
+++ b/lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua
@@ -14,16 +14,15 @@ return function(name, root_dir)
homepage = "https://github.com/kitten/prosemd-lsp",
languages = { "markdown" },
installer = function()
- local source = github.release_file {
+ github.download_release_file({
repo = "kitten/prosemd-lsp",
+ out_file = platform.is_win and "prosemd-lsp.exe" or "prosemd-lsp",
asset_file = coalesce(
when(platform.is_mac, "prosemd-lsp-macos"),
when(platform.is_linux and platform.arch == "x64", "prosemd-lsp-linux"),
when(platform.is_win and platform.arch == "x64", "prosemd-lsp-windows.exe")
),
- }
- source.with_receipt()
- std.download_file(source.download_url, platform.is_win and "prosemd-lsp.exe" or "prosemd-lsp")
+ }).with_receipt()
std.chmod("+x", { "prosemd-lsp" })
end,
default_options = {
diff --git a/lua/nvim-lsp-installer/servers/solc/init.lua b/lua/nvim-lsp-installer/servers/solc/init.lua
index 5f85b82f..1f74f56e 100644
--- a/lua/nvim-lsp-installer/servers/solc/init.lua
+++ b/lua/nvim-lsp-installer/servers/solc/init.lua
@@ -14,18 +14,16 @@ return function(name, root_dir)
homepage = "https://github.com/ethereum/solidity",
languages = { "solidity" },
installer = function()
- local source = github.release_file {
+ github.download_release_file({
repo = "ethereum/solidity",
+ out_file = platform.is_win and "solc.exe" or "solc",
asset_file = coalesce(
when(platform.is_mac, "solc-macos"),
when(platform.is_linux, "solc-static-linux"),
when(platform.is_win, "solc-windows.exe")
),
- }
- source.with_receipt()
- local bin_name = platform.is_win and "solc.exe" or "solc"
- std.download_file(source.download_url, bin_name)
- std.chmod("+x", { bin_name })
+ }).with_receipt()
+ std.chmod("+x", { "solc" })
end,
default_options = {
cmd_env = {
diff --git a/lua/nvim-lsp-installer/servers/vls/init.lua b/lua/nvim-lsp-installer/servers/vls/init.lua
index 207cb819..c531d2f6 100644
--- a/lua/nvim-lsp-installer/servers/vls/init.lua
+++ b/lua/nvim-lsp-installer/servers/vls/init.lua
@@ -1,5 +1,4 @@
local server = require "nvim-lsp-installer.server"
-local path = require "nvim-lsp-installer.core.path"
local github = require "nvim-lsp-installer.core.managers.github"
local github_client = require "nvim-lsp-installer.core.managers.github.client"
local std = require "nvim-lsp-installer.core.managers.std"
@@ -22,17 +21,16 @@ return function(name, root_dir)
local latest_dev_build =
github_client.fetch_latest_release(repo, { include_prerelease = true }):get_or_throw()
- local source = github.release_file {
+ github.download_release_file({
version = Optional.of(latest_dev_build.tag_name),
repo = repo,
+ out_file = platform.is.win and "vls.exe" or "vls",
asset_file = functional.coalesce(
functional.when(platform.is.linux_x64, "vls_linux_x64"),
functional.when(platform.is.mac, "vls_macos_x64"),
functional.when(platform.is.win_x64, "vls_windows_x64.exe")
),
- }
- source.with_receipt()
- std.download_file(source.download_url, platform.is.win and "vls.exe" or "vls")
+ }).with_receipt()
std.chmod("+x", { "vls" })
end,
default_options = {