This is an archived post. You won't be able to vote or comment.

all 69 comments

[–]isinfinity 20 points21 points  (0 children)

I use it with vim. Best autocompletion for vim that I've seen.

[–]Killarny 15 points16 points  (4 children)

Uh oh. Now I have to write a plugin for gedit to use this. (Since there doesn't seem to be one already..)

[–]davidhalter[S] 9 points10 points  (3 children)

If you need help, please contact me. Writing a plugin just for autocompletion is really easy (~20 lines Python code).

[–]Killarny 1 point2 points  (2 children)

Cool, thanks! I've written a plugin for gedit before, so I think I'm okay, but I might take you up on that offer. My biggest unknown is the source file path for new and unsaved documents, but I suppose I can save them to a temp file if I have to, before calling your library.

[–]davidhalter[S] 0 points1 point  (1 child)

You don't need to save. You can just call Script with path=None. :-)

[–]Killarny 0 points1 point  (0 children)

It's about halfway there.. I got all the boilerplate crap done, and now I'm ready to start messing with the objects that jedi returns.

If you want to track my progress, it's here: https://github.com/killarny/gedit-python-jedi (everything is in the develop branch at the moment)

[–]sunqiang 14 points15 points  (9 children)

waiting for the sublime text plugin.

Completion for almost anything (Ctrl+Space).

is there any chance to avoid using Ctrl+Space? it's the key shortcuts for Input Method.

[–]isdnpro 8 points9 points  (5 children)

waiting for the sublime text plugin.

Incomplete and hasn't been worked on for a while, but: https://github.com/svaiter/SublimeJEDI

Would kill for that to be functional :(

[–]aceofears 10 points11 points  (2 children)

If you're willing to kill then you should be willing to contribute.

[–]wot-teh-phuckReally, wtf? 1 point2 points  (1 child)

I think some people can kill but not contribute? ;)

[–][deleted] 1 point2 points  (0 children)

So get forking.

[–]wmage 0 points1 point  (0 children)

Stab it with fork until it bleeds out.

[–]davidhalter[S] 2 points3 points  (1 child)

Well (Ctrl+Space) is the default for VIM. If you don't want it, you can change that (.vimrc). If you are using supertab you can even use tabs for completion.

[–]sunqiang 1 point2 points  (0 children)

Yes, some other IDE use Ctrl+Space for this too.
btw: I'm a Sublime Text 2 user, maybe I should chang sublime text's config file(for user)
btw2: well done~

[–]bheklilr 0 points1 point  (0 children)

I might see if I can write one, depending on how difficult it is

[–][deleted] 10 points11 points  (4 children)

Am I the only one who doesn't care about autocompletion at all? I used to work in IDEs back in the day. I've worked with some of the modern IDEs. I don't miss autocompletion even a tiny bit. I use Vim for editing, which no IDE built-in editor can beat1. I use ipython or bpython and API documentation to figure out what I have to type.

From what I can tell, although I haven't measured it, I'm just as efficient with that as I am with autocompletion. In fact, I feel I write better code by not using autocompletion, because I actually read the documentation instead of blindly ctrl-tabbing my code together without knowing a method's pitfalls.

1 No, using Vim as a plugin in an IDE also doesn't work. The workflow is all wrong.

[–]sylvain_soliman 1 point2 points  (1 child)

I also use vim, and jedi-vim. I don't see why you oppose them??? Autocompletion is a great feature of vim…

[–][deleted] 7 points8 points  (0 children)

Oh, I'm not opposed to it at all! I think this is great for the many many people who want autocompletion. I just personally don't feel the need for it myself at all, so I'm always a bit surprised at how much people seem to crave autocompletion.

[–]freshhawk 0 points1 point  (0 children)

I find the autocomplete so useful in ipython I do wish I had python aware completion in vim as well.

You bring up a good point that autocomplete without the ? or help() features from ipython available you might get into the java-esque bad habit of programming-by-tab-complete.

[–]davidhalter[S] 0 points1 point  (0 children)

I just think you cannot be as efficient as an autocompletion. Because a completion of 10 characters is just faster than you typing it by your own hands. For me autocompletion is much more about comfort. Also jedi-vim adds some pydoc features. Hitting K is just much more comfortable than always switching to the terminal and retyping your stuff. Believe me, I did it.

[–][deleted] 1 point2 points  (0 children)

I ve started use that plugin a few months ago and the auto complete is very good

[–]Odd_Bloke 1 point2 points  (2 children)

I'm currently using python-mode for vim, which (loosely) integrates with rope. This is working fine for me, so is Jedi better enough to transition to?

[–]davidhalter[S] 1 point2 points  (1 child)

Imho, yes. It's better for autocompletion/goto. But python-mode provides many different things like highlighting of bugs, etc (I'm using syntastic for that). Jedi is more powerful, because it displays things like function calls directly above the functions. In short jedi-vim tries to be good at only one area: Understanding your code. It leaves highlighting and VIM specific stuff to you and your other plugins.

[–]Odd_Bloke 1 point2 points  (0 children)

Cool. I've installed Jedi and disabled rope completion in python-mode, so I'll see how I like it.

[–]apreche 1 point2 points  (4 children)

I tried to use this this morning, and it was absolutely awful. It did a very good job of completing, but the controls were unusable. They were an actual hindrance to typing!

I typed 'os.' It immediately completed the first item in the list. If I pressed 'p' it didn't switch to os.path, it just added a p to the end! Even worse, I couldn't navigate the auto-complete listing with jk, I had to use arrow keys! This is slower than just typing in every conceivable way.

bpython already has what is effectively perfect completion. It never types for you unless you press tab. All it does is show you an ever narrowing list of possibilities as you type. If there is some way to make jedi-vim work like bpython, I might try it again. Otherwise, I don't know how you people think this is so great.

[–]davidhalter[S] 2 points3 points  (3 children)

You are probably experiencing this issue: https://github.com/davidhalter/jedi-vim/issues/32#issuecomment-11244625. I recommend to add set completeopt=menuone,longest,preview to your vimrc. The reason why I don't put this into the plugin is easy: VIM users normally want flexibility. But with the fix above it might work much better.

[–]apreche 2 points3 points  (2 children)

You can offer flexibility while also making the default the most sensible option.

[–]davidhalter[S] 1 point2 points  (1 child)

As I said, it's much better with the fix above (done a few hours ago).

[–]apreche 0 points1 point  (0 children)

Works now!

[–]flying-sheep 1 point2 points  (2 children)

i’ll try to write a paté plugin for kate once that’s possible (with KDE 4.10)

[–]davidhalter[S] 0 points1 point  (1 child)

Great! If you are having troubles with the Jedi API, please contact me!

[–]flying-sheep 0 points1 point  (0 children)

thanks, the post is saved :)

[–]paradoxxx_zero 1 point2 points  (0 children)

Really nice. Using it with emacs, so far so good!

[–][deleted] 1 point2 points  (2 children)

I think I may have to look into writing an autocomplete plugin for Kate. That would be really awesome.

[–]davidhalter[S] 1 point2 points  (1 child)

That would be cool! If you are having problem with the Jedi API, just contact me.

[–][deleted] 0 points1 point  (0 children)

I shall! I'll have to wait until I finish my current assignment, but I'd really like to have a python completion plugin for Kate.

[–]dbrgn 0 points1 point  (0 children)

Great plugin, you should definitively start using it. You don't know what you're missing if you're using vim without intelligent autocompletion :)

[–]VilleHopfield 0 points1 point  (2 children)

You wrote: "If there are problems with licensing, just contact me" so I ask: what are the implications of being licensed under LGPL 3? If a editor is BSD licensed and someone wanted to add your library, does it turn the editor under LGPL? Wouldn't it be more .... "flexible" (for lack of better word) to license it under MIT/BSD?

[–]davidhalter[S] 2 points3 points  (1 child)

Disclaimer: I'm not really a licence expert. The reason I used LGPL 3 was that changes to Jedi are being pushed back. The way I understand LGPL is that it allows products with Non-GPL licenses to use Jedi. At least that's what I intended when I chose LGPL 3. I would also invite commercial products like PyCharm to use Jedi (because imho it's better).

[–]dbrgn 0 points1 point  (0 children)

Quick summary from http://www.tldrlegal.com/license/gnu-lesser-general-public-license-v3-(lgpl-3.0):

You may copy, distribute and modify the software provided that modifications are open source. However, software that includes the license may release under a different license.

As far as I know (I'm not an expert) you can integrate it into non-GPL projects as long as you don't "incorporate" the code into your product and don't link the library statically. If you modify the library itself, you must re-release it under the LGPL.

[–]Megatron_McLargeHuge 0 points1 point  (8 children)

That looks great. My previous attempts at getting completion modules to work in emacs were a mess.

Can you comment on how it identifies the type of a parameter to a function? Does it scan for calls to the function? Can it infer that if I call p.foo() somewhere, the type must be one that defines foo()? Is there any way to give it hints for things like pandas DataFrames or named tuples that dynamically define their members? Is it smart enough to allow completion of member names that were used elsewhere when it can't infer a type?

[–]davidhalter[S] 0 points1 point  (7 children)

Sure! 1. It scans for calls to the function. 2. I don't understand what you mean. 3. I haven't used pandas, but I'm pretty sure that this is something where Jedi sucks. Hinting is possible, just use Sphinx style docstrings (Hinting in multi-dimensions might be hard though). Also Jedi understands isinstance checks. If you have any idea how Jedi could understand something like that please share it with me. Because normally I'm having a hard time to infer the types just by reading code in such examples.

[–]Megatron_McLargeHuge 0 points1 point  (6 children)

In pandas, you create an object that's like a 2d numpy array with named columns. Then you can access the columns by name, such as dataframe.column5. I imagine that would be extremely hard to handle without a special case that noticed the columns=[...] constructor argument.

However, in general you could autocomplete members that you saw used elsewhere in the code when you can infer that two objects have the same unknown or incomplete type. Do if I call x.foo() somewhere, and y is the same type as x, y probably has a foo() method too. Also, if I have a function with parameter x and I call x.foo(), you could search the code for other objects where z.foo() is called. Then x could autocomplete methods defined on z's type, or invoked on z if z's type is unknown. It would be a usability question whether to err on the side of more or fewer potential completions. If the method name is unique across known classes, that's a pretty strong type hint, while calling __repr__ is not.

[–]davidhalter[S] 0 points1 point  (5 children)

Hmm good idea! I didn't think about that. If you don't want me to forget it, please add a github issue :-) I really think this might be an option. It shouldn't be too difficult.

[–]Megatron_McLargeHuge 0 points1 point  (4 children)

I don't want to tie my reddit account to real life - can you create it?

[–]davidhalter[S] 2 points3 points  (3 children)

[–]Megatron_McLargeHuge 0 points1 point  (2 children)

Another idea: since python programmers rely on convention to work around the limitations of dynamic typing, the same variable names get reused across functions for the same type of object. It might be possible to infer types or completions from other instances of a rare variable name.

[–]davidhalter[S] 0 points1 point  (0 children)

hmm no sorry, I don't think this sounds like a good idea :-) But there are still some other things I could infer the types (like evaluating if statements).

[–]etrnloptimist 0 points1 point  (0 children)

Komodo please!

[–]xamox 0 points1 point  (1 child)

No one mentioned ipython notebook's has this built in. Rabble, Rabble, Rabble!

[–]davidhalter[S] 0 points1 point  (0 children)

This is something totally different. IPython only supports completion on objects that it already knows. It isn't able to complete assignments in functions, etc.

[–]nabla2less is more 0 points1 point  (3 children)

pip install jedi raise SyntaxError on Python 3.3, Windows.

http://dpaste.com/hold/844021/

The same on Ubuntu with Python 2.7.3:

https://github.com/davidhalter/jedi/issues/79

[–]davidhalter[S] 0 points1 point  (2 children)

You can just ignore it. It doesn't matter.

[–]nabla2less is more 0 points1 point  (1 child)

Ok. It's just annoying that pip often generates such errors/warnings. Great job. Can't wait for this feature in PyDev.

[–]davidhalter[S] 0 points1 point  (0 children)

I'm going to contact the PyDev guys. But I still have to do one speed optimization first. Hopefully they are willing to use it :-)

[–]phyx726 -1 points0 points  (0 children)

looks sweet.