diff --git a/scripts/languageserver/pkgdir.jl b/scripts/languageserver/pkgdir.jl new file mode 100644 index 000000000..881134364 --- /dev/null +++ b/scripts/languageserver/pkgdir.jl @@ -0,0 +1,11 @@ +using Pkg + +c = Pkg.Types.Context() +pkglist = [u[1][string(:path)] for (p,u) in c.env.manifest if haskey(u[1], string(:path))] +if isdir(abspath(joinpath(c.env.manifest_file, "..", "..", ".."))) + println(joinpath(abspath(joinpath(c.env.manifest_file, "..", "..", "..")), "dev")) +elseif !isempty(pkglist) + println(dirname(pkglist[1])) +else + println(joinpath(homedir(), ".julia", "dev")) +end \ No newline at end of file diff --git a/src/packagepath.ts b/src/packagepath.ts index 75d044f0e..76a29b4aa 100644 --- a/src/packagepath.ts +++ b/src/packagepath.ts @@ -17,7 +17,9 @@ export async function getPkgPath() { if (juliaPackagePath == null) { let jlexepath = await juliaexepath.getJuliaExePath(); // TODO: there's got to be a better way to do this. - var res = await exec(`"${jlexepath}" --startup-file=no --history-file=no -e "(using Pkg;println(dirname([u[1][string(:path)] for (p,u) in Pkg.Types.Context().env.manifest if haskey(u[1], string(:path))][1])))"`); + let scriptpath = join(g_context.extensionPath, "scripts", "languageserver", "pkgdir.jl"); + // var res = await exec(`"${jlexepath}" --startup-file=no --history-file=no -e "(using Pkg;println(dirname([u[1][string(:path)] for (p,u) in Pkg.Types.Context().env.manifest if haskey(u[1], string(:path))][1])))"`); + var res = await exec(`"${jlexepath}" --startup-file=no --history-file=no ${scriptpath}`); juliaPackagePath = res.stdout.trim(); } return juliaPackagePath;