summaryrefslogtreecommitdiff
path: root/script/config
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-08 10:17:42 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-08 10:17:42 +0800
commit5a8e3212d25a5c511e25cdf00232e807a7fb5da7 (patch)
tree37187f9c7cd77a426649b2d514d3582d8530fde8 /script/config
parent86da1325d469b45a62c84cde26634855b44cb4d3 (diff)
downloadlua-language-server-5a8e3212d25a5c511e25cdf00232e807a7fb5da7.zip
use last correct local config
Diffstat (limited to 'script/config')
-rw-r--r--script/config/loader.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/script/config/loader.lua b/script/config/loader.lua
index 03588634..e754be49 100644
--- a/script/config/loader.lua
+++ b/script/config/loader.lua
@@ -19,37 +19,43 @@ local m = {}
function m.loadRCConfig(filename)
local path = workspace.getAbsolutePath(filename)
if not path then
- return
+ m.lastRCConfig = nil
+ return nil
end
local buf = util.loadFile(path)
if not buf then
- return
+ m.lastRCConfig = nil
+ return nil
end
local suc, res = pcall(json.decode, buf)
if not suc then
errorMessage(lang.script('CONFIG_LOAD_ERROR', res))
- return
+ return m.lastRCConfig
end
+ m.lastRCConfig = res
return res
end
function m.loadLocalConfig(filename)
local path = workspace.getAbsolutePath(filename)
if not path then
- return
+ m.lastLocalConfig = nil
+ return nil
end
local buf = util.loadFile(path)
if not buf then
errorMessage(lang.script('CONFIG_LOAD_FAILED', path))
- return
+ m.lastLocalConfig = nil
+ return nil
end
local firstChar = buf:match '%S'
if firstChar == '{' then
local suc, res = pcall(json.decode, buf)
if not suc then
errorMessage(lang.script('CONFIG_LOAD_ERROR', res))
- return
+ return m.lastLocalConfig
end
+ m.lastLocalConfig = res
return res
else
local suc, res = pcall(function ()
@@ -57,8 +63,9 @@ function m.loadLocalConfig(filename)
end)
if not suc then
errorMessage(lang.script('CONFIG_LOAD_ERROR', res))
- return
+ return m.lastLocalConfig
end
+ m.lastLocalConfig = res
return res
end
end