Skip to content

Commit a452b61

Browse files
committed
update config
1 parent c6e028f commit a452b61

File tree

2 files changed

+40
-9
lines changed

2 files changed

+40
-9
lines changed

script/config/template.lua

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,28 @@ local template = {
217217
'enable',
218218
'disable',
219219
}
220-
),
220+
)
221+
>> util.deepCopy(define.BuiltIn),
221222
['Lua.diagnostics.enable'] = Type.Boolean >> true,
222223
['Lua.diagnostics.globals'] = Type.Array(Type.String),
223224
['Lua.diagnostics.disable'] = Type.Array(Type.String),
224-
['Lua.diagnostics.severity'] = Type.Hash(Type.String, Type.String)
225+
['Lua.diagnostics.severity'] = Type.Hash(
226+
Type.String << util.getTableKeys(define.DiagnosticDefaultNeededFileStatus, true),
227+
Type.String << {
228+
'Error',
229+
'Warning',
230+
'Information',
231+
'Hint',
232+
}
233+
)
225234
>> util.deepCopy(define.DiagnosticDefaultSeverity),
226-
['Lua.diagnostics.neededFileStatus'] = Type.Hash(Type.String, Type.String)
235+
['Lua.diagnostics.neededFileStatus'] = Type.Hash(
236+
Type.String << util.getTableKeys(define.DiagnosticDefaultNeededFileStatus, true),
237+
Type.String << { 'Any', 'Opened', 'None' }
238+
)
227239
>> util.deepCopy(define.DiagnosticDefaultNeededFileStatus),
228240
['Lua.diagnostics.disableScheme'] = Type.Array(Type.String) >> { 'git' },
229-
['Lua.diagnostics.workspaceDelay'] = Type.Integer >> 5,
241+
['Lua.diagnostics.workspaceDelay'] = Type.Integer >> 3000,
230242
['Lua.diagnostics.workspaceRate'] = Type.Integer >> 100,
231243
['Lua.diagnostics.libraryFiles'] = Type.String >> 'Opened' << {
232244
'Enable',

tools/configuration.lua

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,29 @@ local function insertArray(conf, temp)
5959
}
6060
end
6161

62-
local function insertHash(conf, temp)
63-
conf.additionalProperties = false
64-
if not temp.subkey.enums then
65-
if temp.subvalue.enums then
62+
local function insertHash(name, conf, temp)
63+
conf.title = name:match '[^%.]+$'
64+
65+
if type(conf.default) == 'table' and next(conf.default) then
66+
conf.additionalProperties = false
67+
local default = conf.default
68+
conf.default = nil
69+
conf.properties = {}
70+
local descHead = name:gsub('^Lua', '%%config')
71+
if util.stringStartWith(descHead, '%config.diagnostics') then
72+
descHead = '%config.diagnostics'
73+
end
74+
for key, value in pairs(default) do
75+
conf.properties[key] = {
76+
type = getType( temp.subvalue),
77+
default = value,
78+
enum = getEnum( temp.subvalue),
79+
description = descHead .. '.' .. key .. '%',
80+
}
81+
end
82+
else
83+
if temp.subvalue.enums then
84+
conf.additionalProperties = false
6685
conf.patternProperties = {
6786
['.*'] = {
6887
type = getType( temp.subvalue),
@@ -95,7 +114,7 @@ for name, temp in pairs(template) do
95114
end
96115

97116
if temp.name == 'Hash' then
98-
insertHash(config[name], temp)
117+
insertHash(name, config[name], temp)
99118
end
100119

101120
::CONTINUE::

0 commit comments

Comments
 (0)