Skip to content

Commit ba1f33f

Browse files
committed
1 parent 90b5385 commit ba1f33f

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* `FIX` [#825](https://github.com./sumneko/lua-language-server/issues/825)
66
* `FIX` [#826](https://github.com./sumneko/lua-language-server/issues/826)
77
* `FIX` [#827](https://github.com./sumneko/lua-language-server/issues/827)
8+
* `FIX` [#831](https://github.com./sumneko/lua-language-server/issues/831)
89
* `FIX` [#837](https://github.com./sumneko/lua-language-server/issues/837)
910
* `FIX` runtime errors
1011

script/config/config.lua

+4-1
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,16 @@ function m.dump()
320320
return dump
321321
end
322322

323-
function m.update(new)
323+
function m.update(new, null)
324324
local function expand(t, left)
325325
for key, value in pairs(t) do
326326
local fullKey = key
327327
if left then
328328
fullKey = left .. '.' .. key
329329
end
330+
if value == null then
331+
value = nil
332+
end
330333
if Template[fullKey] then
331334
m.set(fullKey, value)
332335
elseif Template['Lua.' .. fullKey] then

script/provider/provider.lua

+12-29
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,29 @@ local converter = require 'proto.converter'
1717
local filewatch = require 'filewatch'
1818
local json = require 'json'
1919

20-
local function mergeConfig(a, b)
21-
for k, v in pairs(b) do
22-
if a[k] == nil then
23-
a[k] = v
24-
end
25-
end
26-
end
27-
2820
---@async
2921
local function updateConfig()
30-
local merged = {}
31-
32-
local cfg = cfgLoader.loadLocalConfig(CONFIGPATH)
33-
if cfg then
34-
log.debug('load config from local', CONFIGPATH)
35-
-- watch directory
36-
filewatch.watch(workspace.getAbsolutePath(CONFIGPATH):gsub('[^/\\]+$', ''))
37-
mergeConfig(merged, cfg)
22+
local clientConfig = cfgLoader.loadClientConfig()
23+
if clientConfig then
24+
log.debug('load config from client')
25+
config.update(clientConfig, json.null)
3826
end
3927

4028
local rc = cfgLoader.loadRCConfig('.luarc.json')
4129
if rc then
4230
log.debug('load config from luarc')
43-
mergeConfig(merged, rc)
44-
end
45-
46-
local clientConfig = cfgLoader.loadClientConfig()
47-
if clientConfig then
48-
log.debug('load config from client')
49-
mergeConfig(merged, clientConfig)
31+
config.update(rc, json.null)
5032
end
5133

52-
for k, v in pairs(merged) do
53-
if v == json.null then
54-
merged[k] = nil
55-
end
34+
local cfg = cfgLoader.loadLocalConfig(CONFIGPATH)
35+
if cfg then
36+
log.debug('load config from local', CONFIGPATH)
37+
-- watch directory
38+
filewatch.watch(workspace.getAbsolutePath(CONFIGPATH):gsub('[^/\\]+$', ''))
39+
config.update(cfg, json.null)
5640
end
5741

58-
config.update(merged)
59-
log.debug('loaded config dump:', util.dump(merged))
42+
log.debug('loaded config dump:', util.dump(config.dump()))
6043
end
6144

6245
---@class provider

0 commit comments

Comments
 (0)