From aa02a9b2a84af233fda02680fceb3becb892c3d7 Mon Sep 17 00:00:00 2001 From: Mc-GrowlR Date: Fri, 27 Dec 2024 23:42:02 +0800 Subject: [PATCH 1/4] Fix `--configpath` not load --- script/cli/doc/init.lua | 24 +++++++++++++++++------- script/lclient.lua | 4 ++-- script/provider/provider.lua | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/script/cli/doc/init.lua b/script/cli/doc/init.lua index 483ea21f9..86cae3e07 100644 --- a/script/cli/doc/init.lua +++ b/script/cli/doc/init.lua @@ -41,7 +41,7 @@ local function getPathDocUpdate() return section.DOC end end - end) + end) if ok then local doc_json_dir = doc_json_path:string():gsub('/doc.json', '') return doc_json_dir, doc_path @@ -131,7 +131,7 @@ local function injectBuildScript() }, {__index = _G})) if err or not data then - error(err, 0) + error(err, 0) end data() return module @@ -193,6 +193,15 @@ function doc.runCLI() print('root uri = ' .. rootUri) + --- If '--configpath' is specified, get the folder path of the '.luarc.doc.josn' configuration file (without the file name) + --- 如果指定了'--configpath',则获取`.luarc.doc.josn` 配置文件的文件夹路径(不包含文件名) + --- This option is passed into the callback function of the initialized method in provide. + --- 该选项会被传入到`provide`中的`initialized`方法的回调函数中 + local luarcParentUri + if CONFIGPATH then + luarcParentUri = furi.encode(fs.absolute(fs.path(CONFIGPATH)):parent_path():string()) + end + util.enableCloseFunction() local lastClock = os.clock() @@ -203,6 +212,7 @@ function doc.runCLI() client:initialize { rootUri = rootUri, + luarcParentUri = luarcParentUri } io.write(lang.script('CLI_DOC_INITING')) @@ -222,11 +232,11 @@ function doc.runCLI() if os.clock() - lastClock > 0.2 then lastClock = os.clock() local output = '\x0D' - .. ('>'):rep(math.ceil(i / max * 20)) - .. ('='):rep(20 - math.ceil(i / max * 20)) - .. ' ' - .. ('0'):rep(#tostring(max) - #tostring(i)) - .. tostring(i) .. '/' .. tostring(max) + .. ('>'):rep(math.ceil(i / max * 20)) + .. ('='):rep(20 - math.ceil(i / max * 20)) + .. ' ' + .. ('0'):rep(#tostring(max) - #tostring(i)) + .. tostring(i) .. '/' .. tostring(max) io.write(output) end end) diff --git a/script/lclient.lua b/script/lclient.lua index 0909e9321..513e311cf 100644 --- a/script/lclient.lua +++ b/script/lclient.lua @@ -77,7 +77,7 @@ local defaultClientOptions = { valueSet = { define.DiagnosticTag.Unnecessary, define.DiagnosticTag.Deprecated, - }, + }, }, }, }, @@ -92,7 +92,7 @@ local defaultClientOptions = { function mt:initialize(params) local initParams = util.tableMerge(params or {}, defaultClientOptions) self:awaitRequest('initialize', initParams) - self:notify('initialized') + self:notify('initialized', initParams) end function mt:reportHangs() diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 08031213e..3f79f4ea5 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -141,7 +141,7 @@ m.register 'initialized'{ ---@async function (_params) local _ = progress.create(workspace.getFirstScope().uri, lang.script.WINDOW_INITIALIZING, 0.5) - m.updateConfig() + m.updateConfig((_params or {}).luarcParentUri) local registrations = {} if client.getAbility 'workspace.didChangeConfiguration.dynamicRegistration' then From 6ac41ac77d84b238aa44f1615dc6393a955b7925 Mon Sep 17 00:00:00 2001 From: Mc-GrowlR Date: Sat, 28 Dec 2024 00:15:25 +0800 Subject: [PATCH 2/4] fix `--configpath` not load --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index bdea8e280..f948369b6 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## Unreleased +* `FIX` Fixed the error that the configuration file pointed to by the `--configpath` option was not read and loaded. ## 3.13.5 `2024-12-20` From 0703a80c0d080ef3d668c6dcfc5ca3bdaec89c20 Mon Sep 17 00:00:00 2001 From: Mc-GrowlR Date: Sat, 28 Dec 2024 12:38:09 +0800 Subject: [PATCH 3/4] Fixed some minor issues --- script/cli/doc/init.lua | 6 +++--- script/provider/provider.lua | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/script/cli/doc/init.lua b/script/cli/doc/init.lua index 86cae3e07..3492b3d9c 100644 --- a/script/cli/doc/init.lua +++ b/script/cli/doc/init.lua @@ -193,8 +193,8 @@ function doc.runCLI() print('root uri = ' .. rootUri) - --- If '--configpath' is specified, get the folder path of the '.luarc.doc.josn' configuration file (without the file name) - --- 如果指定了'--configpath',则获取`.luarc.doc.josn` 配置文件的文件夹路径(不包含文件名) + --- If '--configpath' is specified, get the folder path of the '.luarc.doc.json' configuration file (without the file name) + --- 如果指定了'--configpath',则获取`.luarc.doc.json` 配置文件的文件夹路径(不包含文件名) --- This option is passed into the callback function of the initialized method in provide. --- 该选项会被传入到`provide`中的`initialized`方法的回调函数中 local luarcParentUri @@ -212,7 +212,7 @@ function doc.runCLI() client:initialize { rootUri = rootUri, - luarcParentUri = luarcParentUri + luarcParentUri = luarcParentUri, } io.write(lang.script('CLI_DOC_INITING')) diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 3f79f4ea5..c1e9a0d20 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -141,7 +141,8 @@ m.register 'initialized'{ ---@async function (_params) local _ = progress.create(workspace.getFirstScope().uri, lang.script.WINDOW_INITIALIZING, 0.5) - m.updateConfig((_params or {}).luarcParentUri) + --- 传递`.luarc.doc.json`文件所在的文件夹路径 + m.updateConfig(_params and _params.luarcParentUri) local registrations = {} if client.getAbility 'workspace.didChangeConfiguration.dynamicRegistration' then From 4a78e36b29becd1b04c2b4bb5ad1798d30ec7f90 Mon Sep 17 00:00:00 2001 From: Mc-GrowlR Date: Sat, 28 Dec 2024 20:23:19 +0800 Subject: [PATCH 4/4] delete `_` --- script/provider/provider.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/provider/provider.lua b/script/provider/provider.lua index c1e9a0d20..8b988059e 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -139,10 +139,10 @@ m.register 'initialize' { m.register 'initialized'{ ---@async - function (_params) + function (params) local _ = progress.create(workspace.getFirstScope().uri, lang.script.WINDOW_INITIALIZING, 0.5) --- 传递`.luarc.doc.json`文件所在的文件夹路径 - m.updateConfig(_params and _params.luarcParentUri) + m.updateConfig(params and params.luarcParentUri) local registrations = {} if client.getAbility 'workspace.didChangeConfiguration.dynamicRegistration' then