Sublime Text 2. Autocomplete python `from`
Asked Answered
N

3

6

I am using SublimeRope plugin. When I am typing from foo.b it displays the autocomplete dialog with random crap but what I am really looking for is to recognize bar module inside the foo package. However if I type from foo import b it immediately suggest me to import bar as a module. Which means Rope "knows" about that module. How can I configure my Sublime to help me suggest the imports when from foo.b ?

I am doing projects with django so the real example it wont me to autocomplete from django.contrib. but if I type from django.contrib.auth.models import U it suggest me to import user.

Nur answered 25/7, 2013 at 12:9 Comment(0)
C
6

You should definitely be using SublimeJEDI for Python autocompletion! There's no way around Jedi awesomeness.

This is just a Sublime Plugin for the Jedi library (which is definitely better than Rope, but I'm biased because I'm the author).

Chilpancingo answered 25/7, 2013 at 23:0 Comment(0)
P
1

Just adding to what other have said sublimecodeintel can help you with this. However to get it working with Django as you would like you have to add a configuration file pointing to django to your project. The instructions for how to do this are on the github page linked above. You'll add something similar to this:

    {
"Django":{
    "django":'/Users/bin/python2.7/site-packages/django'
    },
}
Primalia answered 21/8, 2013 at 13:4 Comment(0)
N
0

Have you checked out SublimeCodeIntel? It's available through Package Control, and has this functionality. The initial indexing of your packages may take some time, but once it's all set (you may need to restart Sublime once or twice to get everything loaded) it works like a charm.

Necolenecro answered 25/7, 2013 at 13:59 Comment(2)
Seems like it mess up the Rope plugin which I use especially because of 'Go To Definition' function. Are there any way to use both of them or maybe just remove Rope? I use Sublime Text 2.Nur
I haven't used SublimeRope, so I'm not sure how they conflict. Double-check the SublimeCodeIntel settings to see if "sublime_auto_complete" is set to false, and if it is then try setting it to true.Necolenecro

© 2022 - 2024 — McMap. All rights reserved.