简体   繁体   中英

Buildout-aware Python autocompletion for Sublime Text

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

Eg 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.

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}

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

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!

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 (ie 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM