Skip to content

DevAlone/LuaFormatter

 
 

Repository files navigation

LuaFormatter

Reformats your Lua source code.

Build Status (Linux / MacOS) Build status (Windows) codecov

Editor support

Install

LuaRocks

The easiest way is to install is to use LuaRocks.

luarocks install --server=https://luarocks.org/dev luaformatter

Build from source

Requirements

  • cmake 3.9+
  • c++ 17 compiler

Steps

    git clone --recurse-submodules https://github.com/Koihik/LuaFormatter.git
    cd LuaFormatter
    cmake .
    make
    make install

Usage

  ./lua-format [Lua scripts...] {OPTIONS}

    Reformats your Lua source code.

  OPTIONS:

      -h, --help                        Display this help menu
      -v, --verbose                     Turn on verbose mode
      -i                                Reformats in-place
      --dump-config                     Dumps the default style used to stdout
      -c[file], --config=[file]         Style config file
      Lua scripts...                    Lua scripts to format
      "--" can be used to terminate flag options and force all following
      arguments to be treated as positional options

The program will attempt to automatically use the current directory's .lua-format file if no config file is passed in the command line. In case there's no file, it will fallback to the default configuration.

Style configure file

Configuration parameters not specified fallback to their default values.

See this file

Default configuration

column_limit: 80
indent_width: 4
use_tab: false
tab_width: 4
continuation_indent_width: 4
keep_simple_block_one_line: true
align_args: true
break_after_functioncall_lp: false
break_before_functioncall_rp: false
align_parameter: true
chop_down_parameter: false
break_after_functiondef_lp: false
break_before_functiondef_rp: false
align_table_field: true
break_after_table_lb: true
break_before_table_rb: true
chop_down_kv_table: true
table_sep: ","
extra_sep_at_table_end: false
break_after_operator: true
double_quote_to_single_quote: false
single_quote_to_double_quote: false

Limitations

  • Do not work when source file contains syntax error
  • Do not support 'Format selection'

About

Code formatter for Lua

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 96.8%
  • ANTLR 2.0%
  • CMake 1.1%
  • Other 0.1%