Formatting lua to a more readable form by using Lua Development Tools library.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
metalua
Default (Linux).sublime-keymap
Default (OSX).sublime-keymap
Default (Windows).sublime-keymap
Default.sublime-commands
FormatLua.py
FormatLua.sublime-settings
Main.sublime-menu
README.md
checks.lua
formatter.lua
metalua.lua
package.json

README.md

Summary

FormatLua formats lua code to a more readable form by using Lua Development Tools library.

Require

  • Lua

Support System

  • MacOSX
  • Linux

How to Use

  • Select lua code and click menu Selection -> Format -> Format Lua Code
  • Select lua code and press alt+l

Configure Setting

Setting lua path in FormatLua.sublime-settings

{
    "lua_path": "/usr/local/bin/lua"
}

Configure Key Binding

Add the following line to keymap settings

{ "keys": ["alt+l"], "command": "format_lua" }

Example

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