Skip to content

Commit 9175822

Browse files
committed
loading settings from .luarc.json
1 parent 80cacc0 commit 9175822

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# changelog
22

33
## 2.4.0
4+
* `NEW` loading settings from `.luarc.json`
45
* `NEW` settings:
56
+ `Lua.diagnostics.libraryFiles`
67
+ `Lua.diagnostics.ignoredFiles`

script/provider/provider.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ local progress = require 'progress'
1414
local tm = require 'text-merger'
1515
local cfgLoader = require 'config.loader'
1616
local converter = require 'proto.converter'
17+
local filewatch = require 'filewatch'
1718

1819
local function updateConfig()
1920
local new
2021
if CONFIGPATH then
2122
new = cfgLoader.loadLocalConfig(CONFIGPATH)
2223
config.setSource 'path'
2324
log.debug('load config from local', CONFIGPATH)
25+
filewatch.watch(workspace.getAbsolutePath(CONFIGPATH))
2426
else
2527
new = cfgLoader.loadRCConfig('.luarc.json')
2628
if new then
@@ -40,6 +42,19 @@ local function updateConfig()
4042
log.debug('loaded config dump:', util.dump(new))
4143
end
4244

45+
filewatch.event(function (changes)
46+
local configPath = workspace.getAbsolutePath(CONFIGPATH or '.luarc.json')
47+
if not configPath then
48+
return
49+
end
50+
for _, change in ipairs(changes) do
51+
if change.path == configPath then
52+
updateConfig()
53+
return
54+
end
55+
end
56+
end)
57+
4358
proto.on('initialize', function (params)
4459
client.init(params)
4560
config.init()

0 commit comments

Comments
 (0)