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

How can an extension use path variables in a settings string that specifies a path? #5089

Closed
rkeithhill opened this issue Apr 8, 2016 · 5 comments
Assignees
Labels
verified Verification succeeded

Comments

@rkeithhill
Copy link

  • VSCode Version: 0.10.14-insider
  • OS Version: Windows 10 1511

Steps to Reproduce:

  1. Extension provides a setting which specifies a path to a tool configuration file that ships in the extension's install dir.
  2. We want to allow the user to override this path in either a user setting or a workspace setting.
  3. We would rather not require the user have to specify a hard-coded absolute path (C:\foo\bar...) when they override the setting at either the user level or the workspace level (.vscode\settings.json).
  4. So how does an extension handle this situation? Using a naked relative path e.g. ./ScriptAnalyzerSettings.psd1 would be confusing because the meaning of . would likely change depending on which setting file is in effect (global, user or workspace).
  5. I would prefer that our extension could ask VSCode to expand certain variables for us before sending the settings path to the extension (either during extension activation or when a user changes a settings file). I would like to see these variables available: ${workspaceRoot}, ${extensionRoot} and perhaps ${home}.
  6. The primary scenario I want to see enabled is having a setting value like "${workspaceRoot}\custom-settings.psd1" get translated to an absolute path by VSCode and that absolute path is then provided to the extension e.g. "C:\work\PowerShell\MyNewModule\custom-settings.psd1".

cc @daviwil

@alexdima
Copy link
Member

alexdima commented Apr 8, 2016

I think the configuration service could do this such that this knowledge doesn't leak through everywhere.

What do you think @bpasero @aeschli ?

@aeschli aeschli assigned bpasero and unassigned aeschli Apr 8, 2016
@bpasero
Copy link
Member

bpasero commented Apr 8, 2016

#2809

@bpasero bpasero closed this as completed Apr 8, 2016
@alexdima
Copy link
Member

alexdima commented Apr 8, 2016

@bpasero I don't think this is about environmental variables (which present a lot more challenges than VSCode built-in paths constants?)

@rkeithhill
Copy link
Author

The environment variable approach could work but wouldn't be ideal. I see that our extension's language host exe inherits the following env vars from VSCode:

vscode_envvars

Now, if VSCode also defined VSCODE_WORKSPACEROOT and VSCODE_EXTENSIONROOT we could make this work. However we would have a user education/usability issue. In some cases (ie launch.json) we tell users to use ${workspaceRoot} to specify a path to a file in their workspace. But in settings.json we tell them that to specify a path to a "settings" file in their workspace they have to use %VSCODE_WORKSPACEROOT%. Seems a bit inconsistent.

@bpasero
Copy link
Member

bpasero commented Apr 29, 2016

#2809 covers also variables we introduce.

@bpasero bpasero added the verified Verification succeeded label Apr 29, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants