diff options
| author | Fredrik Ekre <ekrefredrik@gmail.com> | 2021-07-16 19:10:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-16 10:10:55 -0700 |
| commit | bcebfac7429cd8234960197dca8de1767f3ef5d3 (patch) | |
| tree | bac8c07a45b9c4e1f559ac3372bd5f697d0fbaf5 | |
| parent | [docgen] Update CONFIG.md (diff) | |
| download | nvim-lspconfig-bcebfac7429cd8234960197dca8de1767f3ef5d3.tar nvim-lspconfig-bcebfac7429cd8234960197dca8de1767f3ef5d3.tar.gz nvim-lspconfig-bcebfac7429cd8234960197dca8de1767f3ef5d3.tar.bz2 nvim-lspconfig-bcebfac7429cd8234960197dca8de1767f3ef5d3.tar.lz nvim-lspconfig-bcebfac7429cd8234960197dca8de1767f3ef5d3.tar.xz nvim-lspconfig-bcebfac7429cd8234960197dca8de1767f3ef5d3.tar.zst nvim-lspconfig-bcebfac7429cd8234960197dca8de1767f3ef5d3.zip | |
feat(julials): improve project detection and simplify launch (#1079)
* Simplify LanguageServer.jl launch command (https://github.com/julia-vscode/SymbolServer.jl/issues/54#issuecomment-643667218)
* respect JULIA_PROJECT and JULIA_LOAD_PATH
| -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 |
