From 4d55cca4a73e9cb3a072562ecbd89ebf6c172c0b Mon Sep 17 00:00:00 2001 From: sumneko Date: Tue, 16 Apr 2019 15:31:34 +0800 Subject: =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 11 +++++++++++ server/src/config.lua | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/package.json b/package.json index 89e2de8e..2f23fe13 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,17 @@ ], "description": "Lua runtime version.\nLua运行版本。" }, + "Lua.runtime.path": { + "scope": "resource", + "type": "array", + "items": "string", + "description": "package.path", + "default": [ + "?.lua", + "?/init.lua", + "?/?.lua" + ] + }, "Lua.diagnostics.disable": { "scope": "resource", "type": "array", diff --git a/server/src/config.lua b/server/src/config.lua index c155eab2..125ac655 100644 --- a/server/src/config.lua +++ b/server/src/config.lua @@ -38,10 +38,34 @@ local function Str2Hash(sep) end end +local function Array(checker) + return function (tbl) + if type(tbl) ~= 'table' then + return false + end + local t = {} + for _, v in ipairs(tbl) do + local ok, result = checker(v) + if ok then + t[#t+1] = result + end + end + if #t == 0 then + return false + end + return true, t + end +end + local Template = { runtime = { version = {'Lua 5.3', String}, library = {{}, Str2Hash ';'}, + path = {{ + "?.lua", + "?/init.lua", + "?/?.lua" + }, Array(String)}, }, diagnostics = { globals = {{}, Str2Hash ';'}, -- cgit v1.2.3