Skip to content

Commit fc21ee4

Browse files
authored
Merge pull request #3012 from Mc-GrowlR/master
Fixed the error that the configuration file pointed to by the `--configpath` option was not read and loaded.
2 parents 3a39d06 + 4a78e36 commit fc21ee4

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

changelog.md

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

33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
5+
* `FIX` Fixed the error that the configuration file pointed to by the `--configpath` option was not read and loaded.
56

67
## 3.13.5
78
`2024-12-20`

script/cli/doc/init.lua

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ local function getPathDocUpdate()
4141
return section.DOC
4242
end
4343
end
44-
end)
44+
end)
4545
if ok then
4646
local doc_json_dir = doc_json_path:string():gsub('/doc.json', '')
4747
return doc_json_dir, doc_path
@@ -131,7 +131,7 @@ local function injectBuildScript()
131131
},
132132
{__index = _G}))
133133
if err or not data then
134-
error(err, 0)
134+
error(err, 0)
135135
end
136136
data()
137137
return module
@@ -193,6 +193,15 @@ function doc.runCLI()
193193

194194
print('root uri = ' .. rootUri)
195195

196+
--- If '--configpath' is specified, get the folder path of the '.luarc.doc.json' configuration file (without the file name)
197+
--- 如果指定了'--configpath',则获取`.luarc.doc.json` 配置文件的文件夹路径(不包含文件名)
198+
--- This option is passed into the callback function of the initialized method in provide.
199+
--- 该选项会被传入到`provide`中的`initialized`方法的回调函数中
200+
local luarcParentUri
201+
if CONFIGPATH then
202+
luarcParentUri = furi.encode(fs.absolute(fs.path(CONFIGPATH)):parent_path():string())
203+
end
204+
196205
util.enableCloseFunction()
197206

198207
local lastClock = os.clock()
@@ -203,6 +212,7 @@ function doc.runCLI()
203212

204213
client:initialize {
205214
rootUri = rootUri,
215+
luarcParentUri = luarcParentUri,
206216
}
207217
io.write(lang.script('CLI_DOC_INITING'))
208218

@@ -222,11 +232,11 @@ function doc.runCLI()
222232
if os.clock() - lastClock > 0.2 then
223233
lastClock = os.clock()
224234
local output = '\x0D'
225-
.. ('>'):rep(math.ceil(i / max * 20))
226-
.. ('='):rep(20 - math.ceil(i / max * 20))
227-
.. ' '
228-
.. ('0'):rep(#tostring(max) - #tostring(i))
229-
.. tostring(i) .. '/' .. tostring(max)
235+
.. ('>'):rep(math.ceil(i / max * 20))
236+
.. ('='):rep(20 - math.ceil(i / max * 20))
237+
.. ' '
238+
.. ('0'):rep(#tostring(max) - #tostring(i))
239+
.. tostring(i) .. '/' .. tostring(max)
230240
io.write(output)
231241
end
232242
end)

script/lclient.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ local defaultClientOptions = {
7777
valueSet = {
7878
define.DiagnosticTag.Unnecessary,
7979
define.DiagnosticTag.Deprecated,
80-
},
80+
},
8181
},
8282
},
8383
},
@@ -92,7 +92,7 @@ local defaultClientOptions = {
9292
function mt:initialize(params)
9393
local initParams = util.tableMerge(params or {}, defaultClientOptions)
9494
self:awaitRequest('initialize', initParams)
95-
self:notify('initialized')
95+
self:notify('initialized', initParams)
9696
end
9797

9898
function mt:reportHangs()

script/provider/provider.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ m.register 'initialize' {
139139

140140
m.register 'initialized'{
141141
---@async
142-
function (_params)
142+
function (params)
143143
local _ <close> = progress.create(workspace.getFirstScope().uri, lang.script.WINDOW_INITIALIZING, 0.5)
144-
m.updateConfig()
144+
--- 传递`.luarc.doc.json`文件所在的文件夹路径
145+
m.updateConfig(params and params.luarcParentUri)
145146
local registrations = {}
146147

147148
if client.getAbility 'workspace.didChangeConfiguration.dynamicRegistration' then

0 commit comments

Comments
 (0)