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

Support ${workspaceFolder} Within Custom Sandbox Template #1222

Closed
han-tyumi opened this issue Sep 24, 2023 · 2 comments
Closed

Support ${workspaceFolder} Within Custom Sandbox Template #1222

han-tyumi opened this issue Sep 24, 2023 · 2 comments

Comments

@han-tyumi
Copy link

han-tyumi commented Sep 24, 2023

I use Nix to manage my OCaml projects.
I've looked at how to use this extension with direnv/nix?, but unfortunately this does not work for me because the template is run at the root of my system.

It would be nice if template supported ${workspaceFolder} so that we may specify that as the directory to look for a Nix shell configuration.
Another option could be to make sure that this command is started in the workspace folder.

I've also noticed Haskell's IDE will automatically wait and pickup the environment once it's loaded rather than failing hard.
So that would maybe be an even cleaner option if something like that could also be implemented.
This way you could just use the global sandbox in this scenario which would be even simpler.

This is my current workaround:

{
  "ocaml.sandbox": {
    "kind": "custom",
    "template": "nix develop \"${DIRENV_DIR#-}\" --command $prog $args"
  }
}

Ideally I could switch to one of the following based on the options I mentioned above.

{
 "ocaml.sandbox": {
   "kind": "custom",
   "template": "nix develop \"${workspaceFolder}\" --command $prog $args"
 }
}

With ${workspaceFolder} support.

{
  "ocaml.sandbox": {
    "kind": "custom",
    "template": "nix develop --command $prog $args"
  }
}

With the command definitely running in the workspace folder.

{
  "ocaml.sandbox": {
    "kind": "global"
  }
}

With the extension supporting some form of "waiting" for the expected environment to be loaded.

@mnxn
Copy link
Collaborator

mnxn commented Sep 24, 2023

We do not support the ${workspaceFolder} variable because workspaces may have multiple folders and sandbox configs can come from different places.

You can use either of the following instead:

  1. ${workspaceFolder:folderName}, which will select the folder based on its name. The syntax comes from VS Code's Variables scoped per workspace folder.

    (implemented in Allow using workspaceFolder placeholder variable for more portable sandbox configurations #424)

  2. ${firstWorkspaceFolder}, which will use the first folder in the workspace.

    (implemented in Add support for ${firstWorkspaceFolder} as a placeholder variable in configuration files #1004)

@han-tyumi
Copy link
Author

han-tyumi commented Sep 24, 2023

We do not support the ${workspaceFolder} variable because workspaces may have multiple folders and sandbox configs can come from different places.

You can use either of the following instead:

  1. ${workspaceFolder:folderName}, which will select the folder based on its name. The syntax comes from VS Code's Variables scoped per workspace folder.
    (implemented in Allow using workspaceFolder placeholder variable for more portable sandbox configurations #424)
  2. ${firstWorkspaceFolder}, which will use the first folder in the workspace.
    (implemented in Add support for ${firstWorkspaceFolder} as a placeholder variable in configuration files #1004)

Oh thanks for pointing that out 👍. Didn't see anything about those in the README / docs.
${firstWorkspaceFolder} works for me.

The other options may still be nicer in the future.

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

No branches or pull requests

2 participants