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