Ludicrous Software

Corona Textmate Bundle

The Corona Bundle for TextMate is designed to help TextMate users code their Corona apps more quickly. It contains a large number of autocomplete terms, commands, and snippets that make it that much easier to access the various Corona APIs using the standard TextMate keyboard/menu shortcuts.

Getting the Bundle

The bundle is hosted on GitHub. You have two options for downloading/installing the bundle:

  1. If you use Git for version control, then you can checkout the bundle into your ‘~/Library/Application Support/TextMate/Bundles’ directory. If you cd into that directory, then clone the bundle using ‘git clone’, you’re good to go. The advantage of this method is the ease of getting new versions as the bundle is updated. If you want to specify a custom directory name for the bundle, just make sure it ends in “.tmbundle”, otherwise TextMate won’t recognize it.
  2. If you don’t want to use Git, then you can download the bundle as a zip file from GitHub. Here are the steps:
    1. Download the zip or tarball from GitHub and open it up.
    2. Rename the resulting directory to “Corona SDK.tmbundle”, or whatever other name you prefer. Just make sure it ends in “.tmbundle”.
    3. Copy that directory to ‘~/Library/Application Support/TextMate/Bundles’.
    4. Restart TextMate or reload the bundles to see the Corona SDK Bundle under your bundles menu.

Using the Bundle

Once the bundle is installed, TextMate should automatically recognize .lua files when they’re opened. The autocomplete keywords are accessible using the ‘Esc’ key, as is typical for TextMate. The majority of the snippets are for standard Corona methods, and are accessible by typing the method name and then hitting the ‘tab’ key. There are snippets that encapsulate a larger chunk of code, and are accessible by hitting ‘tab’ after typing a keyword. For example, if you type ‘zwoptex’ and then hit ‘tab’, you’ll get the basic chunk of code required to integrate sprite sheet data generated by Zwoptex.

If you’re not sure if there’s a snippet available for a particular method, you can either browse the bundle via the TextMate Bundles menu, or by typing the method name and hitting the ‘tab’ key. I generally try to add new snippets as I encounter ones that are missing, but if there’s anything in particular you’d like to see added to the bundle, please let me know.

Here’s a short demo of how to use the bundle:

What’s the Cost?

The bundle is completely free. Everything is available through GitHub, so feel free to grab it and use, fork it, do whatever you want.

However, if you use the bundle and find it to be of value to your Corona workflow, donations through PayPal are most welcome, and greatly appreciated.

Latest changes

9 November 2011

  • Ansca recently added package support to Corona, so now Lua modules can be located within a package/subfolder. The “Run Simulator” command would not work if the document currently being edited was in a subfolder. This has been (or should be) fixed. There are apparently situations where the “Project Directory” environment variable in TextMate does not get set, but in my tests that wasn’t happening, so I’m not 100% sure my workaround for that eventuality will in fact work. If you encounter issues, please let me know.

24 September 2011

  • Fixed some bugs/inconsistencies with indentation of code blocks.
  • Added snippets, completions, etc. for factory functions for the new widget library

16 September 2011

Added support for specifying a default device skin for the Corona Simulator when running your project using the ‘Run Simulator’ command. To do this, you must set a project-specific shell variable called ‘SKIN’ to the name of the device skin you want to use. You can see this post about setting a custom location for the Corona SDK to learn how to set up a project-specific shell variable. For setting the SKIN variable, what you should end up with ought to look like this:

3 August 2011

Added support for setting custom locations for the Corona SDK. This is useful if you’ve installed the SDK to a non-default location, or if you want/need to run multiple versions of the SDK simultaneously. I’ve done a blog post explaining how to set this up in your TextMate projects.

29 July 2011

  • A whole whack of code snippets, completions, and highlighting for APIs that have been added recently (where “recently” is defined as “the last time I updated the bundle significantly”). These include:
    • analytics
    • credits/virtual currency
    • Facebook
    • Game Network
    • In-App Purchases
    • JSON
    • Maps
  • A small thing that has me inordinately pleased is the addition of proper code colouring for string and table methods when called in an object-oriented fashion (e.g. myString:reverse() instead of string.reverse(myString)). I find the former much faster to do, but was missing the lack of proper code colouring.
  • There have also been a few minor additions/fixes (added a snippet for display.loadRemoteImage(), fixed code highlighting for addEventListener(), etc.)

2 March 2011

  • Added some very basic templates for build.settings, config.lua, and generic modules. These aren’t intended to be robust methods of making it easy to enter any setting under the sun for these files, but to just make it a bit easier to generate them in the first place. The templates are available via the ‘New from Template’ menu item, or the ‘Create a new file…’ button in the project drawer.
  • Added snippets for the methods in the new audio engine. I’m not entirely pleased with some of these, but am still in the middle of working out a convenient way of including option arguments to the method calls in the snippets. As a result, you’ll still have to do a little bit of manual deleting if you don’t want to pass particular arguments. And, in some cases, you’ll need to know which arguments are optional.

25 January 2011

  • Added snippets for ‘native’ library, setFillColor, setStrokeColor, transition.from
  • Fixed some completions

15 January 2011

  • Updated some of the snippets that were out-of-date due to changes in the Corona SDK.
  • Added a bunch of new snippets, mainly for the media package
  • Started to organize the bundle menu into a set of submenus, grouping snippets by package.
  • Added parentheses to many of the functions in the completions list if the function does not take any arguments (e.g. the completion is now ‘stopTuner()’ instead of ‘stopTuner’, so you don’t have to type those parentheses anymore).
  • Sorted the completion list alphabetically, and put full package paths at the end of the completion list.

12 January 2011

  • Added a ‘module’ snippet to insert the ‘module (…, package.seeall)’ code required at the start of Lua modules.
  • Now with 50% (not an accurate percentage) more colour! Added all of the Corona SDK keywords from the Corona API docs to the syntax highlighting code, so most Corona SDK property/function names will be code-coloured. If I’ve missed any, let me know.

29 December 2010

  • Edited ‘README’ to point to this page.

28 December 2010

  • Added ‘sprite.newSprite’ snippet
  • Added ‘zwoptex’ snippet, which encapsulates code required to integrate sprite sheet data generated by Zwoptex.