@@ -17,46 +17,29 @@ local converter = require 'proto.converter'
17
17
local filewatch = require ' filewatch'
18
18
local json = require ' json'
19
19
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
-
28
20
--- @async
29
21
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 )
38
26
end
39
27
40
28
local rc = cfgLoader .loadRCConfig (' .luarc.json' )
41
29
if rc then
42
30
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 )
50
32
end
51
33
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 )
56
40
end
57
41
58
- config .update (merged )
59
- log .debug (' loaded config dump:' , util .dump (merged ))
42
+ log .debug (' loaded config dump:' , util .dump (config .dump ()))
60
43
end
61
44
62
45
--- @class provider
0 commit comments