ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Format​Lua

by denglf ST2/ST3

Formatting lua to a more readable form by using Lua Development Tools library.

Details

Installs

  • Total 9K
  • Win 6K
  • OS X 2K
  • Linux 716
Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10
Windows 5 6 5 8 12 6 13 1 4 13 11 19 10 5 4 4 4 17 8 8 1 5 6 6 11 10 3 10 3 4 6 7 7 9 4 4 1 8 3 10 18 5 1 5 9 14
OS X 1 3 5 5 5 5 3 1 1 3 5 3 1 1 0 0 0 4 0 2 2 2 3 3 1 5 0 3 0 2 0 2 2 2 2 2 1 1 3 3 3 3 0 1 3 5
Linux 0 0 3 0 0 0 1 0 0 2 1 1 0 3 1 2 0 1 3 1 1 0 0 1 0 0 0 1 0 0 0 0 0 2 1 0 0 0 0 0 1 1 0 1 0 0

Readme

Source
raw.​githubusercontent.​com

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