Home Download Buy Blog Forum Support

Python Completion and GotoDefinition plugin using Rope

Python Completion and GotoDefinition plugin using Rope

Postby jeberius on Sat Mar 12, 2011 5:04 pm

Hello everyone,

I started porting my TextMate bundle RopeMate to ST2. It integrates the python refactoring/completion library Rope (http://rope.sourceforge.net/) into ST2 to enable python auto-completion and Goto-Definition. Testers welcome!

https://github.com/JulianEberius/SublimeRope

Just unzip/git clone the folder SublimeRope into the Packages directory. Single-file completion works instantly, for project-wide completion you need minimal configuration (see README for details).

I'm looking forward to feedback!

p.s.: Don't despair if the first completion on a new project takes long, just wait a moment. Rope indexes the project and stores the information, so subsequent completions should be fast.

Edit:
The package has been updated. Apart from various fixes to completion and GotoDefinition it also has new features:
- "Rope: New Project" command added to the command palette to help with project setup
- "Rope: Show Documentation" command, which shows the docstring of the word under the cursor
- "Rope Refactor: Rename" command now works quite well (project-wide renaming)
Last edited by jeberius on Fri Sep 23, 2011 2:59 pm, edited 1 time in total.
jeberius
 
Posts: 7
Joined: Fri Feb 04, 2011 1:16 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby squ1b3r on Tue Mar 15, 2011 1:11 pm

Hi, it's great idea!

I used Rope when I used emacs.

Keep it up!
squ1b3r
 
Posts: 45
Joined: Fri Feb 11, 2011 6:35 am

Re: Python Completion and GotoDefinition plugin using Rope

Postby rspeer on Tue Mar 15, 2011 5:48 pm

This sounds great. However, when I have SublimeRope in my packages directory, pressing ctrl+spacebar makes Sublime hang. Endless spinning beachball.

I may be doing something unexpected, in that I use Sublime to open individual files from the command line, not projects. I assumed the point of the .ropeproject was so that it could find the project root anyway. Does whether I'm in a project affect anything?
rspeer
 
Posts: 7
Joined: Tue Feb 01, 2011 8:43 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby erix on Wed Mar 30, 2011 9:14 am

Good luck. Looking forward to next release.
erix
 
Posts: 1
Joined: Wed Feb 17, 2010 6:52 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby ggayan on Mon Apr 18, 2011 10:40 pm

Any plans on doing something with pysmell?

I think that it works better than rope in terms of autocompletion (using django).

Maybe I could help developing a plugin for pysmell based on yours.

Great work anyway! :D

Cheers
ggayan
 
Posts: 5
Joined: Mon Apr 18, 2011 10:17 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby jeberius on Thu May 05, 2011 8:52 am

@ggayan:
I played around with it, but I still like Rope better (don't have to update tags, refactoring options etc.)
I attach my version of "SublimeSmell" ;-) so you can improve it if you want. I'll stick with Rope.
Concerning Django: for me it works with Django. Remember that Sublime Text 2 may not use the same Python version as you (e.g. on OSX, it uses the system 2.6), so you may have to add your Django installation to the python_path in .ropeproject/config.py.
As written in the documentation, in my case I add

Code: Select all
prefs.add('python_path', '/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages')


So that ST2 picks up my 2.7 packages.
Then I add the parent dir of my project dir, because the imports in Django include the root package of the project (they don't use relative imports).
Basically, just make sure that everything you want to see completed is on the python path using config.py.

E.g.
Code: Select all
prefs.add('python_path', '/Users/ebi/my_django_projects')


Then Rope completes everything for me, both Django and my Django code.

@rspeer
I think its a performance problem with Rope. If there are a lot of packages Rope will have to index them all, which takes a long time. I also had the same problem when working with "from X import *" on big modules, e.g., PyObjc. Every completion would take ~12 seconds, as Rope would always index the complete Objective-C/Cocoa API and not cache anything (for some reason). In the current version I disabled star imports in Rope, so it works for me.
In your case, try to use it in some project dir, not in your package dir and see if the problem persists.

edit: I have updated the documentation on GitHub to explain the issues with Rope and the Python path.
Attachments
SublimeSmell.zip
This is NOT SublimeRope, check the GitHub page!
(69.13 KiB) Downloaded 337 times
jeberius
 
Posts: 7
Joined: Fri Feb 04, 2011 1:16 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby ggayan on Thu May 05, 2011 8:29 pm

great, thanks!

probably i didn't made the right configuration with rope; I'll give it another change.

I'll be glad to contribute if you need to, my github user is ggayan

Keep up the good work!
ggayan
 
Posts: 5
Joined: Mon Apr 18, 2011 10:17 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby jeberius on Fri Sep 23, 2011 3:02 pm

The package has been updated. Apart from various fixes to completion and GotoDefinition it also has new features:

- "Rope: New Project" command added to the command palette to help with project setup
- "Rope: Show Documentation" command, which shows the docstring of the word under the cursor
- "Rope Refactor: Rename" command now works quite well (project-wide renaming)

With ShowDocumentation, GoToDefinition and Rename (+completions) Sublime Text almost becomes a Python IDE ;-)
jeberius
 
Posts: 7
Joined: Fri Feb 04, 2011 1:16 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby ask on Fri Sep 23, 2011 4:54 pm

Great, many thanks, with rope power, sublime becomes really useful for me.
ask
 
Posts: 26
Joined: Wed Sep 14, 2011 12:40 pm

Re: Python Completion and GotoDefinition plugin using Rope

Postby pakeha on Mon Jan 02, 2012 4:11 am

Hey! I am new to ST2. I just installed this plugin and it seems very useful so far.

Question: why is it that this plugin works when I place it in my 'Packages' directory (relative to the ST2 directory), but not when I put it in 'Packages/User' ? I suspect that this question applies more generally to ST2 rather than just this plugin; in saying that, I've otherwise been fine installing packages to 'Packages/User'. Mac OS X Lion.

Thanks.
pakeha
 
Posts: 1
Joined: Mon Jan 02, 2012 4:07 am

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 7 guests