Buildout-aware Python autocompletion for Sublime Text
Asked Answered
R

4

5

Are there any tricks how one could make Sublime Text's Python autocompletion aware off all eggs from buildout's [eggs] section

E.g. grab the same sys.path as in Plone's generated bin/instance command and expose them to Sublime's auto-completion. You could easily auto-complete imports and stuff after this.

A preferable solution would be

  • Have special bin/sublime command generated by buildout

  • This command would open src/ folder as Sublime text (project?) with all necessary environment variables and stuff set

Other solutions / ideas welcome.

Rockie answered 10/5, 2012 at 19:22 Comment(0)
A
6

Check http://pypi.python.org/pypi/corneti.recipes.codeintel/0.1.3

This is even easier than Martin's solution, I use it together with omelette with a part like this in my development.cfg buildout

[codeintel]
recipe = corneti.recipes.codeintel
eggs = ${buildout:eggs}
extra-paths =
    ${omelette:location}
Allegorist answered 10/5, 2012 at 21:42 Comment(2)
I want to generate .codeintel under src/ so that Sublime file browser sees only the relevant files... src/ which you are editing. Though if omelette is not in the project path CMD + P go anyware does not seem to work. Will investigate the matters.Rockie
The recipe has receive update 0.2.0 with some enhancements I did: github.com/fabiocorneti/corneti.recipes.codeintelRockie
C
4

I, like Martin Aspelli, use the SublimeCodeIntel plugin; together with collective.recipe.omelette this fills all my code-completion needs. Martin blogged about his setup, including a little script that sets up the CodeIntel configuration file for you:

http://www.martinaspeli.net/articles/sublime-text-2-for-zope-and-plone

Constant answered 10/5, 2012 at 20:53 Comment(1)
As a side note, I have a very good experience with ST2's SublimeRope plugin for Python autocompletion.Davena
U
1

For those interested in using SublimeRope instead, you can add something like this to your .ropeproject/config.py:

import os
import glob
for path in glob.glob(os.path.join(os.path.dirname(__file__), '../../buildout-cache/eggs/*.egg')):
    prefs.add('python_path', path)

Those buildout methods are quite fancy though!

Uam answered 6/6, 2012 at 8:16 Comment(0)
C
1

This is another buildout recipe plone.recipe.sublimetext that supports SublimeText 3 with one of the best autocomplete plugin SublimeJEDI, SublimeLinter (flake8, pylint).

This recipe will create buildout specific sublime project file with all paths included (i.e all eggs path for Jedi). Simple use case could be

[buildout]
eggs =
# All eggs here
parts = 
    sublimetext
#   other parts here
[sublimetext]
recipe = plone.recipe.sublimetext
eggs = ${buildout:eggs}
jedi-enabled = True
sublimelinter-enabled = True
sublimelinter-flake8-enabled = True
Checklist answered 17/5, 2017 at 4:17 Comment(1)
a new release is coming up, making it possible to use the omelette as a basis for jedi completion and go-to-definition.Unobtrusive

© 2022 - 2024 — McMap. All rights reserved.