summaryrefslogtreecommitdiff
path: root/script/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-12-02 14:22:46 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-12-02 14:22:46 +0800
commitba1f33f3ebde721148daba0b4cd7c5f8131ffc2d (patch)
tree1c03d231dc8a680c02f6ac662418df1a08858eeb /script/provider
parent90b538557cb305d53a64e240185675f9fc020d94 (diff)
downloadlua-language-server-ba1f33f3ebde721148daba0b4cd7c5f8131ffc2d.zip
#831
Diffstat (limited to 'script/provider')
-rw-r--r--script/provider/provider.lua41
1 files changed, 12 insertions, 29 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 8e64f5d3..addfe320 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -17,46 +17,29 @@ 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 merged = {}
-
- local cfg = cfgLoader.loadLocalConfig(CONFIGPATH)
- if cfg then
- log.debug('load config from local', CONFIGPATH)
- -- watch directory
- filewatch.watch(workspace.getAbsolutePath(CONFIGPATH):gsub('[^/\\]+$', ''))
- mergeConfig(merged, cfg)
+ local clientConfig = cfgLoader.loadClientConfig()
+ if clientConfig then
+ log.debug('load config from client')
+ config.update(clientConfig, json.null)
end
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)
+ config.update(rc, json.null)
end
- for k, v in pairs(merged) do
- if v == json.null then
- merged[k] = nil
- end
+ local cfg = cfgLoader.loadLocalConfig(CONFIGPATH)
+ if cfg then
+ log.debug('load config from local', CONFIGPATH)
+ -- watch directory
+ filewatch.watch(workspace.getAbsolutePath(CONFIGPATH):gsub('[^/\\]+$', ''))
+ config.update(cfg, json.null)
end
- config.update(merged)
- log.debug('loaded config dump:', util.dump(merged))
+ log.debug('loaded config dump:', util.dump(config.dump()))
end
---@class provider