Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pythoncomplete in vim - hardcode factory function returns?

I'm using pythoncomplete omnicompletion in vim. It works great when I instantiate classes directly, eg

import numpy as np
x = np.ndarray(l)

then x attributes complete correctly.

But I work with numpy and matplotlib so usually use factory functions ie

x = np.zeros((2,2)) 
f = plt.figure()  
ax = f.add_subplot(111)

Is there any way I can hard code the return types of these common functions so I can complete on the returned object. (ie set up some mappings that matplotlib.pyplot.figure returns matplotlib.figure.Figure, np.zeros returns np.ndarray etc.?

like image 620
robince Avatar asked Oct 28 '09 12:10

robince


1 Answers

Try jedi-vim.

There's an open issue for the problem you're facing. I think there's a good chance that it will be fixed in 3-4 months time: https://github.com/davidhalter/jedi/issues/372.

Jedi is also the library used behind YouCompleteMe and almost every other decent autocompletion plugin for Python.

like image 173
Dave Halter Avatar answered Oct 04 '22 16:10

Dave Halter