strycore / fakegir

fakegir: Bring autocompletion to your PyGObject code
GNU General Public License v3.0
89 stars 16 forks source link

Feature request: Scan additional paths for gir files #15

Open realh opened 7 years ago

realh commented 7 years ago

As well as the main libraries in /usr/share/gir-1.0, a number of packages install gir files in other directories, for example GEdit. They all seem to use the pattern /usr/share/*/gir-1.0, where is the package name, so it should be quite easy to scan for them, although I don't know what extra steps might be needed in case fakegir needs to use the corresponding typelib files in `/usr/lib/x86_64-linux-gnu//girepository-1.0/`.

Should I try to make a simple implementation and raise a PR?

strycore commented 7 years ago

A PR would be great! I'm not currently using Fakegir because I can't manage to get it working with vim but that's a feature I would welcome!

realh commented 7 years ago

OK, I've made the PR.

It certainly isn't straightforward getting this working in vim. I think I've managed it with youcompleteme, although I haven't tested it properly yet. I could write a wiki page about it if you like, but it would be good if I could have a better understanding of it first.

AFAICT fakegir.py creates a list of classes etc appearing at the top-level of each module but doesn't add the class members. Then build-jedi-cache.sh uses sith.py to add the members to the cache. Is that right?

kastixx commented 5 years ago

I guess this issue can be closed now because the PR is merged.

realh commented 5 years ago

I ran into a related problem: on OS X the prefix is /usr/local instead of /usr. Perhaps a better long-term solution would be to read it with pkg-config --variable=girdir gobject-introspection-1.0 and deal with special cases like GEdit by allowing a full path to be specified on the command line.

realh commented 5 years ago

It's not quite as simple as I thought when I posted the previous comment, because with homebrew all gobject-introspection's pkg-config variables are based on a prefix of /usr/local/Cellar/gobject-introspection/${version}/ and the girdir within that only contains files supplied with that package. The directory that contains all the other gir files (eg from gtk+3) is /usr/local/share/gir-1.0 and there doesn't seem to be a definitive way to detect that. As a workaround in a separate gir parser I'm writing, I use pkg-config as above, but just test whether it starts with /usr/local/ and if so use /usr/local/share/gir-1.0, otherwise use whatever pkg-config returned, which works for Linux (returning /usr/local/gir-1.0).