Skip to content

Support Custom Addons Path for Enhanced Editor Flexibility #3155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `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`
12 changes: 11 additions & 1 deletion doc/en-us/config.md
Original file line number Diff line number Diff line change
@@ -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<string>

```jsonc
[]
```
```
12 changes: 11 additions & 1 deletion doc/pt-br/config.md
Original file line number Diff line number Diff line change
@@ -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<string>

```jsonc
[]
```
```
12 changes: 11 additions & 1 deletion doc/zh-cn/config.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,16 @@ boolean
true
```

# addonRepositoryPath

指定插件仓库的路径(与 Addon Manager 无关)。

## type

```ts
string
```

# codeLens.enable

启用代码度量。
@@ -2318,4 +2328,4 @@ Array<string>

```jsonc
[]
```
```
12 changes: 11 additions & 1 deletion doc/zh-tw/config.md
Original file line number Diff line number Diff line change
@@ -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<string>

```jsonc
[]
```
```
2 changes: 2 additions & 0 deletions locale/en-us/setting.lua
Original file line number Diff line number Diff line change
@@ -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 =
2 changes: 2 additions & 0 deletions locale/es-419/setting.lua
Original file line number Diff line number Diff line change
@@ -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."
2 changes: 2 additions & 0 deletions locale/ja-jp/setting.lua
Original file line number Diff line number Diff line change
@@ -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!
2 changes: 2 additions & 0 deletions locale/pt-br/setting.lua
Original file line number Diff line number Diff line change
@@ -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!
2 changes: 2 additions & 0 deletions locale/zh-cn/setting.lua
Original file line number Diff line number Diff line change
@@ -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 =
2 changes: 2 additions & 0 deletions locale/zh-tw/setting.lua
Original file line number Diff line number Diff line change
@@ -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 =
1 change: 1 addition & 0 deletions script/config/template.lua
Original file line number Diff line number Diff line change
@@ -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,
19 changes: 19 additions & 0 deletions script/files.lua
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions script/workspace/workspace.lua
Original file line number Diff line number Diff line change
@@ -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)