Sublime Text 3 - ROBLOX Lua Syntax Plugin

A while ago I got tired of things like game and workspace not being highlighted in Sublime, so I wrote a syntax package package. Along the way it picked up some other things, like some autocompletion features.

Installation

It’s open-sourced here and is available on Package Control for easy installation and upgrading. For those of you who are new to Package Control, once you’ve installed it, press Ctrl-Shift-P, search for ROBLOXLua and press enter when it’s selected.

The plugin will take effect for both .lua and .rbxs file extensions. You must be using Sublime Text 3 version 3084 or later to use this, due to its use of Sublime’s new syntax definition format. The earliest public build that supports these is build 3103, released February 9th, 2016.

Features

Syntax highlighting

Pretty simple. This does not necessarily conform with Studio’s syntax highlighting, so things may look a little different.

Autocompletion

I implemented a degree of autocompletion for enums and certain strings (Instance.new, GetService, etc). These are based entirely on regexes - no Lua parsing - so they’ll only work for what’s specifically implemented. Specific things include:

  • FindFirstOfClass - autocompletes all class names
  • Instance.new - autocompletes all createable class names
  • GetService, FindService, service, getService - autocompletes all service names
  • All enums

Snippets

There are a few snippets in the plugin for things like numeric for loops, for-ipairs/for-pairs, while, repeat, etc.

Upcoming

These are on my TODO list, whenever I find the time.

  • luac integration to detect Lua syntax errors as you type
  • Refine autocompletion so it won’t draw completions from comments or strings, won’t autocomplete in comments, etc.
  • More snippets.
16 Likes