Skip to content

Commit fa6fe05

Browse files
committed
更新文档
1 parent 5d30402 commit fa6fe05

File tree

3 files changed

+271
-13
lines changed

3 files changed

+271
-13
lines changed

docs/format_config.md

Lines changed: 140 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ end
1919

2020
--use tab
2121
function ff()
22-
local t = 123
23-
local c = 456
22+
local t = 123
23+
local c = 456
2424
end
2525
```
2626

@@ -104,6 +104,22 @@ if aaa == 123
104104
or bbb == 456 then
105105
end
106106
```
107+
## local_assign_continuation_align_to_first_expression
108+
109+
该参数表示local或者赋值语句的右表达式列表,如果存在不止一行则对齐到首个表达式,例如:
110+
```lua
111+
local t = aaa,bbb,ccc,
112+
ddd,eee,fff
113+
```
114+
会被格式化为
115+
```lua
116+
local t = aaa,bbb,ccc,
117+
ddd,eee,fff
118+
```
119+
120+
当该选项有效时,continuation_indent_size选项对local和赋值语句无效。
121+
当表达式列表中出现跨行表达式,例如跨行定义的function 和 table,则该选项无效。
122+
107123

108124
## align_call_args
109125

@@ -130,7 +146,9 @@ helloWorld(aaa, bbb, ccc,
130146

131147
```
132148

133-
## keep_one_space_between_call_args_and_bracket
149+
当调用参数列表中出现跨行表达式时,该选项定义的行为无效
150+
151+
## keep_one_space_between_call_args_and_parentheses
134152

135153
该选项表示函数调用表达式的参数和左右括号之间是否保持一个空格,选项默认值是false
136154

@@ -147,7 +165,7 @@ print(123,456)
147165
格式化后:
148166

149167
```lua
150-
--keep_one_space_between_call_args_and_bracket = true
168+
--keep_one_space_between_call_args_and_parentheses = true
151169

152170
helloWorld( aaa, bbb, ccc,
153171
eee, ddd )
@@ -259,6 +277,26 @@ local t2 = { aaa, bbbb,
259277
}
260278
```
261279

280+
## keep_one_space_between_namedef_and_attribute
281+
282+
该选项表示local语句的名称列表中的名称定义和他的attribute之间保持一个空格。
283+
284+
格式化前:
285+
```lua
286+
local t<const> = 1
287+
```
288+
289+
格式化后:
290+
291+
```lua
292+
local t <const> = 1
293+
```
294+
295+
## max_continuous_line_distance
296+
297+
该选项表示连续行的定义,它的值决定行之间的间距小于等于多少时为同一连续。
298+
299+
262300
## continuous_assign_statement_align_to_equal_sign
263301

264302
该选项表示连续赋值语句的首行语句如果等号与左边符号相距大于一个空格,则对齐到连续赋值语句的等号最大的位置,该选项默认值为true.
@@ -291,7 +329,9 @@ eeeeeeeee = 654 -- this is a comment2
291329

292330
-- no continuous
293331
local c = 132
332+
```
294333

334+
```lua
295335
-- false
296336
local t = 123
297337
local cccc = 456
@@ -335,6 +375,96 @@ local t = {
335375
}
336376
```
337377

378+
## weak_alignment_rule
379+
380+
该选项表示是否为弱对齐规则,如果是,则连续local/赋值语句的等号中任意一个与左边的元素大于一个空格则该连续语句会对齐到等号
381+
382+
## label_no_indent
383+
384+
该选项表示标签无缩进。
385+
386+
格式化前:
387+
```lua
388+
function fff()
389+
390+
for i=1,2,3 do
391+
if true then
392+
goto continue
393+
end
394+
395+
::continue::
396+
end
397+
398+
end
399+
```
400+
格式化后:
401+
```lua
402+
function fff()
403+
404+
for i=1,2,3 do
405+
if true then
406+
goto continue
407+
end
408+
409+
::continue::
410+
end
411+
412+
end
413+
```
414+
## do_statement_no_indent
415+
416+
该选项表示do语句块内无缩进。
417+
418+
419+
格式化前:
420+
```lua
421+
function fff()
422+
do
423+
for i=1,2,3 do
424+
if true then
425+
goto continue
426+
end
427+
428+
::continue::
429+
end
430+
end
431+
end
432+
```
433+
格式化后:
434+
```lua
435+
function fff()
436+
do
437+
for i=1,2,3 do
438+
if true then
439+
goto continue
440+
end
441+
442+
::continue::
443+
end
444+
end
445+
end
446+
```
447+
448+
## if_condition_no_continuation_indent
449+
450+
该选项表示if语句的条件表达式如果跨行,则无需缩进。
451+
452+
格式化前:
453+
```lua
454+
if a
455+
and b then
456+
457+
end
458+
```
459+
格式化后:
460+
```lua
461+
if a
462+
and b then
463+
464+
end
465+
```
466+
467+
338468
## end_of_line
339469

340470
该选项表示行尾的符号,默认为crlf,也可选为lf
@@ -345,13 +475,13 @@ local t = {
345475

346476
这些选项名称和默认值分别是:
347477
```
348-
keep_line_after_if_statement = minLine:1
349-
keep_line_after_do_statement = minLine:1
350-
keep_line_after_while_statement = minLine:1
351-
keep_line_after_repeat_statement = minLine:1
352-
keep_line_after_for_statement = minLine:1
478+
keep_line_after_if_statement = minLine:0
479+
keep_line_after_do_statement = minLine:0
480+
keep_line_after_while_statement = minLine:0
481+
keep_line_after_repeat_statement = minLine:0
482+
keep_line_after_for_statement = minLine:0
353483
keep_line_after_local_or_assign_statement = keepLine
354-
keep_line_after_function_define_statement = keepLine:1
484+
keep_line_after_function_define_statement = keepLine:0
355485
```
356486

357487
所有选项支持三种值表达:

docs/format_config_EN.md

Lines changed: 130 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ if aaa == 123
106106
end
107107
```
108108

109+
## local_assign_continuation_align_to_first_expression
110+
111+
This parameter represents a list of local or right expressions of an assignment statement. If there is more than one line, it will be aligned to the first expression, for example:
112+
````lua
113+
local t = aaa,bbb,ccc,
114+
ddd,eee,fff
115+
````
116+
will be formatted as
117+
````lua
118+
local t = aaa,bbb,ccc,
119+
ddd,eee,fff
120+
````
121+
122+
When this option is in effect, the continuation_indent_size option has no effect on local and assignment statements.
123+
When a cross-line expression appears in the expression list, such as function and table defined across lines, this option is invalid.
124+
109125
## align_call_args
110126

111127
This parameter indicates whether the calling parameter is aligned to the first parameter, the default value is false
@@ -130,7 +146,9 @@ helloWorld(aaa, bbb, ccc,
130146

131147
```
132148

133-
## keep_one_space_between_call_args_and_bracket
149+
The behavior defined by this option has no effect when a cross-line expression appears in the call parameter list
150+
151+
## keep_one_space_between_call_args_and_parentheses
134152

135153
This option indicates whether there is a space between the parameters of the function call expression and the left and right parentheses. The default value of the option is false
136154

@@ -147,7 +165,7 @@ print(123,456)
147165
after formatting:
148166

149167
```lua
150-
--keep_one_space_between_call_args_and_bracket = true
168+
--keep_one_space_between_call_args_and_parentheses = true
151169

152170
helloWorld( aaa, bbb, ccc,
153171
eee, ddd )
@@ -262,6 +280,25 @@ local t2 = { aaa, bbbb,
262280
}
263281
```
264282

283+
## keep_one_space_between_namedef_and_attribute
284+
285+
This option indicates that a space should be maintained between the name definition in the name list of the local statement and its attribute.
286+
287+
Before formatting:
288+
````lua
289+
local t<const> = 1
290+
````
291+
292+
After formatting:
293+
294+
````lua
295+
local t <const> = 1
296+
````
297+
298+
## max_continuous_line_distance
299+
300+
This option indicates the definition of continuous lines, and its value determines the same continuous when the spacing between lines is less than or equal to how much.
301+
265302
## continuous_assign_statement_align_to_equal_sign
266303

267304
This option means that if the first line of the continuous assignment statement is more than one space between the equal sign and the left symbol, it will be aligned to the largest equal sign of the continuous assignment statement. The default value of this option is true.
@@ -294,7 +331,9 @@ eeeeeeeee = 654 -- this is a comment2
294331

295332
-- no continuous
296333
local c = 132
334+
```
297335

336+
```lua
298337
-- false
299338
local t = 123
300339
local cccc = 456
@@ -338,6 +377,95 @@ local t = {
338377
}
339378
```
340379

380+
## weak_alignment_rule
381+
382+
This option indicates whether it is a weak alignment rule. If so, if any of the equal signs of the continuous local/assignment statement and the element to the left are greater than one space, the continuous statement will be aligned to the equal sign
383+
384+
## label_no_indent
385+
386+
This option means that the labels are not indented.
387+
388+
Before formatting:
389+
````lua
390+
function fff()
391+
392+
for i=1,2,3 do
393+
if true then
394+
goto continue
395+
end
396+
397+
::continue::
398+
end
399+
400+
end
401+
````
402+
After formatting:
403+
````lua
404+
function fff()
405+
406+
for i=1,2,3 do
407+
if true then
408+
goto continue
409+
end
410+
411+
::continue::
412+
end
413+
414+
end
415+
````
416+
## do_statement_no_indent
417+
418+
This option means no indentation inside the do statement block.
419+
420+
421+
Before formatting:
422+
```lua
423+
function fff()
424+
do
425+
for i=1,2,3 do
426+
if true then
427+
goto continue
428+
end
429+
430+
::continue::
431+
end
432+
end
433+
end
434+
```
435+
After formatting:
436+
```lua
437+
function fff()
438+
do
439+
for i=1,2,3 do
440+
if true then
441+
goto continue
442+
end
443+
444+
::continue::
445+
end
446+
end
447+
end
448+
```
449+
450+
## if_condition_no_continuation_indent
451+
452+
This option indicates that the conditional expression of the if statement does not need to be indented if it spans lines.
453+
454+
Before formatting:
455+
```lua
456+
if a
457+
and b then
458+
459+
end
460+
```
461+
After formatting:
462+
```lua
463+
if a
464+
and b then
465+
466+
end
467+
```
468+
341469
## end_of_line
342470

343471
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if_condition_no_continuation_indent = false
4646
# optional crlf/lf
4747
end_of_line = crlf
4848

49-
# [Row layout]
49+
# [line layout]
5050
# The following configuration supports three expressions
5151
# minLine:${n}
5252
# keepLine

0 commit comments

Comments
 (0)