aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/bicep-lsp/init.lua
blob: 8472505a4d94a5a2da7fc1a86cde8362e138e7db (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
local Pkg = require "mason-core.package"
local path = require "mason-core.path"
local std = require "mason-core.managers.std"
local github = require "mason-core.managers.github"

return Pkg.new {
    name = "bicep-lsp",
    desc = [[Bicep is a declarative language for describing and deploying Azure resources]],
    homepage = "https://github.com/Azure/bicep",
    languages = { Pkg.Lang.Bicep },
    categories = { Pkg.Cat.LSP },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        std.ensure_executable("dotnet", { help_url = "https://dotnet.microsoft.com/download" })
        ctx.fs:mkdir "vscode"
        ctx:chdir("vscode", function()
            -- The bicep-langserver.zip is a bit broken on POSIX systems - so we download it via the VSCode distribution
            -- instead. See https://github.com/Azure/bicep/issues/3704.
            github
                .unzip_release_file({
                    repo = "Azure/bicep",
                    asset_file = "vscode-bicep.vsix",
                })
                .with_receipt()
        end)
        ctx.fs:rename(path.concat { "vscode", "extension", "bicepLanguageServer" }, "bicepLanguageServer")
        ctx.fs:rmrf "vscode"

        ctx:link_bin(
            "bicep-lsp",
            ctx:write_shell_exec_wrapper(
                "bicep-lsp",
                ("dotnet %q"):format(path.concat {
                    ctx.package:get_install_path(),
                    "bicepLanguageServer",
                    "Bicep.LangServer.dll",
                })
            )
        )
    end,
}