logo

Statement Completion for Dynamic languages in Sublime Text

This post describes how to configure Sublime Text in order to get statement completion for JavaScript, Python, (and perhaps PHP, RHTML, Smarty, Mason, Node.js, XBL, Tcl, HTML, HTML5, TemplateToolkit, XUL, Django, Perl, and Ruby).

After following the steps, statement completion will also work for Python projects installed in a virtualenv.

Install Package Manager

We have just installed Sublime Package Control - A full-featured package manager that helps discovering, installing, updating and removing packages for Sublime Text 2. It features an automatic updater and supports GitHub, BitBucket and a full channel/repository system.

Configure Statement Completion

The Install Package command shows a list of all available packages that are available for install. This will include all of the packages from the [default channel](http://wbond.net/sublime_packages/community), plus any from repositories you have added.

Configure Statement Completion for Python projects in virtualenv

You may skip this if you are not using virtualenv.

{
    "Python": {
        "python": '~/Documents/Projects/VirtualEnvName/bin/python',
        "pythonExtraPaths": ['~/Documents/Projects/VirtualEnvName/lib/python/site-packages',
        ]
    },
}

Note that VirtualEnvName is the name of the virtualenv were the files of the project are located.

The project itself is in ~/Documents/Projects/VirtualEnvName/ProjectName

Statement Completion in action

A screenshot for jQuery (note also the very cool theme)

A screenshot for jQuery

Also,

A screenshot for Document Object Model

A screenshot for Python

References: