diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/mason-core/installer/context.lua | 30 | ||||
| -rw-r--r-- | lua/mason-registry/julia-lsp/init.lua | 33 |
2 files changed, 44 insertions, 19 deletions
diff --git a/lua/mason-core/installer/context.lua b/lua/mason-core/installer/context.lua index 89226f94..b3801330 100644 --- a/lua/mason-core/installer/context.lua +++ b/lua/mason-core/installer/context.lua @@ -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>? @@ -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, @@ -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, } diff --git a/lua/mason-registry/julia-lsp/init.lua b/lua/mason-registry/julia-lsp/init.lua index 14318009..d3dacdfe 100644 --- a/lua/mason-registry/julia-lsp/init.lua +++ b/lua/mason-registry/julia-lsp/init.lua @@ -2,13 +2,25 @@ 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, @@ -16,7 +28,7 @@ runserver( ENV_PATH, OLD_DEPOT_PATH, nothing, - SYMBOLSTORE_PATH + ENV["SYMBOLSTORE_PATH"] ) ]] @@ -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, } |
