You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/external_format/external_formatter_options_EN.md
+62-20Lines changed: 62 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,14 @@
1
-
# External Formatter Options
1
+
# External Formatter Tool Options
2
2
3
-
[中文版本](./external_formatter_options_CN.md)
3
+
[中文版](external_formatter_options_CN.md)
4
4
5
-
EmmyLua_ls supports using external formatting tools to format Lua code. By configuring the `.emmyrc.json` file, you can integrate any command-line code formatting tool.
5
+
EmmyLua_ls supports using external formatting tools to format Lua code. By configuring the `.emmyrc.json` file, you can integrate any code formatting tool that supports command line interface.
6
6
7
7
## Configuration Format
8
8
9
9
In the `.emmyrc.json` file, you can configure external formatting tools:
10
10
11
+
Document formatting configuration:
11
12
```json
12
13
{
13
14
"format" : {
@@ -22,33 +23,60 @@ In the `.emmyrc.json` file, you can configure external formatting tools:
22
23
}
23
24
}
24
25
}
26
+
27
+
```
28
+
Range formatting configuration:
29
+
```json
30
+
{
31
+
"format" : {
32
+
"externalToolRangeFormat": {
33
+
"program": "stylua",
34
+
"args": [
35
+
"-",
36
+
"--stdin-filepath",
37
+
"${file}",
38
+
"--indent-width=${indent_size}",
39
+
"--indent-type",
40
+
"${use_tabs?Tabs:Spaces}",
41
+
"--range-start=${start_offset}",
42
+
"--range-end=${end_offset}"
43
+
],
44
+
"timeout": 5000
45
+
}
46
+
}
47
+
}
25
48
```
26
49
50
+
27
51
## Configuration Options
28
52
29
53
-**program**: Path to the external formatting tool executable
30
-
-**args**: List of arguments to pass to the formatting tool
31
-
-**timeout**: Timeout for the formatting operation in milliseconds (default: 5000ms)
54
+
-**args**: List of arguments passed to the formatting tool
55
+
-**timeout**: Timeout for formatting operations (milliseconds), default is 5000ms
32
56
33
57
## Variable Substitution
34
58
35
-
In the `args`parameter, you can use the following variables, which will be replaced with actual values at runtime:
59
+
In the `args`parameters, you can use the following variables that will be replaced with actual values at runtime:
36
60
37
61
### Simple Variables
38
62
39
63
| Variable | Description | Example Value |
40
64
|----------|-------------|---------------|
41
-
|`${file}`| Full path to the current file |`/path/to/script.lua`|
65
+
|`${file}`| Full path of the current file |`/path/to/script.lua`|
42
66
|`${indent_size}`| Indentation size (number of spaces) |`4`|
67
+
|`${start_offset}`| Start UTF8 offset of the selected range |`0`|
68
+
|`${end_offset}`| End UTF8 offset of the selected range |`100`|
69
+
|`${start_line}`| Start line of the current file |`1`|
70
+
|`${end_line}`| End line of the current file |`10`|
43
71
44
72
### Conditional Variables
45
73
46
-
Conditional variables use the format `${variable?true_value:false_value}` to return different values based on conditions:
74
+
Conditional variables use the format `${variable?true_value:false_value}`, returning different values based on conditions:
0 commit comments