1

I am coming from statically types languages, but I will have to be using python for the next few years and I want to get my setup as smooth as possible.

Right now I am using vim-jedi, and deoplete-jedi for python autocompletion. It's a dynamic language, so static analysis is not as good as it is for static languages and I find myself having to google library docs often which is really REALLY annoying. For example...

from matplotlib import pyplot as plt

# jedi will complete the next lines subplot function
fig, ax = plt.subplots()

# on the instantiated class I get no autocompletion whatsoever, if I want to see the methods, I have to google docs
ax.set_title('...')

I want to be able to see the instantiated class methods without having to go outside of vim. The best would be...

  1. If I could get the method autocompletion to work
  2. If I could pull up the docs for that class (vim-jedi, will pull up docs on the subplot method, but then i'll have to chase down what it returns, etc which is probably harder than just googling so I need a faster way to get to it)

Does anyone know if there is a way to accomplish what I want, or do I just have to leave and google everything when I need to see methods?

2

I have had moderate success with pydoc.vim for documentation; it can be helpful to use a virtualenv/run setup.py develop, but you may still have to point it at the right python.

I’ve also had moderate success with tags (I use universal ctags and these hooks to keep them up to date). With tags, I can quickly jump to the source and read a docstring. Occasionally it sends me to my tests instead of the source, so I need to use g<C-]>.

I haven’t used it, but kite may work for you. They have a vim plugin as well.

  • +1 for ctags. Personally, I found vim-gutentags works great for me to keep the tags file updated. YMMV. – filbranden Aug 15 at 4:38
  • vim-jedi will find documentation like pydoc (unless pydoc does something super magical that I don't know) but it comes back to the problem that after that class is instantiated, no one know what it is. If it was known then autocompletion would work and I would be able to open the docs, but we just don't know what it is. Kite looks way to heavy handed for me. I am not familiar with ctags as I have never used them before. Can they infer instantiated classes as I mentioned? – deltaskelta Aug 15 at 4:41
  • @deltaskelta tags are about navigating the codebase, so with them you should be able to quickly jump to definitions and find docstrings on methods. It isnt perfect (usually fairly regex-based), but it works. IOW, it doesnt care about types of variables (unless they are type)—but it can find a method that you call given it’s name, which is really the point. I do prefer the git hooks only because it’s completely invisible to me, but i can run it manually if i need to (i have an alias set up for it). As filbranden says, YMMV. I agree that Kite seems heavy – D. Ben Knoble Aug 15 at 5:03
  • if it's regexing for methods I call, meaning methods that I already type, then it wont work for me. I want to deal with the situation where I don't know the method name and something helps me find it (..."is that matplotlib method called set_title or title kind of questions) – deltaskelta Aug 15 at 5:07
  • @deltaskelta fair enough—though I believe thats exactly the problem kite solves – D. Ben Knoble Aug 15 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.