aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-09-14 14:40:38 +0200
committerGitHub <noreply@github.com>2022-09-14 12:40:38 +0000
commit07d949a21aff4c8a379a36ac3e457027efe3a1fe (patch)
tree647563e13e936095bc49b94979317c30ec4a5081 /lua
parentchore: update generated code (#416) (diff)
downloadmason-07d949a21aff4c8a379a36ac3e457027efe3a1fe.tar
mason-07d949a21aff4c8a379a36ac3e457027efe3a1fe.tar.gz
mason-07d949a21aff4c8a379a36ac3e457027efe3a1fe.tar.bz2
mason-07d949a21aff4c8a379a36ac3e457027efe3a1fe.tar.lz
mason-07d949a21aff4c8a379a36ac3e457027efe3a1fe.tar.xz
mason-07d949a21aff4c8a379a36ac3e457027efe3a1fe.tar.zst
mason-07d949a21aff4c8a379a36ac3e457027efe3a1fe.zip
fix(r-languageserver): use github releases as version source (#417)
Diffstat (limited to 'lua')
-rw-r--r--lua/mason-core/managers/github/init.lua30
-rw-r--r--lua/mason-core/receipt.lua2
-rw-r--r--lua/mason-registry/haskell-language-server/init.lua19
-rw-r--r--lua/mason-registry/r-languageserver/init.lua15
4 files changed, 38 insertions, 28 deletions
diff --git a/lua/mason-core/managers/github/init.lua b/lua/mason-core/managers/github/init.lua
index b406f0f9..a3cbd103 100644
--- a/lua/mason-core/managers/github/init.lua
+++ b/lua/mason-core/managers/github/init.lua
@@ -49,19 +49,37 @@ local function with_tag_receipt(repo, tag)
end
---@async
----@param opts {repo: string, version: Optional?, asset_file: string|fun(release: string):string}
-function M.release_file(opts)
+---@param opts {repo: string, version: Optional?}
+function M.release_version(opts)
local ctx = installer.context()
+ ---@type string
local release = _.coalesce(opts.version, ctx.requested_version):or_else_get(function()
return client
.fetch_latest_release(opts.repo)
:map(_.prop "tag_name")
:get_or_throw "Failed to fetch latest release from GitHub API. Refer to :h mason-errors-github-api for more information."
end)
+
+ return {
+ with_receipt = function()
+ ctx.receipt:with_primary_source {
+ type = "github_release",
+ repo = opts.repo,
+ release = release,
+ }
+ end,
+ release = release,
+ }
+end
+
+---@async
+---@param opts {repo: string, version: Optional?, asset_file: string|fun(release: string):string}
+function M.release_file(opts)
+ local source = M.release_version(opts)
---@type string
local asset_file
if type(opts.asset_file) == "function" then
- asset_file = opts.asset_file(release)
+ asset_file = opts.asset_file(source.release)
else
assert(type(opts.asset_file) == "string", "expected asset_file to be a string")
asset_file = opts.asset_file --[[@as string]]
@@ -75,12 +93,12 @@ function M.release_file(opts)
0
)
end
- local download_url = settings.current.github.download_url_template:format(opts.repo, release, asset_file)
+ local download_url = settings.current.github.download_url_template:format(opts.repo, source.release, asset_file)
return {
- release = release,
+ release = source.release,
download_url = download_url,
asset_file = asset_file,
- with_receipt = with_release_file_receipt(opts.repo, download_url, release),
+ with_receipt = with_release_file_receipt(opts.repo, download_url, source.release),
}
end
diff --git a/lua/mason-core/receipt.lua b/lua/mason-core/receipt.lua
index 4d346ed8..68f6cf12 100644
--- a/lua/mason-core/receipt.lua
+++ b/lua/mason-core/receipt.lua
@@ -11,7 +11,6 @@ local M = {}
---| '"cargo"'
---| '"opam"'
---| '"dotnet"'
----| '"r_package"'
---| '"unmanaged"'
---| '"system"'
---| '"jdtls"'
@@ -135,7 +134,6 @@ InstallReceiptBuilder.go = package_source "go"
InstallReceiptBuilder.dotnet = package_source "dotnet"
InstallReceiptBuilder.cargo = package_source "cargo"
InstallReceiptBuilder.composer = package_source "composer"
-InstallReceiptBuilder.r_package = package_source "r_package"
InstallReceiptBuilder.opam = package_source "opam"
InstallReceiptBuilder.luarocks = package_source "luarocks"
diff --git a/lua/mason-registry/haskell-language-server/init.lua b/lua/mason-registry/haskell-language-server/init.lua
index 31262945..8f0e3d42 100644
--- a/lua/mason-registry/haskell-language-server/init.lua
+++ b/lua/mason-registry/haskell-language-server/init.lua
@@ -2,7 +2,7 @@ local a = require "mason-core.async"
local _ = require "mason-core.functional"
local Pkg = require "mason-core.package"
local std = require "mason-core.managers.std"
-local github_client = require "mason-core.managers.github.client"
+local github = require "mason-core.managers.github"
local path = require "mason-core.path"
local platform = require "mason-core.platform"
@@ -15,24 +15,13 @@ return Pkg.new {
---@async
---@param ctx InstallContext
install = function(ctx)
- local repo = "haskell/haskell-language-server"
- local release = ctx.requested_version:or_else_get(function()
- return github_client
- .fetch_latest_release(repo)
- :map(
- ---@param release GitHubRelease
- function(release)
- return release.tag_name
- end
- )
- :get_or_throw()
- end)
+ local source = github.release_version { repo = "haskell/haskell-language-server" }
+ source.with_receipt()
std.ensure_executable("ghcup", { help_url = "https://www.haskell.org/ghcup/" })
ctx:promote_cwd()
- ctx.spawn.ghcup { "install", "hls", release, "-i", ctx.cwd:get() }
+ ctx.spawn.ghcup { "install", "hls", source.release, "-i", ctx.cwd:get() }
- ctx.receipt:with_primary_source(ctx.receipt.github_release(repo, release))
platform.when {
unix = function()
ctx:link_bin(
diff --git a/lua/mason-registry/r-languageserver/init.lua b/lua/mason-registry/r-languageserver/init.lua
index 10d576b8..fd7d0292 100644
--- a/lua/mason-registry/r-languageserver/init.lua
+++ b/lua/mason-registry/r-languageserver/init.lua
@@ -1,8 +1,11 @@
local Pkg = require "mason-core.package"
local path = require "mason-core.path"
+local github_client = require "mason-core.managers.github.client"
+local github = require "mason-core.managers.github"
---@param install_dir string
-local function create_install_script(install_dir)
+---@param ref string
+local function create_install_script(install_dir, ref)
return ([[
options(langserver_library = %q);
options(langserver_quiet = FALSE);
@@ -32,10 +35,11 @@ loadNamespace("languageserversetup", lib.loc = rlsLib);
languageserversetup::languageserver_install(
fullReinstall = FALSE,
confirmBeforeInstall = FALSE,
- strictLibrary = TRUE
+ strictLibrary = TRUE,
+ ref = %q
);
library("languageserver", lib.loc = rlsLib);
-]]):format(install_dir)
+]]):format(install_dir, ref)
end
---@param install_dir string
@@ -58,16 +62,17 @@ return Pkg.new {
---@async
---@param ctx InstallContext
install = function(ctx)
+ local source = github.release_version { repo = "REditorSupport/languageserver" }
+ source.with_receipt()
ctx.spawn.R {
"--no-save",
on_spawn = function(_, stdio)
local stdin = stdio[1]
- stdin:write(create_install_script(ctx.cwd:get()))
+ stdin:write(create_install_script(ctx.cwd:get(), source.release))
stdin:close()
end,
}
ctx.fs:write_file("server.R", create_server_script(ctx.package:get_install_path()))
- ctx.receipt:with_primary_source(ctx.receipt.r_package "languageserver")
ctx:link_bin(
"r-languageserver",