diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-08 19:49:15 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-08 19:49:15 +0800 |
commit | a452b6196ecad1d5812558a53a7808104ec40e9d (patch) | |
tree | b91791226f036f6914609a0aa6d8d4287a6aba0d | |
parent | c6e028f7eba7933bf1b6146284446dd9619da00f (diff) | |
download | lua-language-server-a452b6196ecad1d5812558a53a7808104ec40e9d.zip |
update config
-rw-r--r-- | script/config/template.lua | 20 | ||||
-rw-r--r-- | tools/configuration.lua | 29 |
2 files changed, 40 insertions, 9 deletions
diff --git a/script/config/template.lua b/script/config/template.lua index bea1dfa1..3e5b11a6 100644 --- a/script/config/template.lua +++ b/script/config/template.lua @@ -217,16 +217,28 @@ local template = { 'enable', 'disable', } - ), + ) + >> util.deepCopy(define.BuiltIn), ['Lua.diagnostics.enable'] = Type.Boolean >> true, ['Lua.diagnostics.globals'] = Type.Array(Type.String), ['Lua.diagnostics.disable'] = Type.Array(Type.String), - ['Lua.diagnostics.severity'] = Type.Hash(Type.String, Type.String) + ['Lua.diagnostics.severity'] = Type.Hash( + Type.String << util.getTableKeys(define.DiagnosticDefaultNeededFileStatus, true), + Type.String << { + 'Error', + 'Warning', + 'Information', + 'Hint', + } + ) >> util.deepCopy(define.DiagnosticDefaultSeverity), - ['Lua.diagnostics.neededFileStatus'] = Type.Hash(Type.String, Type.String) + ['Lua.diagnostics.neededFileStatus'] = Type.Hash( + Type.String << util.getTableKeys(define.DiagnosticDefaultNeededFileStatus, true), + Type.String << { 'Any', 'Opened', 'None' } + ) >> util.deepCopy(define.DiagnosticDefaultNeededFileStatus), ['Lua.diagnostics.disableScheme'] = Type.Array(Type.String) >> { 'git' }, - ['Lua.diagnostics.workspaceDelay'] = Type.Integer >> 5, + ['Lua.diagnostics.workspaceDelay'] = Type.Integer >> 3000, ['Lua.diagnostics.workspaceRate'] = Type.Integer >> 100, ['Lua.diagnostics.libraryFiles'] = Type.String >> 'Opened' << { 'Enable', diff --git a/tools/configuration.lua b/tools/configuration.lua index 953d5990..3609387d 100644 --- a/tools/configuration.lua +++ b/tools/configuration.lua @@ -59,10 +59,29 @@ local function insertArray(conf, temp) } end -local function insertHash(conf, temp) - conf.additionalProperties = false - if not temp.subkey.enums then - if temp.subvalue.enums then +local function insertHash(name, conf, temp) + conf.title = name:match '[^%.]+$' + + if type(conf.default) == 'table' and next(conf.default) then + conf.additionalProperties = false + local default = conf.default + conf.default = nil + conf.properties = {} + local descHead = name:gsub('^Lua', '%%config') + if util.stringStartWith(descHead, '%config.diagnostics') then + descHead = '%config.diagnostics' + end + for key, value in pairs(default) do + conf.properties[key] = { + type = getType( temp.subvalue), + default = value, + enum = getEnum( temp.subvalue), + description = descHead .. '.' .. key .. '%', + } + end + else + if temp.subvalue.enums then + conf.additionalProperties = false conf.patternProperties = { ['.*'] = { type = getType( temp.subvalue), @@ -95,7 +114,7 @@ for name, temp in pairs(template) do end if temp.name == 'Hash' then - insertHash(config[name], temp) + insertHash(name, config[name], temp) end ::CONTINUE:: |