Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[julia]: Better configurability for LanguageServer.jl install location. #1153

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 19 additions & 6 deletions lua/lspconfig/julials.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ local cmd = {
'--history-file=no',
'-e',
[[
using Pkg
Pkg.instantiate()
# Load LanguageServer.jl: attempt to load from ~/.julia/environments/nvim-lspconfig
# with the regular load path as a fallback
ls_install_path = joinpath(
get(DEPOT_PATH, 1, joinpath(homedir(), ".julia")),
"environments", "nvim-lspconfig"
)
pushfirst!(LOAD_PATH, ls_install_path)
using LanguageServer
popfirst!(LOAD_PATH)
Comment on lines +10 to +18
Copy link
Contributor

@mjlbach mjlbach Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still need all of this if we are passing --project to the julia process? Is this preferable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not passing --project actually. It is a bit tricky, because that would interfere with the project discovery on the lines after. I think the only options are the PR as is, or to juggle with Base.ACTIVE_PROJECT[] instead in an equally "hacky" way.

Copy link
Contributor

@mjlbach mjlbach Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant to imply "why shouldn't we just pass --project?"

I think I understand now, Base.active_project() would then return the project.toml containing directory for LanguageServer.jl vs the one containing the project meant to be analyzed/passed to the LanguageServer.jl instance.

For now, this is good. I still think there's a little bit of duplication in functionality between our root detection in lspconfig and the project.toml detection for figuring out the appropriate julia environment.

depot_path = get(ENV, "JULIA_DEPOT_PATH", "")
project_path = let
dirname(something(
Expand Down Expand Up @@ -51,13 +57,20 @@ configs.julials = {
description = [[
https://github.com/julia-vscode/julia-vscode

`LanguageServer.jl` can be installed with `julia` and `Pkg`:
LanguageServer.jl can be installed with `julia` and `Pkg`:
```sh
julia -e 'using Pkg; Pkg.add("LanguageServer"); Pkg.add("SymbolServer")'
julia --project=~/.julia/environments/nvim-lspconfig -e 'using Pkg; Pkg.add("LanguageServer")'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Julia 1.7 and above this can be spelled

julia --project=@nvim-lspconfig -e 'using Pkg; Pkg.add("LanguageServer")'

but lets wait (at least) until that is released before recommending that.

```
This installs LanguageServer.jl into your global julia environment.
where `~/.julia/environments/nvim-lspconfig` is the location where
the default configuration expects LanguageServer.jl to be installed.

In order to have LanguageServer.jl pick up installed packages or dependencies in a Julia project, you must first instantiate the project:
To update an existing install, use the following command:
```sh
julia --project=~/.julia/environments/nvim-lspconfig -e 'using Pkg; Pkg.update()'
```

Note: In order to have LanguageServer.jl pick up installed packages or dependencies in a
Julia project, you must make sure that the project is instantiated:
```sh
julia --project=/path/to/my/project -e 'using Pkg; Pkg.instantiate()'
```
Expand Down