Skip to content

Commit e1e142f

Browse files
committed
feature: support enable/disable code formatter.
1 parent 6bc3227 commit e1e142f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@
207207
"default": true,
208208
"description": "Keep diagnostic information after document closed."
209209
},
210+
"LuaCoderAssist.format.enable": {
211+
"type": "boolean",
212+
"default": true,
213+
"description": "Enable/Disable code formatter."
214+
},
210215
"LuaCoderAssist.format.lineWidth": {
211216
"type": "integer",
212217
"default": 120,

server/coder.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ class Coder {
2929
this.settings = {
3030
enable: true,
3131
debug: false,
32-
preloads:[],
32+
preloads: [],
3333
useLove: false,
3434
useJit: false,
3535
symbol: {
3636
showAnonymousFunction: true,
3737
showFunctionOnly: false,
3838
},
39-
luaPath:"",
39+
luaPath: "",
4040
luacheck: {
4141
enable: true,
4242
onSave: true,
@@ -60,6 +60,7 @@ class Coder {
6060
allowDefined: false
6161
},
6262
format: {
63+
enable: true,
6364
lineWidth: 120,
6465
indentCount: 4,
6566
quotemark: "single"

server/providers/format-provider.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class FormatProvider {
2525
let uri = params.textDocument.uri;
2626
let opt = this.coder.settings.format;
2727

28+
if (!opt.enable) {
29+
return [];
30+
}
31+
2832
let document = yield this.coder.document(uri);
2933

3034
let text

0 commit comments

Comments
 (0)