I'm using universal-ctags to navigate among objects define in my projects and it works perfectly fines. However i'm struggling to find how to include python builtins objects and package dependencies into the scope of universal-ctags. On the top of it, i'm using poetry (not my choice), which locate dependencies elsewhere than in the directory of my project. (if my project is .
, the related python dependencies are ../../../.cache/pypoetry/....
)
Say otherwise, i would like that <C-]> on works on every case whenever i'm targetting custom python object, python builtin (join
, choice
, lru_cache
, etc...), dependencie object (Model
from Django, ViewSet
from DRF, etc...)
Is there any way to specifie to universal-ctags to fetch all of those additionnal references ?
Thanks !
I thought an option exists to add path to include additionnal to look at, but i did not found anything about that.
I'm using universal-ctags, vim and on Debian 11
You can stitch together a one-liner to do this for you.
As romainl commented, you can pass several paths to generate a single tags file from. And that's pretty much the answer. We can add some fluff, though.
The Python standard library modules will be found in
sys.path
, e.g./usr/lib/python3.9
on my Debian box. I assume this to change rarely (only when you upgrade your Python installation). It does not seem worthwhile to automate this.Poetry's virtualenv is more volatile, so the path should be found automatically. According to the information in this poetry issue, you can get the virtualenv's path (and some more output we don't care about) with
poetry show -v
.Putting it together with a little Bash glue, we get the following one-liner:
Or - shamelessly stealing the more concise way of getting the path from Gwildor's answer - this one-liner becomes even more awesome:
You may want to turn this into a shell script or function and append
"$@"
to pass additional options.