Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wasm-fmt/lua_fmt

A WASM Based Lua Formatter
https://github.com/wasm-fmt/lua_fmt

Last synced: 3 days ago
JSON representation

A WASM Based Lua Formatter

Awesome Lists containing this project

README

        

[![Test](https://github.com/wasm-fmt/lua_fmt/actions/workflows/test.yml/badge.svg)](https://github.com/wasm-fmt/lua_fmt/actions/workflows/test.yml)

# Install

[![npm](https://img.shields.io/npm/v/@wasm-fmt/lua_fmt?color=000080)](https://www.npmjs.com/package/@wasm-fmt/lua_fmt)

```bash
npm install @wasm-fmt/lua_fmt
```

[![jsr.io](https://jsr.io/badges/@fmt/lua-fmt?color=000080)](https://jsr.io/@fmt/lua-fmt)

```bash
npx jsr add @fmt/lua-fmt
```

# Usage

```javascript
import init, { format } from "@wasm-fmt/lua_fmt";

await init();

const input = `print "Hello World"`;

const formatted = format(input, "main.lua");
console.log(formatted);
```

For Vite users:

Add `"@wasm-fmt/lua_fmt"` to `optimizeDeps.exclude` in your vite config:

```JSON
{
"optimizeDeps": {
"exclude": ["@wasm-fmt/lua_fmt"]
}
}
```

Or use another import entry:

```JavaScript
import init, { format } from "@wasm-fmt/lua_fmt/vite";

// ...
```

# Credits

Thanks to:

- The [StyLua](https://github.com/JohnnyMorganz/StyLua) project created by [@JohnnyMorganz](https://github.com/JohnnyMorganz)