diff options
| author | William Boman <william@redwill.se> | 2023-02-20 22:19:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-20 22:19:39 +0100 |
| commit | b8a6632a0f2d263199d5d480ca85477fe0f414ab (patch) | |
| tree | 57e1ee0f3cef078ec144ecdf1b2fa861acf47755 /lua/mason-registry/index/rustfmt/init.lua | |
| parent | chore: autogenerate (#1015) (diff) | |
| download | mason-b8a6632a0f2d263199d5d480ca85477fe0f414ab.tar mason-b8a6632a0f2d263199d5d480ca85477fe0f414ab.tar.gz mason-b8a6632a0f2d263199d5d480ca85477fe0f414ab.tar.bz2 mason-b8a6632a0f2d263199d5d480ca85477fe0f414ab.tar.lz mason-b8a6632a0f2d263199d5d480ca85477fe0f414ab.tar.xz mason-b8a6632a0f2d263199d5d480ca85477fe0f414ab.tar.zst mason-b8a6632a0f2d263199d5d480ca85477fe0f414ab.zip | |
feat: configurable registries (#1016)
Diffstat (limited to 'lua/mason-registry/index/rustfmt/init.lua')
| -rw-r--r-- | lua/mason-registry/index/rustfmt/init.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lua/mason-registry/index/rustfmt/init.lua b/lua/mason-registry/index/rustfmt/init.lua new file mode 100644 index 00000000..c53aa98a --- /dev/null +++ b/lua/mason-registry/index/rustfmt/init.lua @@ -0,0 +1,40 @@ +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 path = require "mason-core.path" + +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 }, + ---@async + ---@param ctx InstallContext + install = function(ctx) + platform.when { + unix = function() + local source = github.untargz_release_file { + repo = "rust-lang/rustfmt", + asset_file = coalesce( + when(platform.is.mac, _.format "rustfmt_macos-x86_64_%s.tar.gz"), + when(platform.is.linux_x64, _.format "rustfmt_linux-x86_64_%s.tar.gz") + ), + } + source.with_receipt() + ctx:link_bin("rustfmt", path.concat { source.asset_file:gsub("%.tar%.gz$", ""), "rustfmt" }) + end, + win = function() + local source = github.unzip_release_file { + repo = "rust-lang/rustfmt", + asset_file = coalesce(when(platform.is.win_x64, _.format "rustfmt_windows-x86_64-msvc_%s.zip")), + } + source.with_receipt() + ctx:link_bin("rustfmt", path.concat { source.asset_file:gsub("%.zip$", ""), "rustfmt.exe" }) + end, + } + end, +} |
