Unity completions for Sublime Text

sublime_unity_small

This might be a technical post, about Sublime Text. Or it could be a community post, about Unity editors. I don’t know yet. In any case it’s about Unity Completions, my first package for ST.

Unity Completions does one thing: It allows me to develop for Unity using ST. I know ST’s got its quirks, but it’s homey. And I eventually fell for its simultaneous editing – it’s stupendous! I’ve been using it quite contently for a long while. But the lack of Unity auto-completions, though, was dissatisfying. I couldn’t let it slide.

What Was

I searched the forums for solutions. There was no solution available for Boo developers. I found a post with a good solution for C-sharp developers only, based on CompleteSharp. And I found Jacob Pennock’s package. It fell short on content — it only offered completions for a handful of GUI-related completions — but it showed me how it can be done.

What Is

The next step was natural: I had to create a plugin that covers the full API. But I needed the info – the Unity API. I took a naive approach and wrote a crawler that just scans the entire scripting reference section and produces all the class names and definitions, including variables and function definitions. The output contained a little over 10,000 items. I then wrote a generator that converts it all to ST snippet files for 3 languages. It worked.

I wrote the package in March (9 months ago), when Unity 4.1 was out. I also tried to add it to Package Control, but those guys were wondering why it is should be added when a package with a similar name already exists (Jacob’s). At this point I tried to contact Jacob, but got no reply. By the time I got back to the subject, a new version of PC was in the pipes, soon to be released. So I decided to wait. Then I forgot about it for a while.

A couple of weeks ago I was reminded about it, and soon after added it to PC. It was immediately downloaded by users. In the first 14 days it was downloaded 128 times. It’s not a lot, but it seems a demand exists. The next step was to update the package – Unity v4.3.1 was recently released. I had to update the crawler because changes in Unity’s website broke it.

What’s Next

Now, two challenges remain. One is how to make the package smaller. The package currently holds snippets for a little over 12,000 Unity items. Each has two files (upper case and lower case – or it won’t work well) and all this for each of the 3 languages. This brings the total number of files to 72,399 and the entire package size to 26 MB.

Another challenge is how to keep updating the package easily. The process breaks whenever something changes in Unity’s website. Perhaps a better approach would be to dig into the DLLs?