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