aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-07-30 16:14:00 +0200
committerGitHub <noreply@github.com>2022-07-30 16:14:00 +0200
commit66f8670e9c5df70c4705a107c524e0abe399fbc4 (patch)
treea1a6df8d344e97905c9b3e44ceb7c39656c0cf01 /lua
parentchore: update package installation issue template (#200) (diff)
downloadmason-66f8670e9c5df70c4705a107c524e0abe399fbc4.tar
mason-66f8670e9c5df70c4705a107c524e0abe399fbc4.tar.gz
mason-66f8670e9c5df70c4705a107c524e0abe399fbc4.tar.bz2
mason-66f8670e9c5df70c4705a107c524e0abe399fbc4.tar.lz
mason-66f8670e9c5df70c4705a107c524e0abe399fbc4.tar.xz
mason-66f8670e9c5df70c4705a107c524e0abe399fbc4.tar.zst
mason-66f8670e9c5df70c4705a107c524e0abe399fbc4.zip
feat(taplo): use prebuilt binary if available (#201)
Diffstat (limited to 'lua')
-rw-r--r--lua/mason-registry/taplo/init.lua31
1 files changed, 27 insertions, 4 deletions
diff --git a/lua/mason-registry/taplo/init.lua b/lua/mason-registry/taplo/init.lua
index bd006eb0..d22c837d 100644
--- a/lua/mason-registry/taplo/init.lua
+++ b/lua/mason-registry/taplo/init.lua
@@ -1,5 +1,10 @@
local Pkg = require "mason-core.package"
local cargo = require "mason-core.managers.cargo"
+local github = require "mason-core.managers.github"
+local _ = require "mason-core.functional"
+local platform = require "mason-core.platform"
+
+local coalesce, when = _.coalesce, _.when
return Pkg.new {
name = "taplo",
@@ -7,8 +12,26 @@ return Pkg.new {
homepage = "https://taplo.tamasfe.dev/",
languages = { Pkg.Lang.TOML },
categories = { Pkg.Cat.LSP },
- install = cargo.crate("taplo-cli", {
- features = "lsp",
- bin = { "taplo" },
- }),
+ ---@async
+ ---@param ctx InstallContext
+ install = function(ctx)
+ local asset_file = coalesce(
+ when(platform.is.mac, "taplo-full-x86_64-apple-darwin-gnu.tar.gz"),
+ when(platform.is.linux_x64, "taplo-full-x86_64-unknown-linux-gnu.tar.gz")
+ )
+ if asset_file then
+ github
+ .untargz_release_file({
+ repo = "tamasfe/taplo",
+ asset_file = asset_file,
+ })
+ .with_receipt()
+ ctx:link_bin("taplo", "taplo")
+ else
+ cargo.crate("taplo-cli", {
+ features = "lsp,toml-test",
+ bin = { "taplo" },
+ })
+ end
+ end,
}