aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/julials/init.lua
blob: 714bce1bd4c49fd6a7a1b3ce87d3533e8ebcdffb (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
63
64
65
66
67
68
69
70
71
72
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
local std = require "nvim-lsp-installer.core.managers.std"
local github = require "nvim-lsp-installer.core.managers.github"

return function(name, root_dir)
    local server_script = [[
using LanguageServer, SymbolServer

maybe_dirname = x -> x !== nothing ? dirname(x) : nothing

OLD_DEPOT_PATH = ARGS[1]
SYMBOLSTORE_PATH = ARGS[2]

runserver(stdin,
          stdout,
          something(maybe_dirname(Base.current_project(pwd())),
                    maybe_dirname(Base.load_path_expand("@v#.#"))),
          OLD_DEPOT_PATH,
          nothing,
          SYMBOLSTORE_PATH)
]]

    return server.Server:new {
        name = name,
        root_dir = root_dir,
        homepage = "https://github.com/julia-vscode/LanguageServer.jl",
        languages = { "julia" },
        ---@param ctx InstallContext
        installer = function(ctx)
            std.ensure_executable("julia", { help_url = "https://julialang.org/downloads/" })

            ctx.fs:mkdir "vscode-package"
            ctx:chdir("vscode-package", function()
                github.unzip_release_file({
                    repo = "julia-vscode/julia-vscode",
                    asset_file = function(version)
                        local version_number = version:gsub("^v", "")
                        return ("language-julia-%s.vsix"):format(version_number)
                    end,
                }).with_receipt()
            end)

            ctx.fs:rename(
                path.concat {
                    "vscode-package",
                    "extension",
                    "scripts",
                },
                "scripts"
            )
            ctx.fs:rmrf "vscode-package"

            ctx.fs:write_file("nvim-lsp.jl", server_script)
        end,
        default_options = {
            cmd = {
                "julia",
                "--startup-file=no",
                "--history-file=no",
                "--depwarn=no",
                ("--project=%s"):format(path.concat { root_dir, "scripts", "environments", "languageserver" }),
                path.concat { root_dir, "nvim-lsp.jl" },
                vim.env.JULIA_DEPOT_PATH or "",
                path.concat { root_dir, "symbolstorev5" },
            },
            cmd_env = {
                JULIA_DEPOT_PATH = path.concat { root_dir, "lsdepot" },
            },
        },
    }
end