You are not logged in.

#1 2007-09-01 19:54:24

jordi
Member
Registered: 2006-12-16
Posts: 103
Website

vim + python + omnicompletion = impossible?

Hi everyone,

I know that a lot of people use vi, and i know that a lot of them use vi to code python stuff.
So since i like vi a lot i tried to use it too. And as you know, vi is just awesome. But when it comes to gui-programing or other stuff, where you have 1000 different widgets with different functions it's hard to remember them all and that's where my problem start -> the omni-completion simply doesn't work as i want it to and after x hours of googling i haven't found a plugin which make it work as i expect it to.

as a side-note: at school and part-time jobs i was often forced to use visual-studio and it may be a bit hard too say, but when it comes to omni-completion it seems to be the best editor out there.

so what am I looking for?
A vi - plugin which makes the completion behave like the one in visual-studio or if that doesn't exist i would also be satisfied with another editor which have a code-completion like visualstudio.

(for those who are wondering what's wrong with the completion in vi:)
when i type gtk.<ctrl+p> it does show possibilities (although not all of them) but when i do something like
button = gtk.Button
button.<ctrl+p> won't find any methods

besides that, i also tend to dislike the behavor of what it does find (if it does find anything)


thanks already for ya helping me out

Offline

#2 2007-09-01 20:19:02

skymt
Member
Registered: 2006-11-27
Posts: 443

Re: vim + python + omnicompletion = impossible?

Eclipse with PyDev has great code completion. If you want to keep the vi editing style, viPlugin seems to fit the bill, though it's $15.

I don't know of any lighter editors/IDEs that have that level of code completion. It's not exactly trivial, as it essentially requires the editor to parse Python code.

Offline

#3 2007-09-01 20:33:37

smoon
Member
Registered: 2005-08-22
Posts: 468
Website

Re: vim + python + omnicompletion = impossible?

jordi wrote:

Hi everyone,

I know that a lot of people use vi, and i know that a lot of them use vi to code python stuff.
So since i like vi a lot i tried to use it too. And as you know, vi is just awesome. But when it comes to gui-programing or other stuff, where you have 1000 different widgets with different functions it's hard to remember them all and that's where my problem start -> the omni-completion simply doesn't work as i want it to and after x hours of googling i haven't found a plugin which make it work as i expect it to.

as a side-note: at school and part-time jobs i was often forced to use visual-studio and it may be a bit hard too say, but when it comes to omni-completion it seems to be the best editor out there.

so what am I looking for?
A vi - plugin which makes the completion behave like the one in visual-studio or if that doesn't exist i would also be satisfied with another editor which have a code-completion like visualstudio.

(for those who are wondering what's wrong with the completion in vi:)
when i type gtk.<ctrl+p> it does show possibilities (although not all of them) but when i do something like
button = gtk.Button
button.<ctrl+p> won't find any methods

besides that, i also tend to dislike the behavor of what it does find (if it does find anything)


thanks already for ya helping me out

I'm not exactly sure how the completion stuff in Visual Studio behaves, but when editing a Pythong file in vim, omni-completion works pretty well for me. I just press ^X^O to get a popup with possible completions and a window with a little help text for every option.
Here's a screenshot:
vimjf8.png

Offline

#4 2007-09-01 21:37:46

jordi
Member
Registered: 2006-12-16
Posts: 103
Website

Re: vim + python + omnicompletion = impossible?

@skymt
ty, gonna try it for a while, didn't know that there is a viPlugin for eclipse that (and that elcipse bloated) prevented me to give it a try.

@smoon
as i said, the omni-completion works (i know that i have to type ^X^O first) but only for stuff like  gtk.<completion>
but not for  messagedialog = gtk.MessageDialog(..)  messagedialog.<nocompletion>

first i thought that only happens when I import the widget from a gladefile (because then it was obvious for me that it doesn't know what type of object it is) but sadly it's also when i define them normal.

Offline

#5 2007-09-02 11:01:50

smoon
Member
Registered: 2005-08-22
Posts: 468
Website

Re: vim + python + omnicompletion = impossible?

jordi wrote:

[...]

@smoon
as i said, the omni-completion works (i know that i have to type ^X^O first) but only for stuff like  gtk.<completion>
but not for  messagedialog = gtk.MessageDialog(..)  messagedialog.<nocompletion>

first i thought that only happens when I import the widget from a gladefile (because then it was obvious for me that it doesn't know what type of object it is) but sadly it's also when i define them normal.

Maybe I still don't get what exactly you mean, but the example you gave works for me:

vimwk1.png

Offline

#6 2007-09-03 12:30:46

jordi
Member
Registered: 2006-12-16
Posts: 103
Website

Re: vim + python + omnicompletion = impossible?

seems as if i had something in my .vimrc which broke the completion, now it works...

thanks so far.

Anyone, one more question: Is there a way to modify the behavor of the completion in vi, so that it doesn't insert the first match but only show the possibilities? (like in eclipse).

so that when i write msg.a<^X^O> it doesn't fill in msg.action_area but only shows the possibilities with a and remain at msg.a ?
(hope you understand what i mean)

Last edited by jordi (2007-09-03 12:32:14)

Offline

#7 2007-11-30 23:28:08

boris
Member
Registered: 2006-02-25
Posts: 20

Re: vim + python + omnicompletion = impossible?

This is what I use with omnifunc :

"autocompletion stuff
set completeopt=longest,menuone
inoremap <expr> <cr> pumvisible() ? "\<c-y>" : "\<c-g>u\<cr>"
inoremap <expr> <c-n> pumvisible() ? "\<lt>c-n>" : "\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"

hth

Offline

#8 2007-12-01 01:33:36

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

Re: vim + python + omnicompletion = impossible?

jordi wrote:

but not for  messagedialog = gtk.MessageDialog(..)  messagedialog.<nocompletion>

Actually, this is probably different. It depends on your version, but there are a few outstanding bugs that could cause this.

I will tell you it has to do with scoping. All of this works at the top level, but depending on your scope, it may fail

Here's one case:

def foo(*args):
    blah.<C-x,C-o>

This always fails because the plugin doesn't handle the *args and **kwargs arguments (whoops)

Additionally, here's the second issue:

def foo(): #No params here
    blah.<C-x,C-o>

Yup. It fails for functions with no params too - however, this one is fixed in 0.8 (which may or may not be in our vim runtime files)

Offline

#9 2007-12-01 04:31:35

Xilon
Member
Registered: 2007-01-01
Posts: 243

Re: vim + python + omnicompletion = impossible?

On a related note, any suggestions on how to make the window that appears with the description automatically close after selecting something or escaping?

Offline

Board footer

Powered by FluxBB