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

Allow selection of Dune context #1449

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

jchavarri
Copy link
Contributor

@jchavarri jchavarri commented Apr 18, 2024

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 config ocaml.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 the default 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:

editor-melange-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.

@jchavarri
Copy link
Contributor Author

I talked to @andreypopp and he suggested to remove the duneContexts protocol command, and instead call dune describe contexts directly from the vscode extension. I applied these changes in 9d34868 and its companion commit ocaml/ocaml-lsp@9ada875.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Allow users to choose which Dune context to use
2 participants