lua code formatter
Table of Contents
1 概述
lua_code_formatter 是一个 lua 代码格式化工具。
调整代码行以适合给定的边距。
格式化后,含有无效 Lua 语法的文件可能会丢失内容!在运行重新格式化之前验证文件的正确性: luac -p <lua_file>
。
2 安装
luarocks install lcf
安装脚本将部署三个命令行脚本:
lua.reformat lua.get_ast lua.get_formatter_ast
3 使用
lua.reformat [options] [lua_file]> [out_file]
不带参数调用将显示可用的命令行参数。
例如:
lua.reformat --indent=' ' test.lua
3.1 options
--indent=<str> Use given string as indent chunk. --right-margin=<int> Right margin, including indent part. --max-text-width=<int> Maximum text length, excluding indent part. --keep-comments Keep comments. --~keep-comments Remove comments. --keep-unparsed-tail Keep unparsed file end. --~keep-unparsed-tail Remove unparsed file end.
3.2 out_file
如果使用 out_file 参数,必须与 lua_file 不同。