John
John

Reputation: 540

Autocomplete blender script using jedi-vim

I recently added jedi-vim to my plug-in arsenal. It works just fine for the standard modules, but is unable to find bpy and bmesh stuff.

So in the blender console I took the output of print(sys.path) and added it to a vimscript function in a .lvimrc file, like this:

function BpyPath()
    python sys.path.append('/home/john/src/blender-2.77-linux-glibcl211-x86_64/2.77/python/lib/python3.5')
    ...
endfunction

Now it works better. Typing bpy. gives me:

enter image description here

But typing bpy.context. still gives me: -- Omni completion (^O^N^P) Pattern not found

Versions:

I am not a very advanced python or vim user, so any help is appreciated.

Upvotes: 1

Views: 768

Answers (3)

Ray Zee
Ray Zee

Reputation: 1

Blender Python Text Editor, IDE there is this new tool Bacutor, has intellisense, syntax Highlight and more

http://bacutor.freeiz.com

Upvotes: -1

sambler
sambler

Reputation: 7079

This often catches people out. Blender's bpy module is a compiled module created from source code within blender. The binary for the module is merged into blender's binary and is not made available outside of the python interpreter within blender.

It is possible to compile blender yourself and enable an option to build blender as a python module that you can import into any python interpreter, and will probably be the solution you are looking for.

In this answer you can also find some links to other answers that have tips for using eclipse and pycharm with blender that may be of some help.

Upvotes: 2

Dave Halter
Dave Halter

Reputation: 16325

I just realized that there's not a lot of hope, because you're already talking to a compiled (C/C++) module.

If dir(bpy.context) (in a Python shell) doesn't give you the completions that you want, Jedi will also not be able to infer this information. If dir gives you something reasonable, just create an issue in the Jedi issue tracker. It would be a bug, IMO.

I'm planning a plugin system for Jedi, to make it possible to use Jedi with such use cases as well. But this will probably take two years.

Upvotes: 2

Related Questions