vim 7 python completion

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

vim 7 python completion

Andrea Spadaccini
Hello everybody,
I can't get the python omni-completion to work, can anybody help me?

Are there any special steps to make it work? Can you point me to a
tutorial?

Thanks in advance,

--
[ Andrea Spadaccini - a.k.a. Lupino - from Catania - ICQ #: 91528290 ]
[ GPG ID: 5D41ABF0 - key on keyservers - Gentoo GNU / Linux - 2.6.18 ]
[ Linux Registered User 313388 - @: a.spadaccini(at)catania.linux.it ]
[      Make everything as simple as possible, but not simpler.       ]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: vim 7 python completion

Karl Guertin
On 12/12/06, Andrea Spadaccini <[hidden email]> wrote:
> Hello everybody,
> I can't get the python omni-completion to work, can anybody help me?
>
> Are there any special steps to make it work? Can you point me to a
> tutorial?

To cover the basics, is your vim compiled with +python?

vim --version | grep "+python"
Reply | Threaded
Open this post in threaded view
|

Re: vim 7 python completion

Andrea Spadaccini
Ciao Karl,

> > Hello everybody,
> > I can't get the python omni-completion to work, can anybody help me?
> >
> > Are there any special steps to make it work? Can you point me to a
> > tutorial?
>
> To cover the basics, is your vim compiled with +python?
>
> vim --version | grep "+python"

Yes, it is. Maybe my question was a bit too unspecified. :)

Well, if I do

import os
os.<C-X><C-O>

It shows correctly all the members of os. But if I do

        self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.win.<C-X><C-O>

It doesn't show anything.
Is it meant to work in this way?

Note that gtk.<C-X><C-O> does work, even if it shows some python
warnings about gtk.TRUE.

TIA,


--
[ Andrea Spadaccini - a.k.a. Lupino - from Catania - ICQ #: 91528290 ]
[ GPG ID: 5D41ABF0 - key on keyservers - Gentoo GNU / Linux - 2.6.18 ]
[ Linux Registered User 313388 - @: a.spadaccini(at)catania.linux.it ]
[                     If it works, don't fix it.                     ]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: vim 7 python completion

Aaron Griffin
On 12/13/06, Andrea Spadaccini <[hidden email]> wrote:
> It shows correctly all the members of os. But if I do
>
>         self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)
>         self.win.<C-X><C-O>
>
> It doesn't show anything.
> Is it meant to work in this way?

I would recommend upgrading to the latest version from www.vim.org
(here: http://vim.sourceforge.net/scripts/script.php?script_id=1542 )

The following code works fine:
import gtk

class Foo(object):
    def __init__(self):
        self.win = gtk.Window()
        self.win.<C-x,C-o>


Please note: if you have syntax errors above the code you are working
with the current code may not complete correctly, due to the top-down
nature of python structure.  I have tried to deal with this as
gracefully as possible, but there are cases where it still happens.
Reply | Threaded
Open this post in threaded view
|

Re: vim 7 python completion

Andrea Spadaccini
Ciao Aaron,

> I would recommend upgrading to the latest version from www.vim.org
> (here: http://vim.sourceforge.net/scripts/script.php?script_id=1542 )
>
> The following code works fine:
> import gtk
>
> class Foo(object):
>     def __init__(self):
>         self.win = gtk.Window()
>         self.win.<C-x,C-o>
>
>
> Please note: if you have syntax errors above the code you are working
> with the current code may not complete correctly, due to the top-down
> nature of python structure.  I have tried to deal with this as
> gracefully as possible, but there are cases where it still happens.
Thanks a lot, now it works, except for warnings from python:

Errore/i eseguendo function pythoncomplete#Complete:
linea   35:
__main__:157: GtkDeprecationWarning: gtk.FALSE is deprecated, use False
instead
Errore/i eseguendo function pythoncomplete#Complete:
linea   35:
__main__:157: GtkDeprecationWarning: gtk.TRUE is deprecated, use True
instead

Now the code you posted works. :)
Another small question: how can I see the parameters for the current
method? Say that I do

win = gtk.Window(

and I want to know the possible constructors of gtk.Window.. How can I
do that?

Thanks again for the good work. :)

--
[ Andrea Spadaccini - a.k.a. Lupino - from Catania - ICQ #: 91528290 ]
[ GPG ID: 5D41ABF0 - key on keyservers - Gentoo GNU / Linux - 2.6.18 ]
[ Linux Registered User 313388 - @: a.spadaccini(at)catania.linux.it ]
[         This is as bad as it can get, but don't bet on it.         ]

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: vim 7 python completion

Aaron Griffin
On 12/13/06, Andrea Spadaccini <[hidden email]> wrote:

> Thanks a lot, now it works, except for warnings from python:
>
> Errore/i eseguendo function pythoncomplete#Complete:
> linea   35:
> __main__:157: GtkDeprecationWarning: gtk.FALSE is deprecated, use False
> instead
> Errore/i eseguendo function pythoncomplete#Complete:
> linea   35:
> __main__:157: GtkDeprecationWarning: gtk.TRUE is deprecated, use True
> instead

Yeah that one is known, but it's cosmetic really, it doesn't hurt
anything.  I will get rid of that next release.

> Another small question: how can I see the parameters for the current
> method? Say that I do
>
> win = gtk.Window(
>
> and I want to know the possible constructors of gtk.Window.. How can I
> do that?

That mostly works, *except* for the instance you mention
(constructors).  I haven't yet made the mapping from __init__ to the
name of the class.

For example:
   import sys
   sys.<C-x,C-o>
move to "excepthook" which will contain the parameters in the popup
window (for convenience).  When you accept that entry, it completes
to:
   sys.excepthook(
Allowing you to enter the parameters themselves.  Hitting <C-x,C-o> at
this point will complete the parameters as named in the original
popup, leaving you with:
   sys.excepthook(exctype, value, traceback)
Reply | Threaded
Open this post in threaded view
|

Re: vim 7 python completion

Andrea Spadaccini
Ciao Aaron,

>    sys.excepthook(
> Allowing you to enter the parameters themselves.  Hitting <C-x,C-o> at
> this point will complete the parameters as named in the original
> popup, leaving you with:
>    sys.excepthook(exctype, value, traceback)

Thanks a lot for your message and for your great script! :)

--
[ Andrea Spadaccini - a.k.a. Lupino - from Catania - ICQ #: 91528290 ]
[ GPG ID: 5D41ABF0 - key on keyservers - Gentoo GNU / Linux - 2.6.18 ]
[ Linux Registered User 313388 - @: a.spadaccini(at)catania.linux.it ]
[              Sometimes too much drink is not enough.               ]

signature.asc (196 bytes) Download Attachment