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

Format​Lua

by denglf ALL

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

Details

Installs

  • Total 17K
  • Win 12K
  • Mac 4K
  • Linux 1K
Feb 5 Feb 4 Feb 3 Feb 2 Feb 1 Jan 31 Jan 30 Jan 29 Jan 28 Jan 27 Jan 26 Jan 25 Jan 24 Jan 23 Jan 22 Jan 21 Jan 20 Jan 19 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
Windows 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 1 0 1 0 1 1 0 0 1 0 0 0 0 1 1 0 0 0 0 1 1 0 1
Mac 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0
Linux 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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