diff options
author | sumneko <sumneko@hotmail.com> | 2021-11-27 02:26:55 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2021-11-27 02:26:55 +0800 |
commit | 08b963cfe8ffea36529b58d56708492aad04d254 (patch) | |
tree | 6312934d7e62a851660620791ef73aeb7a8cb273 /script/provider/provider.lua | |
parent | ed27fb8fac021f77b4824f1a0068a97fe801c7bf (diff) | |
download | lua-language-server-08b963cfe8ffea36529b58d56708492aad04d254.zip |
stash
Diffstat (limited to 'script/provider/provider.lua')
-rw-r--r-- | script/provider/provider.lua | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 7c453315..8d945696 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -16,49 +16,43 @@ 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 +local scope = require 'workspace.scope' ---@async local function updateConfig() - local cfg = cfgLoader.loadLocalConfig(CONFIGPATH) - if cfg then - log.debug('load config from local', CONFIGPATH) + local specified = cfgLoader.loadLocalConfig(CONFIGPATH) + if specified then + log.debug('Load config from specified', CONFIGPATH) + log.debug(util.dump(specified)) -- watch directory filewatch.watch(workspace.getAbsolutePath(CONFIGPATH):gsub('[^/\\]+$', '')) - config.update('specified', nil, cfg) + config.update(scope.override, specified, json.null) + else + config.update(scope.override, {}, json.null) end - for _, folder in ipairs(workspace.folders) do + for _, folder in ipairs(scope.folders) do local uri = folder.uri - local folderConfig = {} - local rc = cfgLoader.loadRCConfig(uri, '.luarc.json') - if rc then - log.debug('load config from luarc') - mergeConfig(folderConfig, rc) - end local clientConfig = cfgLoader.loadClientConfig(uri) if clientConfig then - log.debug('load config from client') - mergeConfig(folderConfig, clientConfig) + log.debug('Load config from client', uri) + log.debug(util.dump(clientConfig)) + config.update(folder, clientConfig, json.null) end - end - for k, v in pairs(baseConfig) do - if v == json.null then - baseConfig[k] = nil + local rc = cfgLoader.loadRCConfig(uri, '.luarc.json') + if rc then + log.debug('Load config from luarc.json', uri) + log.debug(util.dump(rc)) + config.update(folder, rc, json.null) end end - config.update('global', workspace.rootUri,baseConfig) - log.debug('loaded config dump:', util.dump(baseConfig)) + local global = cfgLoader.loadClientConfig() + log.debug('Load config from client', 'fallback') + log.debug(util.dump(global)) + config.update(scope.fallback, global, json.null) end ---@class provider @@ -88,7 +82,6 @@ end) m.register 'initialize' { function (params) client.init(params) - config.init() if params.rootUri then workspace.initRoot(params.rootUri) |