LunaLua style guide
Jump to navigation
Jump to search
Whitespace
function foo(x, y) -- Spaces between arguments
-- Indent with tabs. Comments should match indentation.
local myVar = 1 --Optionally align. If aligning, use spaces.
local otherVar = 2
local someTbl = {
"tables split across",
"multiple lines should",
"look like this"
}
print(#someTbl) --No spaces after unary operators.
return x + myVar --Spaces between binary operators.
end
Comments
--------------------
-- SECTION HEADER --
--------------------
-- Prose comments on their own line should have a space after the --.
local x --This is optional for end-of-line comments, though these should always have space before the --.
-- Multi-line comments should generally still use line comment syntax
--- LDoc-compatible function description.
-- Optional additional description lines.
-- @param foo first parameter
-- @param bar second parameter
function doAThing(foo, bar)
return foo + bar
end
Miscellaneous
- Semicolons are discouraged.
- If using semicolons in a file, use consistently throughout entire file.