Skip to content

Conversation

Mateusz-Grzelinski
Copy link
Collaborator

@Mateusz-Grzelinski Mateusz-Grzelinski commented Aug 17, 2025

Technical notes

  • added basic jest tests
  • that requered dev dependency update. my local setup has node 22.17.0.
    • bumped typescript 5.5.2 -> 5.9.2

General

It was idea that I had for a while.
Use the same completion that is available in blender console, but in VS code.

  • this is experimental feature under setting blender.autocompletion (by default disabled)
  • it will work only in simple cases - the same as if you wrote them directly in blender console

How to use

  1. Enable setting blender.autocompletion and restart extension
  2. Use Blender: Start command - blender must me running for completion to work
  3. In any python file write bpy.<trigger completion> (crtl+space in my case)

Pros:

  • should not break other completion methods like fake-bpy-module - in fact, all methods can be used together
  • this method can complete dynamic items like bpy.ops, bpy.data.object names
  • can resolve function arguments but ony best effort (extracted from docs)
  • can show docs for functions

Cons:

  • bpy import will be still marked as missing
  • type hints are ignored
  • variables (aliases) will not work
image image image

Limitations: fails to resolve aliases and does not use type hints
image

@Mateusz-Grzelinski Mateusz-Grzelinski changed the title Add Blender interanal completion for VS code Integrate Blender internal completion for VS code Aug 17, 2025
@Mateusz-Grzelinski Mateusz-Grzelinski changed the title Integrate Blender internal completion for VS code Integrate Blender internal completion to VS code Aug 17, 2025
@Mateusz-Grzelinski Mateusz-Grzelinski marked this pull request as ready for review August 17, 2025 17:43
@JacquesLucke
Copy link
Owner

Seems ok overall, some notes though:

  • Is it really worth the extra complexity if this stops working in non-trivial cases? Might be, for things like bpy.data.objects[" but the operator completions should work mostly work without this new addition, right?
  • What's the performance impact of this?
  • Are completion results properly deduplicated between different auto-completion methods?

@Mateusz-Grzelinski
Copy link
Collaborator Author

Mateusz-Grzelinski commented Aug 18, 2025

  • the bpy.ops is tricky because it registers new operators from add-ons. I am not sure how fake-bpy-module extracts those values
  • idk, but will check. That is also why I conveniently named this setting experimental 🤪
  • YY, no. I am not sure if it is possible. Will check.

The nice thing about this completion is that: it is ready to go without setup, it stays pretty accurate as Blender completion is actually simply deep inspection of runtime values.

So if you want blender completion to respect alias like D = bpy.data the engine needs to actually evaluate this expression and have variable D in locals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants