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 10K
  • Win 7K
  • OS X 3K
  • Linux 766
Jan 18 Jan 17 Jan 16 Jan 15 Jan 14 Jan 13 Jan 12 Jan 11 Jan 10 Jan 9 Jan 8 Jan 7 Jan 6 Jan 5 Jan 4 Jan 3 Jan 2 Jan 1 Dec 31 Dec 30 Dec 29 Dec 28 Dec 27 Dec 26 Dec 25 Dec 24 Dec 23 Dec 22 Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4
Windows 10 8 5 8 1 4 4 8 9 11 7 0 3 10 9 6 15 0 3 3 6 9 9 12 7 2 5 4 5 8 7 8 6 5 7 2 13 12 11 2 2 4 5 10 7 8
OS X 1 2 5 1 0 1 2 3 2 1 0 0 2 4 5 2 1 2 0 0 2 2 3 0 2 0 0 2 1 5 3 0 0 0 2 1 7 2 0 0 2 0 5 2 2 1
Linux 1 0 0 2 0 0 0 0 0 4 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 2 0 0 1 0 0 1 0 3 0 0 0 0 2 1 3 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