summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/config/loader.lua2
-rw-r--r--script/provider/provider.lua51
3 files changed, 35 insertions, 19 deletions
diff --git a/changelog.md b/changelog.md
index 9d0de779..55a7dfda 100644
--- a/changelog.md
+++ b/changelog.md
@@ -21,6 +21,7 @@
+ supports `---@param ... number`, equivalent to `---@vararg number`
+ supports `fun(...: string)`
+ supports `fun(x, y, ...)`, equivalent to `fun(x: any, y: any, ...: any)`
+* `CHG` settings from `--configpath`, `.luarc.json`, `client` no longer prevent subsequent settings, instead they are merged in order
* `CHG` no longer asks to trust plugin in VSCode, because VSCode already provides the workspace trust feature
* `CHG` skip huge files (>= 10 MB)
* `CHG` after using `Lua.runtime.nonstandardSymbol` to treat `//` as a comment, `//` is no longer parsed as an operator
diff --git a/script/config/loader.lua b/script/config/loader.lua
index e754be49..85193eb6 100644
--- a/script/config/loader.lua
+++ b/script/config/loader.lua
@@ -98,7 +98,7 @@ function m.loadClientConfig()
})
if not configs or not configs[1] then
log.warn('No config?', util.dump(configs))
- return
+ return nil
end
local newConfig = {
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index d732f3c2..2bda860c 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -15,33 +15,48 @@ local tm = require 'text-merger'
local cfgLoader = require 'config.loader'
local converter = require 'proto.converter'
local filewatch = require 'filewatch'
+local json = require 'json'
+
+local function mergeConfig(a, b)
+ for k, v in pairs(b) do
+ if a[k] == nil then
+ a[k] = v
+ end
+ end
+end
---@async
local function updateConfig()
- local new
+ local merged = {}
+
if CONFIGPATH then
- new = cfgLoader.loadLocalConfig(CONFIGPATH)
- config.setSource 'path'
+ local cfg = cfgLoader.loadLocalConfig(CONFIGPATH)
log.debug('load config from local', CONFIGPATH)
-- watch directory
filewatch.watch(workspace.getAbsolutePath(CONFIGPATH):gsub('[^/\\]+$', ''))
- else
- new = cfgLoader.loadRCConfig('.luarc.json')
- if new then
- config.setSource 'luarc'
- log.debug('load config from luarc')
- else
- new = cfgLoader.loadClientConfig()
- config.setSource 'client'
- log.debug('load config from client')
- end
+ mergeConfig(merged, cfg)
end
- if not new then
- log.warn('load config failed!')
- return
+
+ local rc = cfgLoader.loadRCConfig('.luarc.json')
+ if rc then
+ log.debug('load config from luarc')
+ mergeConfig(merged, rc)
+ end
+
+ local clientConfig = cfgLoader.loadClientConfig()
+ if clientConfig then
+ log.debug('load config from client')
+ mergeConfig(merged, clientConfig)
end
- config.update(new)
- log.debug('loaded config dump:', util.dump(new))
+
+ for k, v in pairs(merged) do
+ if v == json.null then
+ merged[k] = nil
+ end
+ end
+
+ config.update(merged)
+ log.debug('loaded config dump:', util.dump(merged))
end
---@class provider