Skip to content

Commit 4fc0d87

Browse files
committed
full-analysis: Use versioned manifest and Pkg.resolve for
auto-instantiation When `auto_instantiate` is enabled and no manifest file exists, JETLS now creates a versioned manifest file (e.g., `Manifest-v1.12.toml`) before running `Pkg.resolve()` and `Pkg.instantiate()`.
1 parent ac74e96 commit 4fc0d87

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1818

1919
### Added
2020

21-
- JETLS now automatically runs `Pkg.instantiate()` for packages that have not
22-
been instantiated yet (e.g., freshly cloned repositories). This allows
23-
full analysis to work immediately upon opening such packages. Note that this
24-
will automatically create a `Manifest.toml` file when the package has not been
25-
instantiated yet. This behavior is controlled by the `full_analysis.auto_instantiate`
21+
- JETLS now automatically runs `Pkg.resolve()` and `Pkg.instantiate()` for
22+
packages that have not been instantiated yet (e.g., freshly cloned repositories).
23+
This allows full analysis to work immediately upon opening such packages.
24+
When no manifest file exists, JETLS first creates a
25+
[versioned manifest](https://pkgdocs.julialang.org/v1/toml-files/#Different-Manifests-for-Different-Julia-versions)
26+
(e.g., `Manifest-v1.12.toml`).
27+
This behavior is controlled by the `full_analysis.auto_instantiate`
2628
configuration option (default: `true`). Set it to `false` to disable.
2729
- When `full_analysis.auto_instantiate` is disabled, JETLS now checks if the
2830
environment is instantiated and warns the user if not.

docs/src/configuration.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ debounce = 2.0 # Wait 2 seconds after save before analyzing
6565
- **Type**: boolean
6666
- **Default**: `true`
6767

68-
When enabled, JETLS automatically runs `Pkg.instantiate()` for packages that have
69-
not been instantiated yet (e.g., freshly cloned repositories). This allows full
70-
analysis to work immediately upon opening such packages. Note that this will
71-
automatically create a `Manifest.toml` file when the package has not been
72-
instantiated yet.
68+
When enabled, JETLS automatically runs `Pkg.resolve()` and `Pkg.instantiate()` for
69+
packages that have not been instantiated yet (e.g., freshly cloned repositories).
70+
This allows full analysis to work immediately upon opening such packages.
71+
When no manifest file exists, JETLS first creates a
72+
[versioned manifest](https://pkgdocs.julialang.org/v1/toml-files/#Different-Manifests-for-Different-Julia-versions)
73+
(e.g., `Manifest-v1.12.toml`).
7374

7475
```toml
7576
[full_analysis]

src/analysis/full-analysis.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,14 @@ end
676676
function ensure_instantiated!(server::Server, env_path::String)
677677
if get_config(server.state.config_manager, :full_analysis, :auto_instantiate)
678678
try
679+
manifest_name = "Manifest-v$(VERSION.major).$(VERSION.minor).toml"
680+
manifest_path = joinpath(dirname(env_path), manifest_name)
681+
if !isfile(manifest_path)
682+
JETLS_DEV_MODE && @info "Touching versioned manifest file" env_path
683+
touch(manifest_path)
684+
end
685+
JETLS_DEV_MODE && @info "Resolving package environment" env_path
686+
Pkg.resolve()
679687
JETLS_DEV_MODE && @info "Instantiating package environment" env_path
680688
Pkg.instantiate()
681689
catch e

0 commit comments

Comments
 (0)