aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/rustfmt/init.lua
diff options
context:
space:
mode:
authorJay Patel <36803168+jayp0521@users.noreply.github.com>2022-11-06 19:54:52 -0500
committerGitHub <noreply@github.com>2022-11-07 01:54:52 +0100
commitf5b1a206c4335e1ccfd4f68feef63ba8950e3e90 (patch)
tree4890bbae81abf23a519239f9ddd25a121e175c09 /lua/mason-registry/rustfmt/init.lua
parentfix(protolint): use Protobuf language (#641) (diff)
downloadmason-f5b1a206c4335e1ccfd4f68feef63ba8950e3e90.tar
mason-f5b1a206c4335e1ccfd4f68feef63ba8950e3e90.tar.gz
mason-f5b1a206c4335e1ccfd4f68feef63ba8950e3e90.tar.bz2
mason-f5b1a206c4335e1ccfd4f68feef63ba8950e3e90.tar.lz
mason-f5b1a206c4335e1ccfd4f68feef63ba8950e3e90.tar.xz
mason-f5b1a206c4335e1ccfd4f68feef63ba8950e3e90.tar.zst
mason-f5b1a206c4335e1ccfd4f68feef63ba8950e3e90.zip
feat(registry): add rustfmt (#642)
Diffstat (limited to 'lua/mason-registry/rustfmt/init.lua')
-rw-r--r--lua/mason-registry/rustfmt/init.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/lua/mason-registry/rustfmt/init.lua b/lua/mason-registry/rustfmt/init.lua
new file mode 100644
index 00000000..e8a03daf
--- /dev/null
+++ b/lua/mason-registry/rustfmt/init.lua
@@ -0,0 +1,32 @@
+local Pkg = require "mason-core.package"
+local _ = require "mason-core.functional"
+local platform = require "mason-core.platform"
+local github = require "mason-core.managers.github"
+
+local coalesce, when = _.coalesce, _.when
+
+return Pkg.new {
+ name = "rustfmt",
+ desc = [[A tool for formatting Rust code according to style guidelines]],
+ homepage = "https://github.com/rust-lang/rustfmt",
+ categories = { Pkg.Cat.Formatter },
+ languages = { Pkg.Lang.Rust },
+ install = function(ctx)
+ ---@param template_string string
+ local function release_file(template_string)
+ return _.compose(_.format(template_string), _.gsub("^v", ""))
+ end
+
+ github
+ .untargz_release_file({
+ repo = "rust-lang/rustfmt",
+ asset_file = coalesce(
+ when(platform.is.mac, release_file "rustfmt_macos-x86_64_%s.tar.gz"),
+ when(platform.is.linux_x64, release_file "rustfmt_linux-x86_64_%s.tar.gz"),
+ when(platform.is.win_x64, release_file "rustfmt_windows-x86_64-msvc_%s.tar.gz")
+ ),
+ })
+ .with_receipt()
+ ctx:link_bin("rustfmt", platform.is.win and "rustfmt.exe" or "rustfmt")
+ end,
+}