From 3e0577f4ef0d8efdaeb0167551882eb9877af95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 8 Mar 2021 11:34:51 +0800 Subject: `Lua.workspace.library` use `path[]` instead of `` --- script/config.lua | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'script/config.lua') diff --git a/script/config.lua b/script/config.lua index 3d8b9fda..18525c13 100644 --- a/script/config.lua +++ b/script/config.lua @@ -44,6 +44,25 @@ local function Str2Hash(sep) end end +local function Array2Hash(checker) + return function (tbl) + if type(tbl) ~= 'table' then + return false + end + local t = {} + if #tbl > 0 then + for _, k in ipairs(tbl) do + t[k] = true + end + else + for k, v in pairs(tbl) do + t[k] = v + end + end + return true, t + end +end + local function Array(checker) return function (tbl) if type(tbl) ~= 'table' then @@ -129,10 +148,7 @@ local ConfigTemplate = { useGitIgnore = {true, Boolean}, maxPreload = {1000, Integer}, preloadFileSize = {100, Integer}, - library = {{}, Hash( - String, - Or(Boolean, Array(String)) - )} + library = {{}, Array2Hash(String)}, }, completion = { enable = {true, Boolean}, -- cgit v1.2.3