[ANN] lua code formatter (lcf) 5.3-2

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] lua code formatter (lcf) 5.3-2

Martin
Hello list!

I've updated Lua code formatter, so now it keeps comments by default.

Requirements: Lua 5.3
License: GPLv3
Installation: sudo luarocks install lcf
Usage: lua.reformat <f_in> <f_out>

Project page: https://github.com/martin-eden/lua_code_formatter
Rockspecs: https://github.com/martin-eden/lua_code_formatter.rockspecs
Version: 5.3-2

That change required loseless Lua code parser. So now it's almost
trivial to write code highlighting and such things. For those who
interested, two shell commands provided: "lua.get_ast" and
"lua.get_formatter_ast". Both have format <f_in> <f_out> and
create file with table which represents raw AST from parser and
structured/simplified AST that is used by code formatter.

Feedback is welcome.

--[[
  There was some wishes from previous release like
    * do not export global functions
    * support command-line pipes
    * use standalone lexer
  They are not satisfied. Some I just can't implement, some I tend
  to keep because it's based on my code which I can easily reshape.
]]

-- Martin

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] lua code formatter (lcf) 5.3-2

Vadi
I'd be really interested in a Lua 5.1 version of this!

On Tue, Sep 26, 2017 at 6:18 AM Martin <[hidden email]> wrote:
Hello list!

I've updated Lua code formatter, so now it keeps comments by default.

Requirements: Lua 5.3
License: GPLv3
Installation: sudo luarocks install lcf
Usage: lua.reformat <f_in> <f_out>

Project page: https://github.com/martin-eden/lua_code_formatter
Rockspecs: https://github.com/martin-eden/lua_code_formatter.rockspecs
Version: 5.3-2

That change required loseless Lua code parser. So now it's almost
trivial to write code highlighting and such things. For those who
interested, two shell commands provided: "lua.get_ast" and
"lua.get_formatter_ast". Both have format <f_in> <f_out> and
create file with table which represents raw AST from parser and
structured/simplified AST that is used by code formatter.

Feedback is welcome.

--[[
  There was some wishes from previous release like
    * do not export global functions
    * support command-line pipes
    * use standalone lexer
  They are not satisfied. Some I just can't implement, some I tend
  to keep because it's based on my code which I can easily reshape.
]]

-- Martin

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] lua code formatter (lcf) 5.3-2

John Logsdon
+1

> I'd be really interested in a Lua 5.1 version of this!
>
> On Tue, Sep 26, 2017 at 6:18 AM Martin <[hidden email]>
> wrote:
>
>> Hello list!
>>
>> I've updated Lua code formatter, so now it keeps comments by default.
>>
>> Requirements: Lua 5.3
>> License: GPLv3
>> Installation: sudo luarocks install lcf
>> Usage: lua.reformat <f_in> <f_out>
>>
>> Project page: https://github.com/martin-eden/lua_code_formatter
>> Rockspecs: https://github.com/martin-eden/lua_code_formatter.rockspecs
>> Version: 5.3-2
>>
>> That change required loseless Lua code parser. So now it's almost
>> trivial to write code highlighting and such things. For those who
>> interested, two shell commands provided: "lua.get_ast" and
>> "lua.get_formatter_ast". Both have format <f_in> <f_out> and
>> create file with table which represents raw AST from parser and
>> structured/simplified AST that is used by code formatter.
>>
>> Feedback is welcome.
>>
>> --[[
>>   There was some wishes from previous release like
>>     * do not export global functions
>>     * support command-line pipes
>>     * use standalone lexer
>>   They are not satisfied. Some I just can't implement, some I tend
>>   to keep because it's based on my code which I can easily reshape.
>> ]]
>>
>> -- Martin
>>
>>
>


Best wishes

John

John Logsdon
Quantex Research Ltd
+44 161 445 4951/+44 7717758675


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] lua code formatter (lcf) 5.3-2

Vadim A. Misbakh-Soloviov
In reply to this post by Vadi
+1 from me too.

And it would be much better if it would also support being a pipe (reading
"in" file from stdin and printing it to stdout) in cli mode. Which is also not
that hard