{"id":13441098,"url":"https://github.com/Koihik/LuaFormatter","last_synced_at":"2025-03-20T11:35:08.300Z","repository":{"id":37743174,"uuid":"154837332","full_name":"Koihik/LuaFormatter","owner":"Koihik","description":"Code formatter for Lua","archived":false,"fork":false,"pushed_at":"2023-08-25T16:37:49.000Z","size":2872,"stargazers_count":677,"open_issues_count":100,"forks_count":85,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-08-01T03:33:01.549Z","etag":null,"topics":["codeformatter","formatter","lua"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Koihik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-26T13:16:03.000Z","updated_at":"2024-07-28T14:28:29.000Z","dependencies_parsed_at":"2023-02-15T20:31:41.098Z","dependency_job_id":null,"html_url":"https://github.com/Koihik/LuaFormatter","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koihik%2FLuaFormatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koihik%2FLuaFormatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koihik%2FLuaFormatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koihik%2FLuaFormatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Koihik","download_url":"https://codeload.github.com/Koihik/LuaFormatter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221752276,"owners_count":16874951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codeformatter","formatter","lua"],"created_at":"2024-07-31T03:01:29.900Z","updated_at":"2024-10-28T00:31:48.137Z","avatar_url":"https://github.com/Koihik.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# LuaFormatter\n\nReformats your Lua source code.\n\n![codecov](https://codecov.io/gh/Koihik/LuaFormatter/branch/master/graph/badge.svg)\n![build](https://github.com/Koihik/LuaFormatter/actions/workflows/build.yml/badge.svg)\n\n## Editor support\n\n* VS Code: https://github.com/Koihik/vscode-lua-format\n* Sublime: https://github.com/Koihik/sublime-lua-format\n* Vim:     https://github.com/andrejlevkovitch/vim-lua-format\n\n## Install\n\n### LuaRocks\n\n#### Requirements\n* c++ 17 compiler\n* luarocks 3.3.0+\n\nThe easiest way to install is to use [LuaRocks](https://github.com/luarocks/luarocks).\n\n```bash\nluarocks install --server=https://luarocks.org/dev luaformatter\n```\n\n### Build from source\n\n#### Requirements\n* cmake 3.9+\n* c++ 17 compiler\n\n#### Steps\n```bash\n    git clone --recurse-submodules https://github.com/Koihik/LuaFormatter.git\n    cd LuaFormatter\n    cmake .\n    make\n    make install\n```\n\n## Usage\n\n```\n  ./lua-format [Lua scripts...] {OPTIONS}\n\n    Reformats your Lua source code.\n\n  OPTIONS:\n\n      -h, --help                        Display this help menu\n      -v, --verbose                     Turn on verbose mode\n      -i                                Reformats in-place\n      --dump-config                     Dumps the default style used to stdout\n      -c[file], --config=[file]         Style config file\n      --column-limit=[column limit]     Column limit of one line\n      --indent-width=[indentation\n      width]                            Number of spaces used for indentation\n      --tab-width=[tab width]           Number of spaces used per tab\n      --continuation-indent-width=[Continuation\n      indentation width]                Indent width for continuations line\n      --spaces-before-call=[spaces\n      before call]                      Space on function calls\n      --column-table-limit=[column\n      table limit]                      Column limit of each line of a table\n      --table-sep=[table separator]     Character to separate table fields\n      --use-tab                         Use tab for indentation\n      --no-use-tab                      Do not use tab for indentation\n      --keep-simple-control-block-one-line\n                                        keep block in one line\n      --no-keep-simple-control-block-one-line\n                                        Do not keep block in one line\n      --keep-simple-function-one-line   keep function in one line\n      --no-keep-simple-function-one-line\n                                        Do not keep function in one line\n      --align-args                      Align the arguments\n      --no-align-args                   Do not align the arguments\n      --break-after-functioncall-lp     Break after '(' of function call\n      --no-break-after-functioncall-lp  Do not break after '(' of function call\n      --break-before-functioncall-rp    Break before ')' of function call\n      --no-break-before-functioncall-rp Do not break before ')' of function call\n      --align-parameter                 Align the parameters\n      --no-align-parameter              Do not align the parameters\n      --chop-down-parameter             Chop down all parameters\n      --no-chop-down-parameter          Do not chop down all parameters\n      --break-after-functiondef-lp      Break after '(' of function def\n      --no-break-after-functiondef-lp   Do not break after '(' of function def\n      --break-before-functiondef-rp     Break before ')' of function def\n      --no-break-before-functiondef-rp  Do not break before ')' of function def\n      --align-table-field               Align fields of table\n      --no-align-table-field            Do not align fields of table\n      --break-after-table-lb            Break after '{' of table\n      --no-break-after-table-lb         Do not break after '{' of table\n      --break-before-table-rb           Break before '}' of table\n      --no-break-before-table-rb        Do not break before '}' of table\n      --chop-down-table                 Chop down any table\n      --no-chop-down-table              Do not chop down any table\n      --chop-down-kv-table              Chop down table if table contains key\n      --no-chop-down-kv-table           Do not chop down table if table contains\n                                        key\n      --extra-sep-at-table-end          Add extra field separator at end of\n                                        table\n      --no-extra-sep-at-table-end       Do not add extra field separator at end\n                                        of table\n      --break-after-operator            Put break after operators\n      --no-break-after-operator         Do not put break after operators\n      --double-quote-to-single-quote    Transform string literals to use single\n                                        quote\n      --no-double-quote-to-single-quote Do not transform string literals to use\n                                        single quote\n      --single-quote-to-double-quote    Transform string literals to use double\n                                        quote\n      --no-single-quote-to-double-quote Do not transform string literals to use\n                                        double quote\n      --spaces-inside-functiondef-parens\n                                        Put spaces on the inside of parens in\n                                        function headers\n      --no-spaces-inside-functiondef-parens\n                                        Do not put spaces on the inside of\n                                        parens in function headers\n      --spaces-inside-functioncall-parens\n                                        Put spaces on the inside of parens in\n                                        function calls\n      --no-spaces-inside-functioncall-parens\n                                        Do not put spaces on the inside of\n                                        parens in function calls\n      --spaces-inside-table-braces      Put spaces on the inside of braces in\n                                        table constructors\n      --no-spaces-inside-table-braces   Do not put spaces on the inside of\n                                        braces in table constructors\n      --spaces-around-equals-in-field   Put spaces around the equal sign in\n                                        key/value fields\n      --no-spaces-around-equals-in-field\n                                        Do not put spaces around the equal sign\n                                        in key/value fields\n      --line-breaks-after-function-body\n                                        Line breakes after function body\n      --line-separator=[line separator] input(determined by the input content),\n                                        os(Use line ending of the current\n                                        Operating system), lf(Unix style \"\\n\"),\n                                        crlf(Windows style \"\\r\\n\"), cr(classic\n                                        Max style \"\\r\")\n      Lua scripts...                    Lua scripts to format\n      \"--\" can be used to terminate flag options and force all following\n      arguments to be treated as positional options\n```\n\nThe program will attempt to automatically use the current directory's `.lua-format` file if no config file is passed in the command line. If none is found, it will try to locate a `.lua-format` file in a parent directory recursively. On Linux it will use `$XDG_CONFIG_HOME/luaformatter/config.yaml` if `.lua-format` does not exist.\nIn case there's no file, it will fallback to the default configuration.\nThe program will give the top priority to the configuration values given in the command-line, then to the configuration files and finally to the hard-coded default values.\n\n### Style configure file\n\nConfiguration parameters not specified fallback to their default values.\n\nSee [this file](https://github.com/Koihik/LuaFormatter/blob/master/docs/Style-Config.md)\n\n### Default configuration\n\n```yaml\ncolumn_limit: 80\nindent_width: 4\nuse_tab: false\ntab_width: 4\ncontinuation_indent_width: 4\nspaces_before_call: 1\nkeep_simple_control_block_one_line: true\nkeep_simple_function_one_line: true\nalign_args: true\nbreak_after_functioncall_lp: false\nbreak_before_functioncall_rp: false\nspaces_inside_functioncall_parens: false\nspaces_inside_functiondef_parens: false\nalign_parameter: true\nchop_down_parameter: false\nbreak_after_functiondef_lp: false\nbreak_before_functiondef_rp: false\nalign_table_field: true\nbreak_after_table_lb: true\nbreak_before_table_rb: true\nchop_down_table: false\nchop_down_kv_table: true\ntable_sep: \",\"\ncolumn_table_limit: 0\nextra_sep_at_table_end: false\nspaces_inside_table_braces: false\nbreak_after_operator: true\ndouble_quote_to_single_quote: false\nsingle_quote_to_double_quote: false\nspaces_around_equals_in_field: true\nline_breaks_after_function_body: 1\nline_separator: input\n```\n### Disable formatting for a line or block\nSometimes it may be useful to disable automatic formatting. This is done be putting the code between `LuaFormatter off` and `LuaFormatter on` tags:\n\n```lua\n-- LuaFormatter off\nmatrix = {\n   {1, 0, 0, 0},\n   {1, 1, 0, 0},\n   {1, 1, 1, 0},\n   {1, 1, 1, 1}\n}\n-- LuaFormatter on\n```\n\n## Limitations\n\n* Do not work when source file contains syntax error\n* Do not support 'Format selection'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKoihik%2FLuaFormatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKoihik%2FLuaFormatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKoihik%2FLuaFormatter/lists"}