diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/julials.lua | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/lua/lspconfig/julials.lua b/lua/lspconfig/julials.lua index bdf92b3a..e92d17c6 100644 --- a/lua/lspconfig/julials.lua +++ b/lua/lspconfig/julials.lua @@ -7,16 +7,31 @@ local cmd = { '--history-file=no', '-e', [[ - using Pkg; + using Pkg Pkg.instantiate() - using LanguageServer; using SymbolServer; + using LanguageServer depot_path = get(ENV, "JULIA_DEPOT_PATH", "") - project_path = dirname(something(Base.current_project(pwd()), Base.load_path_expand(LOAD_PATH[2]))) - # Make sure that we only load packages from this environment specifically. - @info "Running language server" env=Base.load_path()[1] pwd() project_path depot_path - server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path); - server.runlinter = true; - run(server); + project_path = let + dirname(something( + ## 1. Finds an explicitly set project (JULIA_PROJECT) + Base.load_path_expand(( + p = get(ENV, "JULIA_PROJECT", nothing); + p === nothing ? nothing : isempty(p) ? nothing : p + )), + ## 2. Look for a Project.toml file in the current working directory, + ## or parent directories, with $HOME as an upper boundary + Base.current_project(), + ## 3. First entry in the load path + get(Base.load_path(), 1, nothing), + ## 4. Fallback to default global environment, + ## this is more or less unreachable + Base.load_path_expand("@v#.#"), + )) + end + @info "Running language server" VERSION pwd() project_path depot_path + server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path) + server.runlinter = true + run(server) ]], } @@ -57,16 +72,31 @@ require'lspconfig'.julials.setup{ "--startup-file=no", "--history-file=no", "-e", [[ - using Pkg; + using Pkg Pkg.instantiate() - using LanguageServer; using SymbolServer; + using LanguageServer depot_path = get(ENV, "JULIA_DEPOT_PATH", "") - project_path = dirname(something(Base.current_project(pwd()), Base.load_path_expand(LOAD_PATH[2]))) - # Make sure that we only load packages from this environment specifically. - @info "Running language server" env=Base.load_path()[1] pwd() project_path depot_path - server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path); - server.runlinter = true; - run(server); + project_path = let + dirname(something( + ## 1. Finds an explicitly set project (JULIA_PROJECT) + Base.load_path_expand(( + p = get(ENV, "JULIA_PROJECT", nothing); + p === nothing ? nothing : isempty(p) ? nothing : p + )), + ## 2. Look for a Project.toml file in the current working directory, + ## or parent directories, with $HOME as an upper boundary + Base.current_project(), + ## 3. First entry in the load path + get(Base.load_path(), 1, nothing), + ## 4. Fallback to default global environment, + ## this is more or less unreachable + Base.load_path_expand("@v#.#"), + )) + end + @info "Running language server" VERSION pwd() project_path depot_path + server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path) + server.runlinter = true + run(server) \]\] }; new_config.cmd = cmd |
