richterger / Perl-LanguageServer

Language Server for Perl
Other
225 stars 52 forks source link

Support ${workspaceFolder} for perlCmd #25

Open jfg118 opened 4 years ago

jfg118 commented 4 years ago

It would be helpful to be able to use the ${workspaceFolder} variable in the perlCmd.

This would allow easier sharing of workspaces across different sites and users where absolute paths may change, but could be made relative to the workspaceFolder path.

Unfortunately VSCode currently does not support automatic variable expansion for the settings so the extension must specifically handle the expansion.

A possible expansion routine :

function expandCmdPath(path: string, resource: Uri): string {
        if (path.includes("${workspaceFolder}")) {
            const ws =
                workspace.getWorkspaceFolder(resource) ?? workspace.workspaceFolders?.[0];
            const sub = ws?.uri.fsPath ?? "";
            return path.replace("${workspaceFolder}", sub);
        }
        return path;
    }
afgit commented 1 year ago

Apparently the PR has been merged and included with 2.4.0 release, but it still does not work for me. ${workspaceFolder} is not replaced by the workspace folder in perlInc, the error message still is:

Can't locate xxx.pm in @INC (you may need to install the xxx module) (@INC contains: ${workspaceFolder}/yyy ...) at - line 7.

dseynhae commented 1 year ago

Confirming: same problem for me.