Skip to content

Commit

Permalink
Code formatting rules: newline, variables, comments
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Stoletov <[email protected]>
  • Loading branch information
irvis committed Feb 13, 2021
1 parent b987129 commit 0885dc0
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@

## Code formatting rules

### Variables

The option alignment.variables will be align list of variables.

```lua
local a = 1 -- comment
local bb = 22 -- comment

local c = "short text" -- comment
```

### Comments

Skipped space between a double hyphen and text will be revert. Semantic line
(only hyphens) will not has the space.

```lua
--------------------------------
-- Description
-- params: - input
-- - output
```

### Tables

If you create an empty table or with only field key or
Expand Down Expand Up @@ -52,3 +75,56 @@ local t = {
-- comment
}
```

### Newline

If return statement inside block with other statements.

```lua
function isFalse()
return false
end

function calc(a, b)
local c = a + b

return c
end
```

A function with other statements.

```lua
function isFalse()
return false
end

isFalse()
```

If a function has parameters more max line length.

```lua
function very_long_name(
very_long_name_parameter_1,
very_long_name_parameter_2,
very_long_name_parameter_3
)
-- stuff
end
```

If a function call has parameters more max line length.

```lua
very_long_name_function_call(
{a = 1, b = 2, c = 3},
very_long_name_parameter,
{
a = 1,
b = 2,
c = 3,
d = 4,
}
)
```

0 comments on commit 0885dc0

Please sign in to comment.