lua-fmt
is pretty-printer for Lua code, written in TypeScript and deeply inspired by prettier. lua-fmt
provides an interface to format Lua code that conforms to a single and consistent standard.
While not implemented yet, the interface will be customizable to tailor the output to the user's preferences: linebreaks, string style, etc.
npm install lua-fmt
import {formatText} from 'lua-fmt';
console.log(formatText('local hello = "Hello"; print(hello .. " world!")'))
Format a single file:
luafmt test/lua-5.3.4-tests/calls.lua
Format a stream from stdin
:
cat test/lua-5.3.4-tests/calls.lua | luafmt --stdin
- Add support for a
.luafmt
preferences file
This project is licensed under the MIT License - see the LICENSE file for details.
- Oskar Schöldström - luaparse: A Lua parser written in JavaScript
- Christopher Chedeau - prettier: Prettier is an opinionated JavaScript formatter.
- Ben Newman - recast: JavaScript syntax tree transformer, nondestructive pretty-printer, and automatic source map generator.