summaryrefslogtreecommitdiff
path: root/script/config.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-20 21:55:41 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-20 21:55:41 +0800
commitc63b2e404d8d2bb984afe3678a5ba2b2836380cc (patch)
treea70661effacc7a29caa8d49583673ac4be2faaf5 /script/config.lua
parent85c5a4210e4447422cd5677369ae740ed65725a0 (diff)
downloadlua-language-server-c63b2e404d8d2bb984afe3678a5ba2b2836380cc.zip
remove the old version
Diffstat (limited to 'script/config.lua')
-rw-r--r--script/config.lua218
1 files changed, 0 insertions, 218 deletions
diff --git a/script/config.lua b/script/config.lua
deleted file mode 100644
index 8011b905..00000000
--- a/script/config.lua
+++ /dev/null
@@ -1,218 +0,0 @@
-local DiagnosticDefaultSeverity = require 'constant.DiagnosticDefaultSeverity'
-
-local function Boolean(v)
- if type(v) == 'boolean' then
- return true, v
- end
- return false
-end
-
-local function Integer(v)
- if type(v) == 'number' then
- return true, math.floor(v)
- end
- return false
-end
-
-local function String(v)
- return true, tostring(v)
-end
-
-local function Str2Hash(sep)
- return function (v)
- if type(v) == 'string' then
- local t = {}
- for s in v:gmatch('[^'..sep..']+') do
- t[s] = true
- end
- return true, t
- end
- if type(v) == 'table' then
- local t = {}
- for _, s in ipairs(v) do
- if type(s) == 'string' then
- t[s] = true
- end
- end
- return true, t
- end
- return false
- 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
- return true, t
- end
-end
-
-local function Hash(keyChecker, valueChecker)
- return function (tbl)
- if type(tbl) ~= 'table' then
- return false
- end
- local t = {}
- for k, v in pairs(tbl) do
- local ok1, key = keyChecker(k)
- local ok2, value = valueChecker(v)
- if ok1 and ok2 then
- t[key] = value
- end
- end
- if not next(t) then
- return false
- end
- return true, t
- end
-end
-
-local function Or(...)
- local checkers = {...}
- return function (obj)
- for _, checker in ipairs(checkers) do
- local suc, res = checker(obj)
- if suc then
- return true, res
- end
- end
- return false
- end
-end
-
-local ConfigTemplate = {
- runtime = {
- version = {'Lua 5.4', String},
- library = {{}, Str2Hash ';'},
- path = {{
- "?.lua",
- "?/init.lua",
- "?/?.lua"
- }, Array(String)},
- special = {{}, Hash(String, String)},
- },
- diagnostics = {
- enable = {true, Boolean},
- globals = {{}, Str2Hash ';'},
- disable = {{}, Str2Hash ';'},
- severity = {
- table.deepCopy(DiagnosticDefaultSeverity),
- Hash(String, String),
- },
- workspaceDelay = {0, Integer},
- workspaceRate = {100, Integer},
- },
- workspace = {
- ignoreDir = {{}, Str2Hash ';'},
- ignoreSubmodules= {true, Boolean},
- useGitIgnore = {true, Boolean},
- maxPreload = {1000, Integer},
- preloadFileSize = {100, Integer},
- library = {{}, Hash(
- String,
- Or(Boolean, Array(String))
- )}
- },
- completion = {
- enable = {true, Boolean},
- callSnippet = {'Disable', String},
- keywordSnippet = {'Replace', String},
- displayContext = {6, Integer},
- },
- signatureHelp = {
- enable = {true, Boolean},
- },
- hover = {
- enable = {true, Boolean},
- viewString = {true, Boolean},
- viewStringMax = {1000, Integer},
- viewNumber = {true, Boolean},
- fieldInfer = {3000, Integer},
- },
- color = {
- mode = {'Semantic', String},
- },
- luadoc = {
- enable = {true, Boolean},
- },
- plugin = {
- enable = {false, Boolean},
- path = {'.vscode/lua-plugin/*.lua', String},
- },
- intelliSense = {
- searchDepth = {0, Integer},
- fastGlobal = {true, Boolean},
- },
-}
-
-local OtherTemplate = {
- associations = {{}, Hash(String, String)},
- exclude = {{}, Hash(String, Boolean)},
-}
-
-local Config, Other
-
-local function init()
- if Config then
- return
- end
-
- Config = {}
- for c, t in pairs(ConfigTemplate) do
- Config[c] = {}
- for k, info in pairs(t) do
- Config[c][k] = info[1]
- end
- end
-
- Other = {}
- for k, info in pairs(OtherTemplate) do
- Other[k] = info[1]
- end
-end
-
-local function setConfig(self, config, other)
- xpcall(function ()
- for c, t in pairs(config) do
- for k, v in pairs(t) do
- local region = ConfigTemplate[c]
- if region then
- local info = region[k]
- local suc, v = info[2](v)
- if suc then
- Config[c][k] = v
- else
- Config[c][k] = info[1]
- end
- end
- end
- end
- for k, v in pairs(other) do
- local info = OtherTemplate[k]
- local suc, v = info[2](v)
- if suc then
- Other[k] = v
- else
- Other[k] = info[1]
- end
- end
- log.debug('Config update: ', table.dump(Config), table.dump(Other))
- end, log.error)
-end
-
-init()
-
-return {
- setConfig = setConfig,
- config = Config,
- other = Other,
-}