Here's how I get my files linted, using ST3:
1. Install SublimeText 3
It has unlimited free demo (but buy it if you think it's awesome to help support the devs): ST3 Beta (currently in beta, but already better than v2)
2. Install Package Control
A free package manager addon for SublimeText: Package Control
3. Install Sublime Linter
This is an open source generic linting framework for Sublime Text - it provides a consistent UI for multiple linting tools (eg. for Javascript, Lua, JSON, Ruby, etc). Get it here.
4. Install Lua
- Windows installer
- Mac OS X: Install homebrew (a package manager) first, then in a terminal window do to install it
Code: Select all
brew install lua
- Linux binaries, etc.
6. Stop it moaning about inbuilt globals
The linter doesn't know about the globals that Factorio defines, but you can teach it with an inline comment at the start of your lua script file. For example to tell it about `defines`, `game`, `global` and `script`, use:
Code: Select all
--luacheck: globals defines game global script
Don't add custom globals though, you should be defining them as locals (actually improves performance in some cases, and just good practice to get in to). Yes, even functions `local function foo() ...`.
That's it - when you start editing you'll see errors quickly reported as you type
Useful ST3 packages