Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1432.
Dependencies
This PR relies on features being added in ocamllsp and dune:
Description
The PR adds a new
select-dune-context
command that will show the list of available Dune contexts for the user to choose from. Once a selection is done, the setting will be stored in a new configocaml.dune.context
.Every time the value of the context changes, the LSP server will be killed and a new instance will be created, passing
--context
flag as param (this param is added in the PR referred above).Demo
In the demo below, we are switching between a context
melange
and thedefault
one. One can observe how all the features in the editor like go to definition, codelenses or PPXs will be shown from the perspective of the currently selected context:Future improvements
Right now, only a single instance of the LSP server is running, which means that for files that are not in the currently selected context, the editor will show the infamous
No config found for file foo.ml. Try calling 'dune build'
error. In the future, we can improve this by runnning as many LSP server instances as Dune contexts exist, so that the VSCode extension can inspect the result of each, and choose the data from the one that is not failing.