FormatLua formats lua code to a more readable form by using Lua Development Tools library.
- Lua
- MacOSX
- Linux
- Select lua code and click menu Selection -> Format -> Format Lua Code
- Select lua code and press alt+l
Setting lua path in FormatLua.sublime-settings
{
"lua_path": "/usr/local/bin/lua"
}
Add the following line to keymap settings
{ "keys": ["alt+l"], "command": "format_lua" }
Original:
local a = "你好"
local b
function set_text(name, value)
local doc = document:getElementsByName(name)
if doc and #doc > 0 then
doc[1]:setPropertyByName("text", value)
end
end
return b
Formated:
local a = "你好"
local b
function set_text(name, value)
local doc = document:getElementsByName(name)
if doc and #doc > 0 then
doc[1]:setPropertyByName("text", value)
end
end
return b