Skip to content

Commit

Permalink
fix(julia-lsp): adjust for changes in latest release (chipsalliance#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamboman authored Aug 13, 2022
1 parent 1371f1b commit cb7bdcd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
30 changes: 14 additions & 16 deletions lua/mason-core/installer/context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ function InstallContext:write_exec_wrapper(new_executable_rel_path, target_execu
)
end

local BASH_TEMPLATE = _.dedent [[
#!/bin/bash
%s
exec %s "$@"
]]

local BATCH_TEMPLATE = _.dedent [[
@ECHO off
%s
%s %%*
]]

---@param new_executable_rel_path string: Relative path to the executable file to create.
---@param command string: The shell command to run.
---@param env table<string, string>?
Expand All @@ -252,14 +264,7 @@ function InstallContext:write_shell_exec_wrapper(new_executable_rel_path, comman
return ("export %s=%q"):format(var, value)
end, _.to_pairs(env or {}))

self.fs:write_file(
new_executable_rel_path,
_.dedent(([[
#!/bin/bash
%s
exec %s "$@"
]]):format(_.join("\n", formatted_envs), command))
)
self.fs:write_file(new_executable_rel_path, BASH_TEMPLATE:format(_.join("\n", formatted_envs), command))
std.chmod("+x", { new_executable_rel_path })
return new_executable_rel_path
end,
Expand All @@ -270,14 +275,7 @@ function InstallContext:write_shell_exec_wrapper(new_executable_rel_path, comman
return ("SET %s=%s"):format(var, value)
end, _.to_pairs(env or {}))

self.fs:write_file(
executable_file,
_.dedent(([[
@ECHO off
%s
%s %%*
]]):format(_.join("\n", formatted_envs), command))
)
self.fs:write_file(executable_file, BATCH_TEMPLATE:format(_.join("\n", formatted_envs), command))
return executable_file
end,
}
Expand Down
33 changes: 30 additions & 3 deletions lua/mason-registry/julia-lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,33 @@ 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"
local platform = require "mason-core.platform"

local server_script = [[
if VERSION < v"1.0.0"
error("julia language server only works with julia 1.0.0+")
end
import Pkg
version_specific_env_path = joinpath(@__DIR__, "scripts", "environments", "languageserver", "v$(VERSION.major).$(VERSION.minor)")
if isdir(version_specific_env_path)
Pkg.activate(version_specific_env_path)
else
Pkg.activate(joinpath(@__DIR__, "scripts", "environments", "languageserver", "fallback"))
end
using LanguageServer, SymbolServer, Pkg
OLD_DEPOT_PATH = ARGS[1]
SYMBOLSTORE_PATH = ARGS[2]
ENV_PATH = ARGS[3]
ENV_PATH = ARGS[2]
runserver(
stdin,
stdout,
ENV_PATH,
OLD_DEPOT_PATH,
nothing,
SYMBOLSTORE_PATH
ENV["SYMBOLSTORE_PATH"]
)
]]

Expand Down Expand Up @@ -55,5 +67,20 @@ return Pkg.new {
ctx.fs:rmrf "vscode-package"

ctx.fs:write_file("nvim-lsp.jl", server_script)
ctx:link_bin(
"julia-lsp",
ctx:write_shell_exec_wrapper(
"julia-lsp",
("julia --startup-file=no --history-file=no --depwarn=no %q"):format(path.concat {
ctx.package:get_install_path(),
"nvim-lsp.jl",
}),
{
SYMBOLSTORE_PATH = path.concat { ctx.package:get_install_path(), "symbolstorev5" },
JULIA_DEPOT_PATH = path.concat { ctx.package:get_install_path(), "lsdepot" },
JULIA_LOAD_PATH = platform.is.win and ";" or ":",
}
)
)
end,
}

0 comments on commit cb7bdcd

Please sign in to comment.