I’m trying to create a shared C library that uses the gobject library as foundation. So my object inherits in GObject speak from GObject. GObject allows bindings to all different scripting languages such as Python via GObject introspection. Then from python one can import the library from the gi.repository.
import gi
gi.require_versions({'Edf': '0.0', 'GLib': '2.0'})
from gi.repository import Edf
Vim offers autocompletion via jedi-vim. This works out of the box for other libraries making use of the GObject introspections, such as GLib and GTK. I would like use pytest to run some unit tests of the libraries. I would like very much to edit my files using vim with autocompletion for my own library.
So if I import a library as Above, I do get autocompletion for GLib, but not for my Edf module.
I’ve tried to getting autocompletion to work via setting the GI_TYPELIB_PATH environmental variable to the directory containing my Edf.typelib file. Also I’ve created a debian package and intstalled the library to /usr/lib/x86_64-linux-gnu/
and the typelib to /usr/lib/x86_64-linux-gnu/girepository-1.0/
, both these methods are enough to get autocompletion in REPL’s such as bpython3, ipython3 and even the python REPL, however I’m unable to get completion using jedi-vim inside vim.
I would be very happy to see it working. Has anyone any tips to get it to work?
Best regards and thank you for your attention.
3
Answers
It's been a while since I posted this question, however, today I saw the light. What I noticed was, all libraries already installed on the system, had automatic completions out of the box. The problem was, I was working on a library that is currently only in my build directories. In order for a program to start I usually had to specify
The funny thing is, autocompletion with vim in program using my gobject library using gir-introspection relies on exactly the environment. Hence jedi-vim, you-complete-me also needs to know where the typelib and the library are located, hence specify/export those variables before opening vim.
So this question and answer is perhaps relevant for people who use vim with python and perhaps other languages for which GObject bindings exists.
I had a similar error because of a mismatch between the python version I intended to use and the one that was called.
Make sure jedi is using the intended version of python. E.g. add let g:jedi#force_py_version = 3 to your .vimrc
I think the problem is your vim version is too low,I suggest you update to vim 7.4 and make sure it has open the python function,If you want autocomplete function, I suggest you can try You complete Me,It is more powerful,it need Vim 7.3.584+,now the vim 7.4 is come out,it is easy to install, you can install in this ways,
If that is not the problem then try installing jedi-vim with pathogen, hope it works.