diff --git a/changelog.md b/changelog.md index 06c2bd48b..619aee0bc 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## Unreleased * `FIX` cannot debug in Linux due to lua-debug expecting host process to have lua54 symbols available +* `NEW` support custom addons path for enhanced editor flexibility ## 3.14.0 `2025-4-7` diff --git a/doc/en-us/config.md b/doc/en-us/config.md index caa3c3a8f..6e6a5bcae 100644 --- a/doc/en-us/config.md +++ b/doc/en-us/config.md @@ -14,6 +14,16 @@ boolean true ``` +# addonRepositoryPath + +Specifies the addon repository path (not related to the addon manager). + +## type + +```ts +string +``` + # codeLens.enable Enable code lens. @@ -2320,4 +2330,4 @@ Array ```jsonc [] -``` \ No newline at end of file +``` diff --git a/doc/pt-br/config.md b/doc/pt-br/config.md index acaed4dc8..2df237476 100644 --- a/doc/pt-br/config.md +++ b/doc/pt-br/config.md @@ -14,6 +14,16 @@ boolean true ``` +# addonRepositoryPath + +Specifies the addon repository path (not related to the addon manager). + +## type + +```ts +string +``` + # codeLens.enable Enable code lens. @@ -2320,4 +2330,4 @@ Array ```jsonc [] -``` \ No newline at end of file +``` diff --git a/doc/zh-cn/config.md b/doc/zh-cn/config.md index e7292b929..8505bed70 100644 --- a/doc/zh-cn/config.md +++ b/doc/zh-cn/config.md @@ -14,6 +14,16 @@ boolean true ``` +# addonRepositoryPath + +指定插件仓库的路径(与 Addon Manager 无关)。 + +## type + +```ts +string +``` + # codeLens.enable 启用代码度量。 @@ -2318,4 +2328,4 @@ Array ```jsonc [] -``` \ No newline at end of file +``` diff --git a/doc/zh-tw/config.md b/doc/zh-tw/config.md index 5e491a516..7a75e1618 100644 --- a/doc/zh-tw/config.md +++ b/doc/zh-tw/config.md @@ -14,6 +14,16 @@ boolean true ``` +# addonRepositoryPath + +Specifies the addon repository path (not related to the addon manager). + +## type + +```ts +string +``` + # codeLens.enable Enable code lens. @@ -2318,4 +2328,4 @@ Array ```jsonc [] -``` \ No newline at end of file +``` diff --git a/locale/en-us/setting.lua b/locale/en-us/setting.lua index e0ca458b8..722345887 100644 --- a/locale/en-us/setting.lua +++ b/locale/en-us/setting.lua @@ -6,6 +6,8 @@ config.addonManager.repositoryBranch = "Specifies the git branch used by the addon manager." config.addonManager.repositoryPath = "Specifies the git path used by the addon manager." +config.addonRepositoryPath = +"Specifies the addon repository path (not related to the addon manager)." config.runtime.version = "Lua runtime version." config.runtime.path = diff --git a/locale/es-419/setting.lua b/locale/es-419/setting.lua index f7d76480f..5fbc7a7fd 100644 --- a/locale/es-419/setting.lua +++ b/locale/es-419/setting.lua @@ -6,6 +6,8 @@ config.addonManager.repositoryBranch = "Especifica la rama de git usada por el manejador de extensiones." config.addonManager.repositoryPath = "Especifica la ruta git usada por el manejador de extensiones." +config.addonRepositoryPath = -- TODO: need translate! +"Specifies the addon repository path (not related to the addon manager)." config.runtime.version = "Versión de Lua que se ejecuta." diff --git a/locale/ja-jp/setting.lua b/locale/ja-jp/setting.lua index a8c307324..2514d1ad0 100644 --- a/locale/ja-jp/setting.lua +++ b/locale/ja-jp/setting.lua @@ -6,6 +6,8 @@ config.addonManager.repositoryBranch = -- TODO: need translate! "Specifies the git branch used by the addon manager." config.addonManager.repositoryPath = -- TODO: need translate! "Specifies the git path used by the addon manager." +config.addonRepositoryPath = -- TODO: need translate! +"Specifies the addon repository path (not related to the addon manager)." config.runtime.version = -- TODO: need translate! "Lua runtime version." config.runtime.path = -- TODO: need translate! diff --git a/locale/pt-br/setting.lua b/locale/pt-br/setting.lua index 465b45f27..75740fef7 100644 --- a/locale/pt-br/setting.lua +++ b/locale/pt-br/setting.lua @@ -6,6 +6,8 @@ config.addonManager.repositoryBranch = -- TODO: need translate! "Specifies the git branch used by the addon manager." config.addonManager.repositoryPath = -- TODO: need translate! "Specifies the git path used by the addon manager." +config.addonRepositoryPath = -- TODO: need translate! +"Specifies the addon repository path (not related to the addon manager)." config.runtime.version = -- TODO: need translate! "Lua runtime version." config.runtime.path = -- TODO: need translate! diff --git a/locale/zh-cn/setting.lua b/locale/zh-cn/setting.lua index ece1e6191..cf09bbaa5 100644 --- a/locale/zh-cn/setting.lua +++ b/locale/zh-cn/setting.lua @@ -6,6 +6,8 @@ config.addonManager.repositoryBranch = "指定插件管理器(Addon Manager)使用的git仓库分支" config.addonManager.repositoryPath = "指定插件管理器(Addon Manager)使用的git仓库路径" +config.addonRepositoryPath = +"指定插件仓库的路径(与 Addon Manager 无关)" config.runtime.version = "Lua运行版本。" config.runtime.path = diff --git a/locale/zh-tw/setting.lua b/locale/zh-tw/setting.lua index 1bc254aa9..09d040925 100644 --- a/locale/zh-tw/setting.lua +++ b/locale/zh-tw/setting.lua @@ -6,6 +6,8 @@ config.addonManager.repositoryBranch = -- TODO: need translate! "Specifies the git branch used by the addon manager." config.addonManager.repositoryPath = -- TODO: need translate! "Specifies the git path used by the addon manager." +config.addonRepositoryPath = -- TODO: need translate! +"Specifies the addon repository path (not related to the addon manager)." config.runtime.version = "Lua執行版本。" config.runtime.path = diff --git a/script/config/template.lua b/script/config/template.lua index 74b7c4b8e..b59911599 100644 --- a/script/config/template.lua +++ b/script/config/template.lua @@ -414,6 +414,7 @@ local template = { }, --testma ["Lua.docScriptPath"] = Type.String, + ["Lua.addonRepositoryPath"] = Type.String, -- VSCode ["Lua.addonManager.enable"] = Type.Boolean >> true, ["Lua.addonManager.repositoryPath"] = Type.String, diff --git a/script/files.lua b/script/files.lua index f61330e21..776b23f83 100644 --- a/script/files.lua +++ b/script/files.lua @@ -908,6 +908,25 @@ end local addonsPath +---Updates the variable 'addonsPath' with the user's configuration. +---The path is only updated if 'addonsPath' is not set and the provided path is a valid string. +---It first expands the input path and then verifies its existence via fs.exists. +---@param path string +function m.updateAddonsPath(path) + if addonsPath then + return + end + if not (path and type(path) == "string") then + return + end + + path = util.expandPath(fs.path(path):string()) + if fs.exists(fs.path(path)) then + addonsPath = path + log.info('Updating addon repository path to: ', path) + end +end + ---Resolve path variables/placeholders like ${3rd} and ${addons} ---@param path string ---@return string resolvedPath diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index 4ae3ba9e8..d58683424 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -131,6 +131,7 @@ local globInteferFace = { end } +local addonRepositoryPathUpdated = false --- 创建排除文件匹配器 ---@param scp scope function m.getNativeMatcher(scp) @@ -175,6 +176,11 @@ function m.getNativeMatcher(scp) end end for _, path in ipairs(config.get(scp.uri, 'Lua.workspace.library')) do + if not addonRepositoryPathUpdated then + addonRepositoryPathUpdated = true + local addonRepositoryPath = config.get(scp.uri, 'Lua.addonRepositoryPath') + files.updateAddonsPath(addonRepositoryPath) + end path = m.getAbsolutePath(scp.uri, path) if path then log.debug('Ignore by library:', path)