lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 27/09/2010 12:14, Jon Akhtar wrote:
I know that a lot of code formatting is a matter of personal taste, however, I
am developing a code formatter for Lua, and I am in need of a "default" format
to support "out of the box".

Tongue in cheek suggestion: take the Lua code written by Roberto and Luiz (or just the samples given in Programming in Lua) and use that as default style guide.

There are a lot of nuances to code formatting, and I'd like to cover as many as

Indeed. Somehow, Eclipse is doing a decent job there, offering an impressive set of options fitting probably 90% of the needs (except the most exotics).

for example spacing:

local a = {1,2,3}  vs  local a = {1, 2, 3}  vs. local a={1,2,3}

I would do: local a = { 1, 2, 3 }


local f = function()

I add a space there: local f = function ()
because I write the alternative: function f()
although, IIRC, R & L write: function f ()
to distinguish function declaration from function call (f() -- no space).

local f = function()

Ugly! Excessive indentation is, IMHO, a bad idea.

I'd like to get a discussion going on this topic.

Above shows that possibilities are endless (well, you guessed it!), and nobody is right (but some are wrong, eg. when forgetting they have a space key! ;-))
Well, such discussion is a bit of a Pandora box...

Incidentally, if you would like to try my code formatter its built into my
plugin for IntelliJ. Right now its still in development, but using it may aid in
the discussion.

Stupid question: I suppose a standalone version (even if it needs a JRE) is not possible? Installing a 100MB IDE to test your plugin is a bit overkill (even if as a Java programmer I would like to test IntelliJ, the free version, some day).

Philippe Lhoste
--  (near) Paris -- France
--  --  --  --  --  --  --  --  --  --  --  --  --  --