aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/rust_analyzer/common.mjs
blob: 0f54a71ec7788d77c07bd400a170dbf2959f284c (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
export const VERSION = "2021-06-28";

const exitNotSupported = () => {
    console.error(chalk.red(`${os.platform()} ${os.arch()} is currently not supported.`));
    process.exit(1);
};

export const getDownloadUrl = () => {
    const target = (() => {
        switch (os.platform()) {
            case "win32": {
                switch (os.arch()) {
                    case "arm64":
                        return "rust-analyzer-aarch64-pc-windows-msvc.gz";
                    case "x64":
                        return "rust-analyzer-x86_64-pc-windows-msvc.gz";
                    default:
                        return exitNotSupported();
                }
            }
            case "darwin":
                switch (os.arch()) {
                    case "arm64":
                        return "rust-analyzer-aarch64-apple-darwin.gz";
                    case "x64":
                        return "rust-analyzer-x86_64-apple-darwin.gz";
                    default:
                        return exitNotSupported();
                }
            default:
                switch (os.arch()) {
                    case "arm64":
                        return "rust-analyzer-aarch64-unknown-linux-gnu.gz";
                    default:
                        return "rust-analyzer-x86_64-unknown-linux-gnu.gz";
                }
        }
    })();

    return `https://github.com/rust-analyzer/rust-analyzer/releases/download/${VERSION}/${target}`;
};