You are not logged in.

#1 2006-01-06 21:55:53

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

python omnifunc, coming to a vim-snapshot near you

More info here: http://phraktured.net/blog/2006/01/04/vim-python/

For those of you who don't know what omni completion is, it's a vim-devel thing (in [unstable]) that looks like this:
screenshot200512270240442fo.th.png

See the popup there listing arg, node, string, and type?

Here's it in python (with a slightly more-fugly popup color):
pycomplete7rk.th.png

Offline

#2 2006-01-06 22:14:46

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: python omnifunc, coming to a vim-snapshot near you

Oh man, that's well sweeeeet!

Offline

#3 2006-01-06 22:22:04

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: python omnifunc, coming to a vim-snapshot near you

I just uploaded v0.2 of the omnifunc - now it should work for everything except local variables inside classes and "self.X" variables set inside classes.  The local class parsing is the most complicated chunk, so that will take some time to muck with.

Test it out, let me know what's going on.

PS omnifuncs are still missing for most languages
C requires a ctags patch
C++ requires icomplete
html/css are provided in the distribution

Now here's python.
Ruby should be just as easy, and I may look into that as well, assuming ruby can lex itself.... can it?

Offline

#4 2006-01-06 22:25:50

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: python omnifunc, coming to a vim-snapshot near you

woooooooooow.... real code completion in vim? Like honest to god..... and it works python.....ooooooooooooooohk, I'm tempted to try vim again. wow!

Dusty

Offline

#5 2006-01-06 22:33:07

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: python omnifunc, coming to a vim-snapshot near you

Dusty wrote:

woooooooooow.... real code completion in vim? Like honest to god..... and it works python.....ooooooooooooooohk, I'm tempted to try vim again. wow!

Heh, it "works" in python... as I said, there's still some errors to iron out - such as being unable to complete local variables inside class definitions because I trash function bodies... and a few other things.  At some point, I'd like to add signature completion too, but that would require inspect, and doesn't work on builtins, I don't think.

For the record, it's C-x,C-o (C-x is the universal "completion" prefix... C-x,C-f completes file names, etc etc) - C-o is for "omni".

Right now this is pretty functional - but feel free to bug report whatever you want.

Offline

#6 2006-01-07 11:58:30

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

Re: python omnifunc, coming to a vim-snapshot near you

Man, what would vim users around the globe do without you phrak? Seriously, that's awesome engineering big_smile


.oO Komodo Dave Oo.

Offline

#7 2006-01-09 04:47:30

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: python omnifunc, coming to a vim-snapshot near you

If anyone has tried this, please let me know what is lacking and what you'd like to see.

On a side note, I'm looking for a way to get the signature of a python function like so:

foo = sys.exc_info
function_sig(foo)
#prints "()"

Offline

#8 2006-01-09 07:20:24

postlogic
Member
Registered: 2005-02-24
Posts: 410
Website

Re: python omnifunc, coming to a vim-snapshot near you

Oooh, that's nice.

btw, what colorscheme are you using for the top one? It's purdy...

Offline

#9 2006-01-09 16:15:46

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: python omnifunc, coming to a vim-snapshot near you

The top scheme is just 'desert', but the terminal colors come from rezza (see the Desktop forum, for the terminal colorscheme thread I started)

Offline

#10 2006-01-10 05:03:21

deficite
Member
From: Augusta, GA
Registered: 2005-06-02
Posts: 693

Re: python omnifunc, coming to a vim-snapshot near you

w00tlicious. I'm going to give you a pizza.

Offline

#11 2006-01-24 01:29:44

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: python omnifunc, coming to a vim-snapshot near you

Updates galore! Now it's secure and completes arguments - give it a whirl if ya want.

http://phraktured.net/blog/2006/01/23/pycomplete-03/

Offline

#12 2006-01-24 02:11:34

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: python omnifunc, coming to a vim-snapshot near you

Phrakture is very wise.

Offline

#13 2006-01-24 16:43:18

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: python omnifunc, coming to a vim-snapshot near you

Please, if you have a chance, try this and bug report the crap out of it.

Testing steps:
Install vim-devel from [unstable]
Download pycomplete.vim - either put it in ~/.vim/autoload, or /usr/share/vim/autoload.

Upon opening a python file, type :set ofu=pycomplete#Complete
[ Optionally, something like "au BufRead,BufNewFile *.py set ofu=pycomplete#Complete" in ~/.vimrc would work ]

Also, you can change popup colors like so:

    hi Pmenu ctermfg=0 ctermbg=7
    hi PmenuSel ctermfg=7 ctermbg=4
    hi PmenuSbar ctermfg=0 ctermbg=4
    hi PmenuThumb gui=reverse

Then just use C-x,C-o for the popup menu.  Let me know if you get any errors or just funky workings.  I'd like to iron most of this out soon, so I can start adding __doc__ previews.

Offline

#14 2006-01-25 00:05:36

awalk
Member
From: Perth, Western Australia
Registered: 2005-02-14
Posts: 40

Re: python omnifunc, coming to a vim-snapshot near you

phrakture wrote:

If anyone has tried this, please let me know what is lacking and what you'd like to see.

On a side note, I'm looking for a way to get the signature of a python function like so:

foo = sys.exc_info
function_sig(foo)
#prints "()"

Did you ever get this? I just saw the post... I believe you can use the "co_argcount" and "co_varnames" members of a code object to do it. i.e. the first co_argcount elements of co_varnames.

Looks like a rather nice tool. Too bad I don't do more Python programming.

Offline

#15 2006-01-25 05:18:39

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: python omnifunc, coming to a vim-snapshot near you

awalk wrote:

Did you ever get this? I just saw the post... I believe you can use the "co_argcount" and "co_varnames" members of a code object to do it. i.e. the first co_argcount elements of co_varnames.

Looks like a rather nice tool. Too bad I don't do more Python programming.

Yup, I ganked the code from IDLE's calltips section.  Odd part is that co_varnames and company don't work on C based python modules (i.e. half the standard library), however most of those contain the signature in the doc string, so I parse that as well

Offline

#16 2006-01-26 01:52:36

codemac
Member
From: Cliche Tech Place
Registered: 2005-05-13
Posts: 776
Website

Re: python omnifunc, coming to a vim-snapshot near you

So if pressing Ctrl-x Ctrl-o does omni completion... what is Ctrl-n doing?  It pops up a window as well...

Offline

#17 2006-01-26 19:24:31

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: python omnifunc, coming to a vim-snapshot near you

codemac wrote:

So if pressing Ctrl-x Ctrl-o does omni completion... what is Ctrl-n doing?  It pops up a window as well...

Ctrl-n and Ctrl-p are not completion mechanisms in and of themselves.  They simply repeat the last completion type given.  For instance, if you do "/usr/bi<C-x,C-f>" and then use <C-p> you will get file completion again.

Also, the popup menu is not unique to omni-completion, it can be used for everything:

                                                *'completeopt'* *'cot'*
'completeopt' 'cot'     string  (default: "menu")
                        global
                        {not in Vi}
        Options for Insert mode completion |ins-completion|.
        Currently the only supported value is:

           menu     Use a popup menu to show the possible completions.  The
                    menu is only shown when there is more than one match and
                    sufficient colors are available.  |ins-completion-menu|

Offline

#18 2006-01-31 16:38:23

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: python omnifunc, coming to a vim-snapshot near you

vegetaz wrote:

Is that a console terminal, xterm, etc? I mean there is no need for gvim?

Popup completion works in both console and gui modes.

Offline

Board footer

Powered by FluxBB