summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2021-10-01 15:43:18 +0800
committersumneko <sumneko@hotmail.com>2021-10-01 15:43:18 +0800
commit80cacc02ae952a8dede16ad69c7ed00ed0928a07 (patch)
tree904c8d5fb61b7f4ef204d7d4ee34cca8faa86ca7 /script
parent98e3b264a52738d79bc914f68207d7f3971ef9ae (diff)
downloadlua-language-server-80cacc02ae952a8dede16ad69c7ed00ed0928a07.zip
load config in `.luarc.json`
Diffstat (limited to 'script')
-rw-r--r--script/config/loader.lua14
-rw-r--r--script/provider/provider.lua12
2 files changed, 23 insertions, 3 deletions
diff --git a/script/config/loader.lua b/script/config/loader.lua
index 9f15830d..c7af26d9 100644
--- a/script/config/loader.lua
+++ b/script/config/loader.lua
@@ -16,6 +16,20 @@ end
local m = {}
+function m.loadRCConfig(filename)
+ local path = fs.path(workspace.getAbsolutePath(filename))
+ local buf = fsu.loadFile(path)
+ if not buf then
+ return
+ end
+ local suc, res = pcall(json.decode, buf)
+ if not suc then
+ errorMessage(lang.script('CONFIG_LOAD_ERROR', res))
+ return
+ end
+ return res
+end
+
function m.loadLocalConfig(filename)
local path = fs.path(workspace.getAbsolutePath(filename))
local buf = fsu.loadFile(path)
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 0e4f7ddd..284eca97 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -22,9 +22,15 @@ local function updateConfig()
config.setSource 'path'
log.debug('load config from local', CONFIGPATH)
else
- new = cfgLoader.loadClientConfig()
- config.setSource 'client'
- log.debug('load config from client')
+ new = cfgLoader.loadRCConfig('.luarc.json')
+ if new then
+ config.setSource 'luarc'
+ log.debug('load config from luarc')
+ else
+ new = cfgLoader.loadClientConfig()
+ config.setSource 'client'
+ log.debug('load config from client')
+ end
end
if not new then
log.warn('load config failed!')