vscode-zig icon indicating copy to clipboard operation
vscode-zig copied to clipboard

Support substituting environment variables in path settings

Open polykernel opened this issue 2 years ago • 0 comments

Feature request

In certain situations, it is desirable to use environment variables in the zig.zls.path and zig.path settings. The motivating use case for this is a portable per-project zig+zls setup where the zig and zls path are parameterized by a prefix stored in some environment variable. Currently, it is possible to support this setup by creating a symlink in the workspace and use the ${workspaceFolder} variable which gets substituted by the extension, but it would be nice to avoid this layer of indirection.

Ideally, the expansion should be implemented in vscode itself^1 but progress on the this front seems to have stagnated. In the mean time, I propose implementing environment variable substitution as described in the Variables Reference in the extension similar to currently done for ${workspaceFolder}.

An example of the aforementioned setup using direnv and nix is

.vscode/settings.json

{
    "zig.zls.path": "${env:ZLS_PATH}",
    "zig.path": "${env:ZIG_PATH}"
}

.envrc

use flake .
export ZIG_PATH=$(which zig)
export ZLS_PATH=$(which zls)

polykernel avatar Nov 06 '23 00:11 polykernel