summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2021-10-01 16:21:24 +0800
committersumneko <sumneko@hotmail.com>2021-10-01 16:21:24 +0800
commit9175822e6c84fc52ef77215117d46f78619cf3cd (patch)
tree3360c82d892774a6dd220b8333a1db6f1b82183f /script
parent80cacc02ae952a8dede16ad69c7ed00ed0928a07 (diff)
downloadlua-language-server-9175822e6c84fc52ef77215117d46f78619cf3cd.zip
loading settings from `.luarc.json`
Diffstat (limited to 'script')
-rw-r--r--script/provider/provider.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 284eca97..b4cf8b49 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -14,6 +14,7 @@ local progress = require 'progress'
local tm = require 'text-merger'
local cfgLoader = require 'config.loader'
local converter = require 'proto.converter'
+local filewatch = require 'filewatch'
local function updateConfig()
local new
@@ -21,6 +22,7 @@ local function updateConfig()
new = cfgLoader.loadLocalConfig(CONFIGPATH)
config.setSource 'path'
log.debug('load config from local', CONFIGPATH)
+ filewatch.watch(workspace.getAbsolutePath(CONFIGPATH))
else
new = cfgLoader.loadRCConfig('.luarc.json')
if new then
@@ -40,6 +42,19 @@ local function updateConfig()
log.debug('loaded config dump:', util.dump(new))
end
+filewatch.event(function (changes)
+ local configPath = workspace.getAbsolutePath(CONFIGPATH or '.luarc.json')
+ if not configPath then
+ return
+ end
+ for _, change in ipairs(changes) do
+ if change.path == configPath then
+ updateConfig()
+ return
+ end
+ end
+end)
+
proto.on('initialize', function (params)
client.init(params)
config.init()