Skip to content

Commit 2703fd8

Browse files
committed
发布0.7.0
1 parent 3513cb8 commit 2703fd8

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

docs/format_action.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,33 @@ local d = {
100100
eee = 131231,
101101
}
102102
```
103+
## if语句对齐
104+
105+
lua没有switch语句,一般都是通过if/elseif模拟出一个匹配列表,对于其他有switch语句的语言,格式化会将case对齐,这里也支持这种行为:
106+
107+
```lua
108+
if aa.isDDDD()
109+
and bb == fwfwfw
110+
or hi == 123 then
111+
print(1313)
112+
elseif cc == 123
113+
or dd == 13131 and ddd == 123 then
114+
local ccc = 123
115+
end
116+
```
117+
会被格式化为:
118+
```lua
119+
if aa.isDDDD()
120+
and bb == fwfwfw
121+
or hi == 123 then
122+
print(1313)
123+
elseif cc == 123
124+
or dd == 13131 and ddd == 123 then
125+
local ccc = 123
126+
end
127+
```
128+
129+
该特性不是默认行为
103130

104131
## 长表达式列表
105132

docs/format_config.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,40 @@ and b then
464464
end
465465
```
466466

467+
## table_append_expression_no_space
468+
469+
该选项表示形如t[#t+1]的表达式,不会被格式化为t[#t + 1]
470+
471+
## if_condition_align_with_each_other
472+
473+
该选项表示if语句的条件表达式会互相对齐,该选项当且仅当存在 elseif语句时有效,并且该选项有效时,if语句的条件表达式一定会无缩进。
474+
互相对齐指的是像switch case一样排版:
475+
476+
```lua
477+
local t = {1,2,3}
478+
local c = {
479+
aaa, bbb, eee
480+
}
481+
local d = {
482+
aa =123,
483+
bbbb = 4353,
484+
eee = 131231,
485+
}
486+
```
487+
488+
格式化后:
489+
490+
```lua
491+
local t = { 1, 2, 3 }
492+
local c = {
493+
aaa, bbb, eee
494+
}
495+
local d = {
496+
aa = 123,
497+
bbbb = 4353,
498+
eee = 131231,
499+
}
500+
```
467501

468502
## end_of_line
469503

docs/format_config_EN.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,41 @@ and b then
466466
end
467467
```
468468

469+
## table_append_expression_no_space
470+
471+
This option represents an expression of the form t[#t+1], which will not be formatted as t[#t + 1]
472+
473+
##if_condition_align_with_each_other
474+
475+
This option means that the conditional expressions of the if statement will be aligned with each other. This option is valid if and only if there is an elseif statement, and when this option is valid, the conditional expressions of the if statement must be without indentation.
476+
Alignment with each other refers to typesetting like a switch case:
477+
478+
````lua
479+
local t = {1,2,3}
480+
local c = {
481+
aaa, bbb, eee
482+
}
483+
local d = {
484+
aa =123,
485+
bbbb = 4353,
486+
eee = 131231,
487+
}
488+
````
489+
490+
After formatting:
491+
492+
````lua
493+
local t = { 1, 2, 3 }
494+
local c = {
495+
aaa, bbb, eee
496+
}
497+
local d = {
498+
aa = 123,
499+
bbbb = 4353,
500+
eee = 131231,
501+
}
502+
````
503+
469504
## end_of_line
470505

471506
This option represents the symbol at the end of the line, the default is crlf, and it can also be lf

lua.template.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ do_statement_no_indent = false
4343
if_condition_no_continuation_indent = false
4444
# if true, t[#t+1] will not space wrapper '+'
4545
table_append_expression_no_space = false
46-
46+
# if statement will align like switch case
47+
if_condition_align_with_each_other = false
4748
# optional crlf/lf
4849
end_of_line = crlf
4950

0 commit comments

Comments
 (0)