summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/settings.json4
-rw-r--r--script/config/config.lua (renamed from script/config.lua)14
-rw-r--r--script/config/init.lua3
-rw-r--r--script/config/loader.lua47
-rw-r--r--script/core/completion.lua22
-rw-r--r--script/core/diagnostics/deprecated.lua6
-rw-r--r--script/core/diagnostics/init.lua6
-rw-r--r--script/core/diagnostics/lowercase-global.lua2
-rw-r--r--script/core/diagnostics/undefined-global.lua4
-rw-r--r--script/core/hint.lua6
-rw-r--r--script/core/hover/description.lua4
-rw-r--r--script/core/hover/label.lua2
-rw-r--r--script/core/hover/table.lua2
-rw-r--r--script/core/infer.lua4
-rw-r--r--script/files.lua14
-rw-r--r--script/library.lua12
-rw-r--r--script/plugin.lua4
-rw-r--r--script/progress.lua4
-rw-r--r--script/provider/diagnostic.lua12
-rw-r--r--script/provider/provider.lua11
-rw-r--r--script/service/telemetry.lua6
-rw-r--r--script/vm/getDocs.lua2
-rw-r--r--script/workspace/workspace.lua18
-rw-r--r--test.lua4
-rw-r--r--test/completion/init.lua8
-rw-r--r--test/crossfile/completion.lua12
-rw-r--r--test/crossfile/definition.lua12
-rw-r--r--test/diagnostics/init.lua14
-rw-r--r--test/full/example.lua2
-rw-r--r--test/full/init.lua4
-rw-r--r--test/full/projects.lua4
-rw-r--r--test/type_inference/init.lua8
32 files changed, 166 insertions, 111 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 51e4b3fb..ec0e4bde 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -15,7 +15,8 @@
"LOCALE",
"SHOWSOURCE",
"TRACE",
- "FOOTPRINT"
+ "FOOTPRINT",
+ "CONFIGPATH"
],
"Lua.diagnostics.disable": [
"close-non-object",
@@ -38,6 +39,7 @@
"E:/Github/test",
// Just some comment
"script/meta",
+ "bin",
],
"Lua.runtime.path": [
"?.lua",
diff --git a/script/config.lua b/script/config/config.lua
index 1287681c..8a69b234 100644
--- a/script/config.lua
+++ b/script/config/config.lua
@@ -207,15 +207,15 @@ local OtherTemplate = {
}
local function init()
- if m.config then
+ if m.Lua then
return
end
- m.config = {}
+ m.Lua = {}
for c, t in pairs(ConfigTemplate) do
- m.config[c] = {}
+ m.Lua[c] = {}
for k, info in pairs(t) do
- m.config[c][k] = info[1]
+ m.Lua[c][k] = info[1]
end
end
@@ -236,9 +236,9 @@ function m.setConfig(config, other)
if info then
local suc, v = info[2](v)
if suc then
- m.config[c][k] = v
+ m.Lua[c][k] = v
else
- m.config[c][k] = info[1]
+ m.Lua[c][k] = info[1]
end
end
end
@@ -255,7 +255,7 @@ function m.setConfig(config, other)
end
end
end
- log.debug('Config update: ', util.dump(m.config), util.dump(m.other))
+ log.debug('Config update: ', util.dump(m.Lua), util.dump(m.other))
end, log.error)
end
diff --git a/script/config/init.lua b/script/config/init.lua
new file mode 100644
index 00000000..32387226
--- /dev/null
+++ b/script/config/init.lua
@@ -0,0 +1,3 @@
+local config = require 'config.config'
+
+return config
diff --git a/script/config/loader.lua b/script/config/loader.lua
new file mode 100644
index 00000000..4159547e
--- /dev/null
+++ b/script/config/loader.lua
@@ -0,0 +1,47 @@
+local fs = require 'bee.filesystem'
+local fsu = require 'fs-utility'
+local json = require 'json'
+local proto = require 'proto'
+local lang = require 'language'
+local config = require 'config.Lua'
+
+local function errorMessage(msg)
+ proto.notify('window/showMessage', {
+ type = 3,
+ message = msg,
+ })
+end
+
+local m = {}
+
+function m.loadLocalConfig(filename)
+ local path = fs.path(filename)
+ local ext = path:extension():string():lower()
+ local buf = fsu.loadFile(path)
+ if not buf then
+ errorMessage(lang.script('无法读取设置文件:{}', filename))
+ return
+ end
+ if ext == '.json' then
+ local suc, res = pcall(json.decode, buf)
+ if not suc then
+ errorMessage(lang.script('设置文件加载错误:{}', res))
+ return
+ end
+ return res
+ elseif ext == '.lua' then
+ local suc, res = pcall(function ()
+ assert(load(buf, '@' .. filename, 't'))()
+ end)
+ if not suc then
+ errorMessage(lang.script('设置文件加载错误:{}', res))
+ return
+ end
+ return res
+ else
+ errorMessage(lang.script('设置文件必须是lua或json格式:{}', filename))
+ return
+ end
+end
+
+return m
diff --git a/script/core/completion.lua b/script/core/completion.lua
index 97984299..47155e57 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -145,7 +145,7 @@ local function buildDetail(source)
end
local function getSnip(source)
- local context = config.config.completion.displayContext
+ local context = config.Lua.completion.displayContext
if context <= 0 then
return nil
end
@@ -187,7 +187,7 @@ local function buildDesc(source)
end
local function buildFunction(results, source, value, oop, data)
- local snipType = config.config.completion.callSnippet
+ local snipType = config.Lua.completion.callSnippet
if snipType == 'Disable' or snipType == 'Both' then
results[#results+1] = data
end
@@ -220,7 +220,7 @@ local function buildInsertRequire(ast, targetUri, stemName)
end
end
local path = furi.decode(targetUri)
- local visiblePaths = rpath.getVisiblePath(path, config.config.runtime.path, true)
+ local visiblePaths = rpath.getVisiblePath(path, config.Lua.runtime.path, true)
if not visiblePaths or #visiblePaths == 0 then
return nil
end
@@ -311,7 +311,7 @@ local function checkLocal(ast, word, offset, results)
end
local function checkModule(ast, word, offset, results)
- if not config.config.completion.autoRequire then
+ if not config.Lua.completion.autoRequire then
return
end
local locals = guide.getVisibleLocals(ast.ast, offset)
@@ -325,7 +325,7 @@ local function checkModule(ast, word, offset, results)
local stemName = fileName:gsub('%..+', '')
if not locals[stemName]
and not vm.hasGlobalSets(stemName)
- and not config.config.diagnostics.globals[stemName]
+ and not config.Lua.diagnostics.globals[stemName]
and stemName:match '^[%a_][%w_]*$'
and matchKey(word, stemName) then
local targetAst = files.getState(uri)
@@ -409,8 +409,8 @@ local function checkFieldFromFieldToIndex(name, parent, word, start, offset)
}
end
else
- if config.config.runtime.version == 'Lua 5.1'
- or config.config.runtime.version == 'LuaJIT' then
+ if config.Lua.runtime.version == 'Lua 5.1'
+ or config.Lua.runtime.version == 'LuaJIT' then
textEdit.newText = '_G' .. textEdit.newText
else
textEdit.newText = '_ENV' .. textEdit.newText
@@ -494,7 +494,7 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res
goto CONTINUE
end
local funcLabel
- if config.config.completion.showParams then
+ if config.Lua.completion.showParams then
local value = searcher.getObjectValue(src) or src
if value.type == 'function'
or value.type == 'doc.type.function' then
@@ -594,7 +594,7 @@ local function checkCommon(myUri, word, text, offset, results)
for _, data in ipairs(keyWordMap) do
used[data[1]] = true
end
- if config.config.completion.workspaceWord and #word >= 2 then
+ if config.Lua.completion.workspaceWord and #word >= 2 then
local myHead = word:sub(1, 2)
for uri in files.eachFile() do
if #results >= 100 then
@@ -681,7 +681,7 @@ local function isInString(ast, offset)
end
local function checkKeyWord(ast, text, start, offset, word, hasSpace, afterLocal, results)
- local snipType = config.config.completion.keywordSnippet
+ local snipType = config.Lua.completion.keywordSnippet
local symbol = lookBackward.findSymbol(text, start - 1)
local isExp = symbol == '(' or symbol == ',' or symbol == '='
local info = {
@@ -865,7 +865,7 @@ local function checkUri(ast, text, offset, results)
goto CONTINUE
end
local path = workspace.getRelativePath(uri)
- local infos = rpath.getVisiblePath(path, config.config.runtime.path)
+ local infos = rpath.getVisiblePath(path, config.Lua.runtime.path)
for _, info in ipairs(infos) do
if matchKey(literal, info.expect) then
if not collect[info.expect] then
diff --git a/script/core/diagnostics/deprecated.lua b/script/core/diagnostics/deprecated.lua
index d6265f64..5c2933f9 100644
--- a/script/core/diagnostics/deprecated.lua
+++ b/script/core/diagnostics/deprecated.lua
@@ -27,10 +27,10 @@ return function (uri, callback)
if not key then
return
end
- if config.config.diagnostics.globals[key] then
+ if config.Lua.diagnostics.globals[key] then
return
end
- if config.config.runtime.special[key] then
+ if config.Lua.runtime.special[key] then
return
end
end
@@ -75,7 +75,7 @@ return function (uri, callback)
end
table.sort(versions)
if #versions > 0 then
- message = ('%s(%s)'):format(message, lang.script('DIAG_DEFINED_VERSION', table.concat(versions, '/'), config.config.runtime.version))
+ message = ('%s(%s)'):format(message, lang.script('DIAG_DEFINED_VERSION', table.concat(versions, '/'), config.Lua.runtime.version))
end
end
diff --git a/script/core/diagnostics/init.lua b/script/core/diagnostics/init.lua
index 0a04ad91..5a070360 100644
--- a/script/core/diagnostics/init.lua
+++ b/script/core/diagnostics/init.lua
@@ -20,13 +20,13 @@ table.sort(diagList, function (a, b)
end)
local function check(uri, name, results)
- if config.config.diagnostics.disable[name] then
+ if config.Lua.diagnostics.disable[name] then
return
end
- local level = config.config.diagnostics.severity[name]
+ local level = config.Lua.diagnostics.severity[name]
or define.DiagnosticDefaultSeverity[name]
- local neededFileStatus = config.config.diagnostics.neededFileStatus[name]
+ local neededFileStatus = config.Lua.diagnostics.neededFileStatus[name]
or define.DiagnosticDefaultNeededFileStatus[name]
if neededFileStatus == 'None' then
diff --git a/script/core/diagnostics/lowercase-global.lua b/script/core/diagnostics/lowercase-global.lua
index cba33459..967a9737 100644
--- a/script/core/diagnostics/lowercase-global.lua
+++ b/script/core/diagnostics/lowercase-global.lua
@@ -24,7 +24,7 @@ return function (uri, callback)
end
local definedGlobal = {}
- for name in pairs(config.config.diagnostics.globals) do
+ for name in pairs(config.Lua.diagnostics.globals) do
definedGlobal[name] = true
end
diff --git a/script/core/diagnostics/undefined-global.lua b/script/core/diagnostics/undefined-global.lua
index c53029ba..01caa7d2 100644
--- a/script/core/diagnostics/undefined-global.lua
+++ b/script/core/diagnostics/undefined-global.lua
@@ -25,10 +25,10 @@ return function (uri, callback)
if not key then
return
end
- if config.config.diagnostics.globals[key] then
+ if config.Lua.diagnostics.globals[key] then
return
end
- if config.config.runtime.special[key] then
+ if config.Lua.runtime.special[key] then
return
end
local node = src.node
diff --git a/script/core/hint.lua b/script/core/hint.lua
index 67c725f7..857ae510 100644
--- a/script/core/hint.lua
+++ b/script/core/hint.lua
@@ -29,11 +29,11 @@ local function typeHint(uri, edits, start, finish)
return
end
if source.parent.type == 'funcargs' then
- if not config.config.hint.paramType then
+ if not config.Lua.hint.paramType then
return
end
else
- if not config.config.hint.setType then
+ if not config.Lua.hint.setType then
return
end
end
@@ -96,7 +96,7 @@ local function hasLiteralArgInCall(call)
end
local function paramName(uri, edits, start, finish)
- if not config.config.hint.paramName then
+ if not config.Lua.hint.paramName then
return
end
local ast = files.getState(uri)
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index bcc3065a..431fa619 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -59,11 +59,11 @@ end
local function asStringView(source, literal)
-- 内部包含转义符?
local rawLen = source.finish - source.start - 2 * #source[2] + 1
- if config.config.hover.viewString
+ if config.Lua.hover.viewString
and (source[2] == '"' or source[2] == "'")
and rawLen > #literal then
local view = literal
- local max = config.config.hover.viewStringMax
+ local max = config.Lua.hover.viewStringMax
if #view > max then
view = view:sub(1, max) .. '...'
end
diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua
index d3715a35..cda2af65 100644
--- a/script/core/hover/label.lua
+++ b/script/core/hover/label.lua
@@ -157,7 +157,7 @@ local function formatNumber(n)
end
local function asNumber(source)
- if not config.config.hover.viewNumber then
+ if not config.Lua.hover.viewNumber then
return nil
end
local num = source[1]
diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua
index eb5faa9f..f064c99a 100644
--- a/script/core/hover/table.lua
+++ b/script/core/hover/table.lua
@@ -91,7 +91,7 @@ local function getKeyMap(fields)
end
return function (source)
- local maxFields = config.config.hover.previewFields
+ local maxFields = config.Lua.hover.previewFields
if maxFields <= 0 then
return 'table'
end
diff --git a/script/core/infer.lua b/script/core/infer.lua
index 4bd8d40e..06839dd2 100644
--- a/script/core/infer.lua
+++ b/script/core/infer.lua
@@ -217,7 +217,7 @@ local function bindClassOrType(source)
end
local function cleanInfers(infers)
- local version = config.config.runtime.version
+ local version = config.Lua.runtime.version
local enableInteger = version == 'Lua 5.3' or version == 'Lua 5.4'
infers['unknown'] = nil
if infers['any'] and infers['nil'] then
@@ -305,7 +305,7 @@ function m.viewInfers(infers)
return sa < sb
end
end)
- local limit = config.config.hover.enumsLimit
+ local limit = config.Lua.hover.enumsLimit
if limit < 0 then
limit = 0
end
diff --git a/script/files.lua b/script/files.lua
index bcab7462..494bdb9f 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -164,7 +164,7 @@ function m.setText(uri, text, isTrust, instance)
return
end
if not isTrust and unicode then
- if config.config.runtime.fileEncoding == 'ansi' then
+ if config.Lua.runtime.fileEncoding == 'ansi' then
text = unicode.a2u(text)
end
end
@@ -393,7 +393,7 @@ end
function m.compileState(uri, text)
local ws = require 'workspace'
- if not m.isOpen(uri) and #text >= config.config.workspace.preloadFileSize * 1000 then
+ if not m.isOpen(uri) and #text >= config.Lua.workspace.preloadFileSize * 1000 then
if not m.notifyCache['preloadFileSize'] then
m.notifyCache['preloadFileSize'] = {}
m.notifyCache['skipLargeFileCount'] = 0
@@ -406,7 +406,7 @@ function m.compileState(uri, text)
type = 3,
message = lang.script('WORKSPACE_SKIP_LARGE_FILE'
, ws.getRelativePath(m.getOriginUri(uri))
- , config.config.workspace.preloadFileSize
+ , config.Lua.workspace.preloadFileSize
, #text / 1000
),
})
@@ -419,11 +419,11 @@ function m.compileState(uri, text)
local clock = os.clock()
local state, err = parser:compile(text
, 'lua'
- , config.config.runtime.version
+ , config.Lua.runtime.version
, {
- special = config.config.runtime.special,
- unicodeName = config.config.runtime.unicodeName,
- nonstandardSymbol = config.config.runtime.nonstandardSymbol,
+ special = config.Lua.runtime.special,
+ unicodeName = config.Lua.runtime.unicodeName,
+ nonstandardSymbol = config.Lua.runtime.nonstandardSymbol,
delay = await.delay,
}
)
diff --git a/script/library.lua b/script/library.lua
index 80622f73..c4308289 100644
--- a/script/library.lua
+++ b/script/library.lua
@@ -10,7 +10,7 @@ local define = require "proto.define"
local m = {}
local function getDocFormater()
- local version = config.config.runtime.version
+ local version = config.Lua.runtime.version
if client.isVSCode() then
if version == 'Lua 5.1' then
return 'HOVER_NATIVE_DOCUMENT_LUA51'
@@ -94,11 +94,11 @@ local function compileSingleMetaDoc(script, metaLang, status)
middleBuf[#middleBuf+1] = ('PUSH [===[%s]===]'):format(script:sub(last))
local middleScript = table.concat(middleBuf, '\n')
local version, jit
- if config.config.runtime.version == 'LuaJIT' then
+ if config.Lua.runtime.version == 'LuaJIT' then
version = 5.1
jit = true
else
- version = tonumber(config.config.runtime.version:sub(-3))
+ version = tonumber(config.Lua.runtime.version:sub(-3))
jit = false
end
@@ -194,8 +194,8 @@ end
local function compileMetaDoc()
local langID = lang.id
- local version = config.config.runtime.version
- local metaPath = fs.path(METAPATH) / config.config.runtime.meta:gsub('%$%{(.-)%}', {
+ local version = config.Lua.runtime.version
+ local metaPath = fs.path(METAPATH) / config.Lua.runtime.meta:gsub('%$%{(.-)%}', {
version = version,
language = langID,
})
@@ -212,7 +212,7 @@ local function compileMetaDoc()
local out = fsu.dummyFS()
local templateDir = ROOT / 'meta' / 'template'
for libName, status in pairs(define.BuiltIn) do
- status = config.config.runtime.builtin[libName] or status
+ status = config.Lua.runtime.builtin[libName] or status
if status == 'disable' then
goto CONTINUE
end
diff --git a/script/plugin.lua b/script/plugin.lua
index c55960a1..a3eaf92b 100644
--- a/script/plugin.lua
+++ b/script/plugin.lua
@@ -49,11 +49,11 @@ function m.init()
end
end
- if not config.config.runtime.plugin or config.config.runtime.plugin == '' then
+ if not config.Lua.runtime.plugin or config.Lua.runtime.plugin == '' then
return
end
- local pluginPath = fs.path(config.config.runtime.plugin)
+ local pluginPath = fs.path(config.Lua.runtime.plugin)
if pluginPath:is_relative() then
if not ws.path then
return
diff --git a/script/progress.lua b/script/progress.lua
index 3e630289..c16ddd3d 100644
--- a/script/progress.lua
+++ b/script/progress.lua
@@ -83,7 +83,7 @@ function mt:_update()
and self._clock + self._delay <= os.clock() then
self._updated = os.clock()
self._dirty = false
- if not config.config.window.progressBar then
+ if not config.Lua.window.progressBar then
return
end
proto.request('window/workDoneProgress/create', {
@@ -106,7 +106,7 @@ function mt:_update()
if not self._showed then
return
end
- if not config.config.window.progressBar then
+ if not config.Lua.window.progressBar then
self:remove()
return
end
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 30efe53e..d461ed3c 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -26,7 +26,7 @@ local function buildSyntaxError(uri, err)
local message = lang.script('PARSER_'..err.type, err.info)
if err.version then
- local version = err.info and err.info.version or config.config.runtime.version
+ local version = err.info and err.info.version or config.Lua.runtime.version
message = message .. ('(%s)'):format(lang.script('DIAG_NEED_VERSION'
, concat(err.version, '/')
, version
@@ -151,7 +151,7 @@ function m.syntaxErrors(uri, ast)
local results = {}
for _, err in ipairs(ast.errs) do
- if not config.config.diagnostics.disable[err.type:lower():gsub('_', '-')] then
+ if not config.Lua.diagnostics.disable[err.type:lower():gsub('_', '-')] then
results[#results+1] = buildSyntaxError(uri, err)
end
end
@@ -179,7 +179,7 @@ function m.diagnostics(uri, diags)
end
function m.doDiagnostic(uri)
- if not config.config.diagnostics.enable then
+ if not config.Lua.diagnostics.enable then
return
end
uri = files.asKey(uri)
@@ -302,14 +302,14 @@ local function askForDisable()
end
function m.diagnosticsAll()
- if not config.config.diagnostics.enable then
+ if not config.Lua.diagnostics.enable then
m.clearAll()
return
end
if not m._start then
return
end
- local delay = config.config.diagnostics.workspaceDelay / 1000
+ local delay = config.Lua.diagnostics.workspaceDelay / 1000
if delay < 0 then
return
end
@@ -361,7 +361,7 @@ function m.checkWorkspaceDiag()
if not await.hasID 'diagnosticsAll' then
return
end
- local speedRate = config.config.diagnostics.workspaceRate
+ local speedRate = config.Lua.diagnostics.workspaceRate
if speedRate <= 0 or speedRate >= 100 then
return
end
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 0249ffca..33404886 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -61,10 +61,10 @@ local function updateConfig()
acceptSuggestionOnEnter = configs[5],
}
- local oldConfig = util.deepCopy(config.config)
+ local oldConfig = util.deepCopy(config.Lua)
local oldOther = util.deepCopy(config.other)
config.setConfig(updated, other)
- local newConfig = config.config
+ local newConfig = config.Lua
local newOther = config.other
if not util.equal(oldConfig.runtime, newConfig.runtime) then
@@ -166,6 +166,9 @@ proto.on('shutdown', function ()
end)
proto.on('workspace/didChangeConfiguration', function ()
+ if CONFIGPATH then
+ return
+ end
updateConfig()
end)
@@ -595,7 +598,7 @@ proto.on('completionItem/resolve', function (item)
end)
proto.on('textDocument/signatureHelp', function (params)
- if not config.config.signatureHelp.enable then
+ if not config.Lua.signatureHelp.enable then
return nil
end
workspace.awaitReady()
@@ -892,7 +895,7 @@ do
local function updateHint(uri)
local awaitID = 'hint:' .. uri
await.close(awaitID)
- if not config.config.hint.enable then
+ if not config.Lua.hint.enable then
return
end
await.setID(awaitID)
diff --git a/script/service/telemetry.lua b/script/service/telemetry.lua
index 30b26586..19fe86f1 100644
--- a/script/service/telemetry.lua
+++ b/script/service/telemetry.lua
@@ -65,7 +65,7 @@ end
timer.wait(5, function ()
timer.loop(300, function ()
- if not config.config.telemetry.enable then
+ if not config.Lua.telemetry.enable then
return
end
local suc, link = pcall(net.connect, 'tcp', 'moe-moe.love', 11577)
@@ -83,7 +83,7 @@ timer.wait(5, function ()
end
end)()
timer.loop(1, function ()
- if not config.config.telemetry.enable then
+ if not config.Lua.telemetry.enable then
return
end
net.update()
@@ -93,7 +93,7 @@ end)
local m = {}
function m.updateConfig()
- if config.config.telemetry.enable ~= nil then
+ if config.Lua.telemetry.enable ~= nil then
return
end
if m.hasShowedMessage then
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua
index 79e60fed..dd21c965 100644
--- a/script/vm/getDocs.lua
+++ b/script/vm/getDocs.lua
@@ -135,7 +135,7 @@ local function isDeprecated(value)
return true
elseif doc.type == 'doc.version' then
local valids = vm.getValidVersions(doc)
- if not valids[config.config.runtime.version] then
+ if not valids[config.Lua.runtime.version] then
value._deprecated = true
return true
end
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index e92870c1..ae3af6d4 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -77,7 +77,7 @@ function m.getNativeMatcher()
local pattern = {}
-- config.workspace.ignoreDir
- for path in pairs(config.config.workspace.ignoreDir) do
+ for path in pairs(config.Lua.workspace.ignoreDir) do
log.info('Ignore directory:', path)
pattern[#pattern+1] = path
end
@@ -89,7 +89,7 @@ function m.getNativeMatcher()
end
end
-- config.workspace.ignoreSubmodules
- if config.config.workspace.ignoreSubmodules then
+ if config.Lua.workspace.ignoreSubmodules then
local buf = pub.awaitTask('loadFile', furi.encode(m.path .. '/.gitmodules'))
if buf then
for path in buf:gmatch('path = ([^\r\n]+)') do
@@ -99,7 +99,7 @@ function m.getNativeMatcher()
end
end
-- config.workspace.useGitIgnore
- if config.config.workspace.useGitIgnore then
+ if config.Lua.workspace.useGitIgnore then
local buf = pub.awaitTask('loadFile', furi.encode(m.path .. '/.gitignore'))
if buf then
for line in buf:gmatch '[^\r\n]+' do
@@ -120,7 +120,7 @@ function m.getNativeMatcher()
end
end
-- config.workspace.library
- for path in pairs(config.config.workspace.library) do
+ for path in pairs(config.Lua.workspace.library) do
path = path:gsub('${(.-)}', {
meta = (ROOT / 'meta' / '3rd'):string(),
})
@@ -142,7 +142,7 @@ function m.getLibraryMatchers()
end
local librarys = {}
- for path in pairs(config.config.workspace.library) do
+ for path in pairs(config.Lua.workspace.library) do
path = path:gsub('${(.-)}', {
meta = (ROOT / 'meta' / '3rd'):string(),
})
@@ -183,12 +183,12 @@ local function loadFileFactory(root, progressData, isLibrary)
return function (path)
local uri = furi.encode(path)
if files.isLua(uri) then
- if not isLibrary and progressData.preload >= config.config.workspace.maxPreload then
+ if not isLibrary and progressData.preload >= config.Lua.workspace.maxPreload then
if not m.hasHitMaxPreload then
m.hasHitMaxPreload = true
proto.request('window/showMessageRequest', {
type = define.MessageType.Info,
- message = lang.script('MWS_MAX_PRELOAD', config.config.workspace.maxPreload),
+ message = lang.script('MWS_MAX_PRELOAD', config.Lua.workspace.maxPreload),
actions = {
{
title = lang.script.WINDOW_INCREASE_UPPER_LIMIT,
@@ -207,7 +207,7 @@ local function loadFileFactory(root, progressData, isLibrary)
data = {
key = 'Lua.workspace.maxPreload',
action = 'set',
- value = config.config.workspace.maxPreload + math.max(1000, config.config.workspace.maxPreload),
+ value = config.Lua.workspace.maxPreload + math.max(1000, config.Lua.workspace.maxPreload),
}
})
end
@@ -415,7 +415,7 @@ function m.findUrisByRequirePath(path)
local input = path:gsub('%.', '/')
:gsub('%%', '%%%%')
- for _, luapath in ipairs(config.config.runtime.path) do
+ for _, luapath in ipairs(config.Lua.runtime.path) do
local part = m.normalize(luapath:gsub('%?', input))
local uris, posts = m.findUrisByFilePath(part)
for _, uri in ipairs(uris) do
diff --git a/test.lua b/test.lua
index 3f2cf2cd..44b3c45b 100644
--- a/test.lua
+++ b/test.lua
@@ -86,8 +86,8 @@ local function main()
require 'utility'.enableCloseFunction()
local config = require 'config'
- config.config.runtime.version = 'Lua 5.4'
- --config.config.intelliSense.searchDepth = 5
+ config.Lua.runtime.version = 'Lua 5.4'
+ --config.Lua.intelliSense.searchDepth = 5
loadDocMetas()
--test 'full'
diff --git a/test/completion/init.lua b/test/completion/init.lua
index 4a04ecc5..ca88af07 100644
--- a/test/completion/init.lua
+++ b/test/completion/init.lua
@@ -109,9 +109,9 @@ function TEST(script)
end
end
-config.config.completion.callSnippet = 'Both'
-config.config.completion.keywordSnippet = 'Both'
-config.config.completion.workspaceWord = false
+config.Lua.completion.callSnippet = 'Both'
+config.Lua.completion.keywordSnippet = 'Both'
+config.Lua.completion.workspaceWord = false
TEST [[
local zabcde
@@ -920,7 +920,7 @@ print(io.$)
]]
(EXISTS)
-require 'config' .config.runtime.version = 'Lua 5.4'
+require 'config' .Lua.runtime.version = 'Lua 5.4'
--TEST [[
--local $
--]]
diff --git a/test/crossfile/completion.lua b/test/crossfile/completion.lua
index 15ce3440..3be26b5a 100644
--- a/test/crossfile/completion.lua
+++ b/test/crossfile/completion.lua
@@ -359,8 +359,8 @@ TEST {
}
-local originRuntimePath = config.config.runtime.path
-config.config.runtime.path = {
+local originRuntimePath = config.Lua.runtime.path
+config.Lua.runtime.path = {
'?/1.lua',
}
@@ -388,10 +388,10 @@ TEST {
}
}
-config.config.runtime.path = originRuntimePath
+config.Lua.runtime.path = originRuntimePath
-local originRuntimePath = config.config.runtime.path
-config.config.runtime.path = {
+local originRuntimePath = config.Lua.runtime.path
+config.Lua.runtime.path = {
'd:/?/1.lua',
}
@@ -414,7 +414,7 @@ TEST {
}
}
-config.config.runtime.path = originRuntimePath
+config.Lua.runtime.path = originRuntimePath
TEST {
{
diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua
index d1b613cc..cbb5f7fe 100644
--- a/test/crossfile/definition.lua
+++ b/test/crossfile/definition.lua
@@ -730,8 +730,8 @@ TEST {
}
platform.OS = originOS
-local originRuntimePath = config.config.runtime.path
-config.config.runtime.path = {
+local originRuntimePath = config.Lua.runtime.path
+config.Lua.runtime.path = {
'?/1.lua',
}
TEST {
@@ -749,10 +749,10 @@ TEST {
]],
},
}
-config.config.runtime.path = originRuntimePath
+config.Lua.runtime.path = originRuntimePath
-local originRuntimePath = config.config.runtime.path
-config.config.runtime.path = {
+local originRuntimePath = config.Lua.runtime.path
+config.Lua.runtime.path = {
'D:/?/1.lua',
}
TEST {
@@ -770,7 +770,7 @@ TEST {
]],
},
}
-config.config.runtime.path = originRuntimePath
+config.Lua.runtime.path = originRuntimePath
TEST {
{
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index b00a4e21..cb314691 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -4,7 +4,7 @@ local config = require 'config'
local util = require 'utility'
local define = require 'proto.define'
-config.config.diagnostics.neededFileStatus['deprecated'] = 'Any'
+config.Lua.diagnostics.neededFileStatus['deprecated'] = 'Any'
rawset(_G, 'TEST', true)
@@ -206,7 +206,7 @@ local _ENV = { print = print }
print(1)
]]
-config.config.diagnostics.disable['undefined-env-child'] = true
+config.Lua.diagnostics.disable['undefined-env-child'] = true
TEST [[
_ENV = nil
<!GLOBAL!> = 1 --> _ENV.GLOBAL = 1
@@ -232,7 +232,7 @@ GLOBAL = 1
_ENV = nil
]]
-config.config.diagnostics.disable['undefined-env-child'] = nil
+config.Lua.diagnostics.disable['undefined-env-child'] = nil
TEST [[
<!print()
('string')!>:sub(1, 1)
@@ -344,17 +344,17 @@ return [[
]]
]=]
-config.config.diagnostics.disable['close-non-object'] = true
+config.Lua.diagnostics.disable['close-non-object'] = true
TEST [[
local _ <close> = function () end
]]
-config.config.diagnostics.disable['close-non-object'] = nil
+config.Lua.diagnostics.disable['close-non-object'] = nil
TEST [[
local _ <close> = <!1!>
]]
-config.config.diagnostics.disable['unused-local'] = true
+config.Lua.diagnostics.disable['unused-local'] = true
TEST [[
local f = <!function () end!>
]]
@@ -367,7 +367,7 @@ TEST [[
local <!function f() end!>
]]
-config.config.diagnostics.disable['unused-local'] = nil
+config.Lua.diagnostics.disable['unused-local'] = nil
TEST [[
local mt, x
function mt:m()
diff --git a/test/full/example.lua b/test/full/example.lua
index 8633318a..86f89935 100644
--- a/test/full/example.lua
+++ b/test/full/example.lua
@@ -9,7 +9,7 @@ local noder = require 'core.noder'
-- 临时
local function testIfExit(path)
- config.config.workspace.preloadFileSize = 1000000000
+ config.Lua.workspace.preloadFileSize = 1000000000
local buf = util.loadFile(path:string())
if buf then
local vm
diff --git a/test/full/init.lua b/test/full/init.lua
index 3831a5f1..1f36f3bb 100644
--- a/test/full/init.lua
+++ b/test/full/init.lua
@@ -11,9 +11,9 @@ function TEST(script)
end
local function startCollectDiagTimes()
- for name in pairs(config.config.diagnostics.neededFileStatus) do
+ for name in pairs(config.Lua.diagnostics.neededFileStatus) do
if name ~= 'no-implicit-any' then
- --config.config.diagnostics.neededFileStatus[name] = 'Any'
+ --config.Lua.diagnostics.neededFileStatus[name] = 'Any'
end
end
DIAGTIMES = {}
diff --git a/test/full/projects.lua b/test/full/projects.lua
index b2e6d3cc..b9b3187c 100644
--- a/test/full/projects.lua
+++ b/test/full/projects.lua
@@ -6,8 +6,8 @@ local config = require 'config'
local ws = require 'workspace'
local fs = require 'bee.filesystem'
-config.config.workspace.preloadFileSize = 1000000
-config.config.diagnostics.neededFileStatus = {}
+config.Lua.workspace.preloadFileSize = 1000000
+config.Lua.diagnostics.neededFileStatus = {}
local function doProjects(pathname)
files.removeAll()
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index f2fd8dd7..1d52ecc8 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -748,25 +748,25 @@ TEST 'function' [[
string.gsub():gsub():<?gsub?>()
]]
-config.config.hover.enumsLimit = 5
+config.Lua.hover.enumsLimit = 5
TEST 'a|b|c|d|e...(+5)' [[
---@type 'a'|'b'|'c'|'d'|'e'|'f'|'g'|'h'|'i'|'j'
local <?t?>
]]
-config.config.hover.enumsLimit = 1
+config.Lua.hover.enumsLimit = 1
TEST 'a...(+9)' [[
---@type 'a'|'b'|'c'|'d'|'e'|'f'|'g'|'h'|'i'|'j'
local <?t?>
]]
-config.config.hover.enumsLimit = 0
+config.Lua.hover.enumsLimit = 0
TEST '...(+10)' [[
---@type 'a'|'b'|'c'|'d'|'e'|'f'|'g'|'h'|'i'|'j'
local <?t?>
]]
-config.config.hover.enumsLimit = 5
+config.Lua.hover.enumsLimit = 5
TEST 'string|fun():string' [[
---@type string | fun(): string