Single-file Version of Lua Auto-indent Processing

2018-08-02 04:31Edit this page

I found a script at https://www.oschina.net/code/snippet_563463_19381 that uses Perl regex to auto-indent Lua files. The approach seemed good - a single file can do simple automatic indentation. But after searching GitHub for a long time, I couldn’t find any related Lua standalone project code.

Side note about LuaRocks: to use scripts installed by LuaRocks, you need to have LuaRocks installed on the machine. So even if you resolve dependencies when packaging by calling LuaRocks, it won’t work unless you add LuaRocks to the dependencies. This is very unfriendly for someone like me with a standalone obsession.

I rewrote the Perl version of auto-indent into a Lua version. The regex uses ngx.re from OpenResty, and it needs to be started using the resty command line or within openresty (two startup methods).

https://github.com/xiaocang/lua-resty-luatidy

Unless otherwise stated, articles on this blog are licensed under the Creative Commons Attribution 4.0 International License. Please credit the original author and source when sharing.


Tags: lua

No comments yet

Leave a comment

Creative Commons © 2013 — 2025 xiaocang | Theme based on fzheng.me & NexT | Hosted by Netlify