Sublime Forum

Autocomplete for Corona SDK

#1

Hi,

Is there a way to add custom autocompletes for Sublime Text 2?

Am very interested to use ST2 as the IDE of choice, particularly love the very nice and customizable aesthetics. However, what’s lacking is the autocompletes for Corona SDK. There’s this other text editor - TextMate that comes with Corona bundle:

http://www.youtube.com/watch?v=PoBVq5Tr5eY)

Not only does it have autocompletes for Corona, you press tab, and the function parameters are even listed out for you to simply fill in. This is an essential feature that’s a must have. However, the text editor is just too plain boring to look at, which is where ST2 comes in. If anyone has a satisfactory solution for this, I’d buy ST2 straight away. Otherwise, I’ve no choice but to go for TextMate.

Thanks.

0 Likes

#2

You can use TextMate snippets (where you press tab and fill in) and grammars (syntax highlighting) with ST2. Just grab the .tmlanguage and snippets files from the TextMate bundle and you should be good to go.

0 Likes

#3

Apologies for this beginner’s question, but I’ve been getting an error popup when I try to load ST2 after installing the Corona TextMate bundle. I placed the files in Packages/User (where I successfully installed the Soda theme) but cannot load ST2. It just gives me the following error message:

Error loading meta info: Expected key scope

Any advice is much appreciated. I read a huge chunk of the docs but they seem to deal with creating your own packages or syntax definitions vs just installing a TextMate bundle (perhaps because the latter is more straightforward?). I really like my evaluation of ST2 and if I can get the Corona bundle working, it’s an instant purchase.

thanks,
jim

0 Likes

#4

I also tried installing the Corona TextMate bundle using the instructions from HERE, but wasn’t able to get neither the autocomplete of keywords or snippets to work.

From the Corona TextMate bundle I copied

  • All of the snippet files (104 files starting with addEventListener.tmSnippet and ending with zwoptex.tmSnippet) from the Snippets directory
  • Lua.tmLanguage file from the Syntaxes directoryctor
  • Preference files (Comments.tmPreferences, Completions.tmPreferences, and Indent.tmPreferences) from the Preferences directory

All into the Sublime Text 2 Packages/Lua subdirectory. Lano78 at CreativeFusion who created the instructions to do this mentioned that there was an error that was displayed at Sublime start up but didn’t mention explicitly what the error was. I just assumed that the Error loading meta info: Expected key scope was the error he was mentioning.

I did reply to Lano78 of the issue that I was having on the CreativeFusion web page but he hasn’t moderated my reply yet. I also reached out to Rodrigo who seemed to get his installation to work but havent’ heard back from him either. Has anyone else here been successful in getting the TextMate bundle to work with Sublime Text 2?

Thanks,

Steve

0 Likes

#5

Here is the Sublime console output after Sublime starts up (don’t know if this will be of any help):

startup, version: 2139 osx x64 channel: stable
executable: /Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2
working dir: /
packages path: /Users/scapie/Library/Application Support/Sublime Text 2/Packages
settings path: /Users/scapie/Library/Application Support/Sublime Text 2/Settings
error parsing session: No data at: 0:0
PackageSetup not required
catalogue loaded
found 3 files for base name Default.sublime-keymap
found 1 files for base name Default.sublime-mousemap
found 1 files for base name Main.sublime-menu
error: Error loading meta info: Expected key scope

Regards,

Steve

0 Likes

#6

I guess it is always good when you can answer your own question :smiley:

I should first point out that I installed exactly what I mentioned previously into the Sublime Packages/Lua subdirectory no changes were done to get it to work. I still get the previous error (i.e Expected key scope) but this doesn’t seem to prevent the auto-completion to work. I am also running on Mac running OSX 10.6.8.

I received a response from Rodrigo and he mentioned that for auto-completion to work for the parameters that you need to type all characters up to but not including the opening parenthesis. For example, if I want to auto-complete the parameters for display.newRect. I would type the characters up to ‘t’ then press TAB to get the parameter snippet auto-completion. Previously, after typing display.newRect I had typed the opening parenthesis in which Sublime would automatically add the closing parenthesis then I tried pressing the TAB key but nothing happened.

Given this new information I thought I could now tackle figuring out how to get keyword auto-completion to work. Luckily I figured this out as well. Let’s say you want to use the display.newRect API call. First start typing the ‘d’ then press Option-ESC (the instructions for the TextMate bundle said to press ESC for TextMate; however, this won’t work in Sublime). This displayed a popup (use ESC to remove the popup) with all the different display related methods (e.g. display.newText, display.newRect, etc…). Select the one that you want in the popup press RETURN and it will also then auto-complete the parameters as well. Be careful, because if you type ‘display.’ then press Option-ESC the keyword auto-complete doesn’t work then. It appears you can type everything up to but not including the period.

I also discovered the following that if you had a line such as:

local t = display.newText(“string”, 0, 0, native.systemFont, 14);

and you wanted to set the text color on the local variable t you can type
t:[Press Option-ESC]

Note that you must type the ‘t’ and ‘:’ then press Option-ESC for it to work.

A popup will show the available instance methods and you can select the setTextColor and it will then auto-complete it as

t:setTextColor(r, g, b, [alpha])

I already like working in Sublime and with the new auto-completion functionality for both keywords, methods, and parameters will make programming Corona that much easier. :laughing:

Regards,

Steve

0 Likes

#7

Actually, as I plan on trying my hand at some Corona SDK here soon, and this bug was more than harmless for myself; I looked further into it.

I removed folders/files one by one until I narrowed down the issue in one of the .tmPreferences files.

Knowing absolutely nothing about it I removed lines until it worked as well.

Then I compared it against the other two .tmPreference files.

Finally I was able to deduce that it was missing two lines of xml that the others shared; this cleared up my issue and I’ve sent a pull request to the git.

github.com/osadchuk/Corona-SDK.tmbundle/pull/2

[code]<?xml version="1.0" encoding="UTF-8"?>

name Completions + scope + source.lua settings [/code]

EDIT: Since this post I’ve thus found this which seems to be more up to date: creativefusion.se/?p=177, I’d suggest using that.

0 Likes

#8

Could someone explain how to set up ( where to copy paste / what to do in sublime ) the Corona-SDK.tmbundle ??

I tried with no success …

0 Likes