exceedsystem / vscode-macros

This extension gives the macro features to your vscode.
https://marketplace.visualstudio.com/items?itemName=EXCEEDSYSTEM.vscode-macros
MIT License
38 stars 2 forks source link

How do you specify the workspace folder as the location for the macro file? #13

Closed gregveres closed 2 years ago

gregveres commented 2 years ago

I would like to have the macro file be part of the project. Is there a way to specify the workspace folder as the location for the macro file?

I have tried {workspaceFolder} as pointed out in the VSCode docs, but I think the docs are talking about using the variable from the user's point of view, not from the extension writer's point of view.

I tried this and it doesn't work:

  "vscodemacros.macroFilePath": "${workspaceFolder}/.vscode/openTerminals.js",
exceedsystem commented 2 years ago

@gregveres

If you would like to use macros of workspace, you have to enter the path to your macro file in the Macro File Path of the Workspace settings.

image

The settings are stored in the *.code-workspace file.

image

Then you can run the workspace macro as follows.

image

Best regards,

gregveres commented 2 years ago

Thank you. My problem was that I was trying to use a relative path from the workspace, but I was saving the settings in the user portion of the settings. Apparently when saving as the user settings, the path is relative to somewhere else.

saving in the workspace settings I was able to use the ".vscode/macros" directory.

exceedsystem commented 2 years ago

@gregveres

Thank you for your reply.

I forgot to mention something important.

We are unable to use VSCode predefined variables such as ${workspaceFolder} for the macro file path in VSCode Macros extension because VSCode does not provide an API to expand predefined variables so far.

Please see issue #3 for details.

Best regards,

gregveres commented 2 years ago

No problem at all. Just defining the value as ".vscode/macros/macro-file.js" worked great. I am not sure I would need to expand those variables.

BTW, this is a great extension. I was able to quickly write a macro to open up three terminals and start nx serve X in each of those terminals to get my monorepo based application building with a single command. I love it!