aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/rust-analyzer/init.lua
blob: c7a9fabf4a9892e459a810d7cda9ff0342b33138 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local Pkg = require "mason-core.package"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local platform = require "mason-core.platform"
local std = require "mason-core.managers.std"

local coalesce, when = _.coalesce, _.when

return Pkg.new {
    name = "rust-analyzer",
    desc = _.dedent [[
        rust-analyzer is an implementation of Language Server Protocol for the Rust programming language. It provides
        features like completion and goto definition for many code editors, including VS Code, Emacs and Vim.
    ]],
    homepage = "https://rust-analyzer.github.io",
    languages = { Pkg.Lang.Rust },
    categories = { Pkg.Cat.LSP },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local asset_file = coalesce(
            when(platform.is.mac_arm64, "rust-analyzer-aarch64-apple-darwin.gz"),
            when(platform.is.mac_x64, "rust-analyzer-x86_64-apple-darwin.gz"),
            when(platform.is.linux_x64_gnu, "rust-analyzer-x86_64-unknown-linux-gnu.gz"),
            when(platform.is.linux_arm64_gnu, "rust-analyzer-aarch64-unknown-linux-gnu.gz"),
            when(platform.is.linux_x64_musl, "rust-analyzer-x86_64-unknown-linux-musl.gz"),
            when(platform.is.win_arm64, "rust-analyzer-aarch64-pc-windows-msvc.zip"),
            when(platform.is.win_x64, "rust-analyzer-x86_64-pc-windows-msvc.zip")
        )

        platform.when {
            unix = function()
                github
                    .gunzip_release_file({
                        repo = "rust-lang/rust-analyzer",
                        asset_file = asset_file,
                        out_file = "rust-analyzer",
                    })
                    .with_receipt()
            end,
            win = function()
                github
                    .unzip_release_file({
                        repo = "rust-lang/rust-analyzer",
                        asset_file = asset_file,
                    })
                    .with_receipt()
            end,
        }
        std.chmod("+x", { "rust-analyzer" })
        ctx:link_bin("rust-analyzer", platform.is.win and "rust-analyzer.exe" or "rust-analyzer")
    end,
}