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 12K
  • Win 9K
  • OS X 3K
  • Linux 851
Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4 Aug 3 Aug 2 Aug 1 Jul 31 Jul 30 Jul 29 Jul 28 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
Windows 7 13 5 8 4 6 9 8 4 2 4 11 20 10 15 9 6 3 9 13 8 17 15 4 14 9 8 13 11 11 4 6 14 17 8 9 5 2 5 16 12 11 8 8 3 6
OS X 0 2 3 1 1 3 1 1 1 0 3 3 1 0 1 3 0 0 2 1 1 1 1 0 2 3 2 0 0 1 0 0 2 1 4 5 3 0 1 2 1 4 7 0 1 1
Linux 0 0 0 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 1 1 0 1

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