haochengxia / vscode-pydata-viewer

Display PyData files (.npz .npy .pkl .pth) in VSCode.
https://marketplace.visualstudio.com/items?itemName=Percy.vscode-pydata-viewer
MIT License
14 stars 8 forks source link

[Proposal / Feature request] Support ${workspaceFolder} (and some reference variable) for pythonPath and scriptPath config #21

Closed Take-Me1010 closed 1 week ago

Take-Me1010 commented 5 months ago

Thank you for your great extention.

The config for pythonPath and scriptPath is only supported absolute-path style, right? It would be good if I can use "${workspaceWolder}" for path config as follows:

{
    "vscode-pydata-viewer.scriptPath": "${workspaceFolder}/read_files.py",
}

With respect to scriptPath config, I think inserting some codes to replace variable around line 139 in pydataPreview.ts resolves my concern:

const workspace = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(resourcePath));
scriptPath = scriptPath.replace('${workspaceFolder}', workspace.uri.fsPath);    // note  `scriptPath` is a const variable, so there is a need to write more beautiful code...

PS: This may relate #3 . In addition, this feature can resolve some problems like #19 more easily.

haochengxia commented 5 months ago

Thanks for your proposal! The feat is added in the latest commit. Please feel free to provide more details and suggestions if you have any further concerns.

Take-Me1010 commented 5 months ago

Thank you for your quick reply and coding!

It seems perfect at a glance. However, one concern remains. If this feature for scriptPath is released, users may think ${workspaceFolder} can also be used for pythonPath, which may cause confusion. So supporting ${workspaceFolder} for pythonPath is also crucial, I believe. These features will bring comfortable experience in a python virtual environment as follows:

{
    "vscode-pydata-viewer.scriptPath": "${workspaceFolder}/read_files.py",
    "vscode-pydata-viewer.pythonPath": "${workspaceFolder}/.venv/Scripts/python.exe",
}
haochengxia commented 5 months ago

Thank you for your comment. I sincerely appreciate it. I will revise the code soon before the next version update.