Closed cyraid closed 4 months ago
Hmm I'm not really sure how this would look. The workspaceFolder:name
field is not a native-to-vscode variable so it won't do anything unless I implement support for it. (I did at support for just ${workspaceFolder}
but that only works in single-workspace configs since it just uses VSCode's workspace variable) In multi-root workspaces this presents two problems:
Could you maybe enter a path to the workspace you want phpstan-linted and save that in the (multi-root) workspace settings? That way it'll only lint a single workspace but will (I think) work.
Sure! I'd be fine for a setting to set the folder path to the one that'll be "stanned", that would be great.
You should be able to do that by setting rootDir
right? Or does that not work
Nope. It sets whatever I put in there relative to the first workspace. It should be relative to the directory of the workspace root if anything? Ultimately if you supported ${workspace folder:name} would be great too. :)
It should be relative to the directory of the workspace root What is the workspace root in the case of multiple workspaces? Do you mean a sort of shared root between the two of them? If I have the workspaces
/home/sander/js-projects/X
and/home/sander/php-projects/Y
open, what is the workspace root?
I'm not against supporting ${workspace folder:name}
, I'm just not really sure what its value would be and how it would work. In the case of a multi-root workspace it can essentially have two values right?
It's indeed correct that it sets whatever is in there relative to the first workspace if it's a relative path, because otherwise it's kind of hard to say "to what" it is relative. It should work with an absolute path though.
I definitely wanna stay away from absolute paths. If the rootDir could be fixed to be relative to the multi-root workspace folder I'm sure that would work too, then I could just put a relative path to the right folder.
In a .code-workspace
file, you can add multiple folders (or through the editor). It ends up looking like this:
{
"folders": [
{
"path": "path1"
},
{
"path": "path2"
},
{
"path": "path3"
}
],
}
And using ${workspaceFolder:path1} uses the folder for path1 in the folders. :)
As for more information on the topic, going here: https://code.visualstudio.com/docs/editor/variables-reference#_variables-scoped-per-workspace-folder
You can see that:
By appending the root folder's name to a variable (separated by a colon), it is possible to reach into sibling root folders of a workspace. Without the root folder name, the variable is scoped to the same folder where it is used.
For example, in a multi root workspace with folders Server and Client, a ${workspaceFolder:Client} refers to the path of the Client root.
There's also a little more located at: https://code.visualstudio.com/docs/editor/multi-root-workspaces
If you wanna know about the "folders" setting. Thanks for all the help.
If the rootDir could be fixed to be relative to the multi-root workspace folder I'm sure that would work too, then I could just put a relative path to the right folder. What would be the multi-root workspace folder in the case of the example I gave? I still don't really understand this concept.
And using ${workspaceFolder:path1} uses the folder for path1 in the folders. :) Ahhh I only just understood that you meant for
${workspace folder:name}
to actually have the name of a workspace after the colon instead of just the raw string name. Okay that makes more sense. Yeah that should be doable. I've attached a version of the extension that adds support for${workspaceFolder:name}
, can you test that? (I've attached it as a zip file because github doesn't allow attaching of.vsix
files, just rename it to that and drop it into your extensiosn panel)
Beautiful! Thanks man. <3
Hi there, I do appreciate the warning of multiple workspaces, but, it would be nice if we could configure the path and rootDir ourselves and use "${workspaceFolder:name}", and binPath would be "${workspaceFolder:name}/vendor/bin/phpstan" etc. But instead when I set rootDir, it shows "/home/user/some/folder/${workspaceFolder:name}" does not exist, and I'm also guessing binPath doesn't scan for the workspace folder either?