VSCode autocompletion on addons deeper inside Workspace subfolders?

I can make VSCode and Jacques Lucke’s Blender Development extension work quite well, but autocompletion and imports resolution only seem to work if I set my addons’ folders directly as such in the Workspace.

I’d very much rather add my addon repositories’ folders instead, as that lets me work on additional stuff like markdown documentation and additional files in a centralized manner. Alas, the moment the addon folder isn’t the root of its Workspace folder but a subfolder inside, I lose autocompletion and other features.

I can have autocreation of junctions if i enter the path to the subfolder in the extension’s settings at their folder level, but nothing else.

Is there any setting I can use to regain those features?

(And, at that, is there any documentation where each and every setting for Jacques Lucke’s extension is thoroughly explained? Specially for a novice? For such an essential tool, one finds the lack of direct Blender Foundation support inexplicable, given that it is the go-to IDE for beginners)

1 Like

I use vscode a lot for addons, but not the Blender Development extension.

As far as import resolutions go, there’s one setting that determines what shows up:

python.analysis.extraPaths

In your settings.json, add the root path of each module or package.

    "python.analysis.extraPaths": [
        "path/to/addon1",
        "path/to/addon1/third_party/module"
    ],

If the addon is a module, that is, a single file addon, then the containing folder is the root.
If the addon is a package with __init__.py, then the root is one level up so that the package directory is what the analyzer sees.

Note: If your workspace folder has a .vscode folder and a settings.json inside it, vscode will prioritize whatever setting is in there, and ignore your global user settings.

There are two additional settings:

"python.autoComplete.extraPaths": []
"python.analysis.include": []

… which may or may not help adding the paths to.

Apart from this, there isn’t much else to make import completions work.

If you work with multiple git-repositories and need scm integration to work in a single workspace, you can use File > Add Folder to Workspace for that.

1 Like

Thank you! I’ll give it a try :slightly_smiling_face:

This is peculiar: I was doing tests with new Workspaces, and I’m finding that, on a new Workspace with no Blender Extension settings’ adjustments yet, everything seems to work as I wanted.

I’ve got to check if the problem is out of some interaction with the Extension (which I’d hate to lose, as it offers so many conveniences). I’ll report what I find.

EDIT: everything seems to be fine, including the extension’s basic functionality (automatically creating junctions in Blender’s addon folder to have the addons in development be present to the app, having Blender refresh its addons whenever one saves changes to the scripts…).

I don’t get it :sweat_smile:

It seems to have to do with what Python one is using. If it is the plain standard install in AppData (Windows) with the extension having installed Blender’s modules in there (accidentally on my part, possibly), VSC defaulting to it at the user settings level seems to make everything work. The moment one chooses a Venv at the Workspace level, things start to go awry (not fully, as in it seems to get that bpy is there but some secondary modules start not being resolved).

I’ll have to dig further into this.

This is a late addition but…

The reason I was having all those problems is that I was doing it wrong: instead of installing fake-bpy-module-latest in the Venv, I was installing just plain bpi. The moment I installed fake-bpy in the Venv everything became fully functional and flexible, with no limitations regarding folder hierarchies in the Workspace.