JacquesLucke / blender_vscode

Visual Studio Code extension for Blender development.
MIT License
540 stars 70 forks source link

Allow usage of custom defined addon folders #120

Closed Griperis closed 2 years ago

Griperis commented 2 years ago

If you want to have multiple addons in one repository or in some subfolder structure it is necessary to edit the workspace config and setup a "workspace folder" for each addon. This works super good until you work with monorepo or big crosslinked projects.

Why: We use monorepo structure, where the addons lie in one repository, we cross-reference some stuff. If the workspace folders are setup in VScode, then VSCode treats them individually as roots and some python features like auto-complete or linting are broken. This doesn't happen if there is only one root workspace folder.

How: New option in extension settings: "blender.addonFolders" - array of paths to addon folders, all of those folders are treated like workspace folders if provided, if not provided the extension uses workspace folders as before.

"blender.addonFolders": [
     "C:/Users/USER/repo/addon1",
     "C:/Users/USER/repo/addon2",
     "C:/Users/USER/repo/addon3",
     "C:/Users/USER/other_repo/anothersupercooladdon",
     "addons/addon1",
     "addons/addonXYZ"
]

Both absolute and relative paths are supported.

This way all of the addons in settings get installed if user specifies in VScode settings to do so.

Griperis commented 2 years ago

Thanks for the review.

I see that it makes sense to check all the workspace folders from the point of how VSCode works, but I don't know whether there is use case for that? Maybe if you want to find multiple addons that are in different workspaces under the same path structure? I am not sure, but I am worried that afterwards duplicate addon entries would have to be handled and there can be other stuff. I can be more explicit about what the addonFolders option does in the settings description.

I wondered about keeping the folder concept separated from the workspace, so there isn't any "mockup" stuff but I didn't want to make more significant design changes that may broke something. I am going to add some comments about the code now and perhaps I can handle it in some future larger MR.

JacquesLucke commented 2 years ago

Only got some minor comments now.

I see that it makes sense to check all the workspace folders from the point of how VSCode works, but I don't know whether there is use case for that?

Well, it does not seem entirely unreasonable that someone might work with more than one monorepo each of which contains multiple addons. But yeah, it's fine if that is not supported for now.