Package: luastyle
A Lua code formatter written in Python.Installation:The package can be installed throughpip:$ python3.6 -m pip install luastyleIt will install the shell command ‘luastyle’.OptionsThese are the command-line flags:Usage: luastyle [options] file_or_dir1 file_or_dir2 …CLI Options:
  --version                       Show program's version number and exit
  -h, --help                      Show this help message and exit
  -i, --in-place                  Write output in-place, replacing input
  --config=F                      Path to config file
  --config-generate               Generate a default config file
  --type=EXT                      File extension to indent (can be repeated) [lua]
  -d, --debug                     Enable debugging messages
  -j N, --jobs=N                  Number of parallel jobs in recursive mode
  -C, --check-bytecode            Check lua bytecode with luac, $LUAC can also be set to
                                  use a specific compiler


Beautifier Options:
  -a, --space-around-assign       Ensure one space before and after assign op "="
  -c S, --indent-char=S           Indentation character [" "]
  -f, --check-field-list          Format field-list (table)
  -l N, --indent-level=N          Initial indentation level [0]
  -p, --check-param-list          Format var-list, name-list and expr-list
  -s N, --indent-size=N           Indentation size [2]
  -t, --indent-with-tabs          Indent with tabs, overrides -s and -c
  --close-on-lowest-level         If several closing tokens, indent on lowest token level
  -F N, --func-cont-level=N       Continuation lines level in function arguments [2]
  -I N, --if-cont-level=N         If statement continuation line level [2]
  -M, --check-line-comment-text   Ensure that line comments text is started by at least N char
  -N N, --com-txt-space-size=N    If --check-line-comment-text is enabled, configure the number of spaces [1]
  -S, --skip-sem-colon            Skip all semi-colon after statements
  --break-if                      Break mono-line if statement
  --break-while                   In while and repeat statement, ensure newline after
                                  "do" or "repeat" and before "end" or "until" keyword
  --break-all                     Enable --break-if --break-for and --break-while and
                                  before "end" or "until" keyword
  --force-call-spaces             Force spaces before opening parenthesis in function
                                  call [0]
  --call-spaces-size=N            If --force-call-spaces is enabled, configure the
                                  number of spaces
  --strict                        Enable all featuresLoading settings from environment or .luastylercIn addition to CLI arguments, you may pass a config file via:the LUASTYLE_CONF environment variables pointing to a config filea .luastylerc file located in your user directoryOptions examplesContinuation lines level in function arguments (-F)-F N, --func-cont-level=N   Continuation lines level in function arguments [2]Given:localfunctionprocess(param_1,param_2,param_3,param_4,param_5,param_6)returndo_something()end$luastyle-c"."-F2source.lualocalfunctionprocess(param_1,param_2,param_3,....param_4,param_5,param_6)..returndo_something()endComments formatting options (-M, -N)Available options are:-M, --check-line-comment-text Ensure that line comments text is started by at least N char
-N N, --com-txt-space-size=N  If --check-line-comment-text is enabled, configure the number of spaces [1]Given:--Lorem ipsum dolor sit ametlocalfoo--In sodales elit id orci mollis varius$luastyle-M-N1source.lua-- Lorem ipsum dolor sit ametlocalfoo-- In sodales elit id orci mollis variusBreak If statement option (–break-if)Given:ifconditionthenreturnsuccess()elsereturnfailure()end$luastyle--break-ifsource.luaifconditionthenreturnsuccess()elsereturnfailure()endFormat table field-list (-f)This option ensure that:field separator in table (‘,’ or ‘;’) are trailingcomma is preceded by one space and followed by two spacesThe keyword‘@luastyle.disable’ placed in a comment just after the opening brace
will disable this feature in the concerned table.Given:localdays={monday=1,tuesday=2,wednesday=3}localn={1,2,3}localt={-- @luastyle.disable1,2,4,8,16,32}$luastyle-fsource.lualocaldays={monday=1,tuesday=2,wednesday=3}localn={1,2,3}localt={-- @luastyle.disable1,2,4,8,16,32}Indent closing token (–close-on-lowest-level )Given:describe('must indent',function()done()end)$luastyle--close-on-lowest-levelsource.luadescribe('must indent',function()done()end)$luastylesource.luadescribe('must indent',function()done()end)Function call formatting options (–force-call-spaces, –call-spaces-size)Given:build(foo)$luastyle--force-call-spacessource.luabuild(foo)$luastyle--force-call-spaces--call-spaces-size=1source.luabuild(foo)