aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/omnisharp/init.lua
blob: f45df354f39abeae3798658fbb557aa5bf3ac85a (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
54
55
56
57
58
59
60
61
62
local server = require "nvim-lsp-installer.server"
local platform = require "nvim-lsp-installer.platform"
local path = require "nvim-lsp-installer.path"
local Data = require "nvim-lsp-installer.data"
local github = require "nvim-lsp-installer.core.managers.github"
local std = require "nvim-lsp-installer.core.managers.std"

local coalesce, when = Data.coalesce, Data.when

return function(name, root_dir)
    return server.Server:new {
        name = name,
        root_dir = root_dir,
        homepage = "https://github.com/OmniSharp/omnisharp-roslyn",
        languages = { "c#" },
        async = true,
        ---@param ctx InstallContext
        installer = function(ctx)
            std.ensure_executable("dotnet", { help_url = "https://dotnet.microsoft.com/download" })

            -- We write to the omnisharp directory for backwards compatibility reasons
            ctx.fs:mkdir "omnisharp"
            ctx:chdir("omnisharp", function()
                github.unzip_release_file({
                    repo = "OmniSharp/omnisharp-roslyn",
                    asset_file = coalesce(
                        when(
                            platform.is_mac,
                            coalesce(
                                when(platform.arch == "x64", "omnisharp-osx-x64-net6.0.zip"),
                                when(platform.arch == "arm64", "omnisharp-osx-arm64-net6.0.zip")
                            )
                        ),
                        when(
                            platform.is_linux,
                            coalesce(
                                when(platform.arch == "x64", "omnisharp-linux-x64-net6.0.zip"),
                                when(platform.arch == "arm64", "omnisharp-linux-arm64-net6.0.zip")
                            )
                        ),
                        when(
                            platform.is_win,
                            coalesce(
                                when(platform.arch == "x64", "omnisharp-win-x64-net6.0.zip"),
                                when(platform.arch == "arm64", "omnisharp-win-arm64-net6.0.zip")
                            )
                        )
                    ),
                }).with_receipt()
            end)
        end,
        default_options = {
            cmd = {
                "dotnet",
                path.concat { root_dir, "omnisharp", "OmniSharp.dll" },
                "--languageserver",
                "--hostPID",
                tostring(vim.fn.getpid()),
            },
        },
    }
end