Skip to content

Commit 13686ec

Browse files
committed
feat: allow configurable addons path for non-VSCode editors
1 parent 606ea70 commit 13686ec

File tree

14 files changed

+83
-4
lines changed

14 files changed

+83
-4
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
55
* `FIX` cannot debug in Linux due to lua-debug expecting host process to have lua54 symbols available
6+
* `NEW` support custom addons path for enhanced editor flexibility
67

78
## 3.14.0
89
`2025-4-7`

doc/en-us/config.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ boolean
1414
true
1515
```
1616

17+
# addonRepositoryPath
18+
19+
Specifies the addon repository path (not related to the addon manager).
20+
21+
## type
22+
23+
```ts
24+
string
25+
```
26+
1727
# codeLens.enable
1828

1929
Enable code lens.
@@ -2320,4 +2330,4 @@ Array<string>
23202330

23212331
```jsonc
23222332
[]
2323-
```
2333+
```

doc/pt-br/config.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ boolean
1414
true
1515
```
1616

17+
# addonRepositoryPath
18+
19+
Specifies the addon repository path (not related to the addon manager).
20+
21+
## type
22+
23+
```ts
24+
string
25+
```
26+
1727
# codeLens.enable
1828

1929
Enable code lens.
@@ -2320,4 +2330,4 @@ Array<string>
23202330

23212331
```jsonc
23222332
[]
2323-
```
2333+
```

doc/zh-cn/config.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ boolean
1414
true
1515
```
1616

17+
# addonRepositoryPath
18+
19+
指定插件仓库的路径(与 Addon Manager 无关)。
20+
21+
## type
22+
23+
```ts
24+
string
25+
```
26+
1727
# codeLens.enable
1828

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

23192329
```jsonc
23202330
[]
2321-
```
2331+
```

doc/zh-tw/config.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ boolean
1414
true
1515
```
1616

17+
# addonRepositoryPath
18+
19+
Specifies the addon repository path (not related to the addon manager).
20+
21+
## type
22+
23+
```ts
24+
string
25+
```
26+
1727
# codeLens.enable
1828

1929
Enable code lens.
@@ -2318,4 +2328,4 @@ Array<string>
23182328

23192329
```jsonc
23202330
[]
2321-
```
2331+
```

locale/en-us/setting.lua

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ config.addonManager.repositoryBranch =
66
"Specifies the git branch used by the addon manager."
77
config.addonManager.repositoryPath =
88
"Specifies the git path used by the addon manager."
9+
config.addonRepositoryPath =
10+
"Specifies the addon repository path (not related to the addon manager)."
911
config.runtime.version =
1012
"Lua runtime version."
1113
config.runtime.path =

locale/es-419/setting.lua

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ config.addonManager.repositoryBranch =
66
"Especifica la rama de git usada por el manejador de extensiones."
77
config.addonManager.repositoryPath =
88
"Especifica la ruta git usada por el manejador de extensiones."
9+
config.addonRepositoryPath = -- TODO: need translate!
10+
"Specifies the addon repository path (not related to the addon manager)."
911

1012
config.runtime.version =
1113
"Versión de Lua que se ejecuta."

locale/ja-jp/setting.lua

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ config.addonManager.repositoryBranch = -- TODO: need translate!
66
"Specifies the git branch used by the addon manager."
77
config.addonManager.repositoryPath = -- TODO: need translate!
88
"Specifies the git path used by the addon manager."
9+
config.addonRepositoryPath = -- TODO: need translate!
10+
"Specifies the addon repository path (not related to the addon manager)."
911
config.runtime.version = -- TODO: need translate!
1012
"Lua runtime version."
1113
config.runtime.path = -- TODO: need translate!

locale/pt-br/setting.lua

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ config.addonManager.repositoryBranch = -- TODO: need translate!
66
"Specifies the git branch used by the addon manager."
77
config.addonManager.repositoryPath = -- TODO: need translate!
88
"Specifies the git path used by the addon manager."
9+
config.addonRepositoryPath = -- TODO: need translate!
10+
"Specifies the addon repository path (not related to the addon manager)."
911
config.runtime.version = -- TODO: need translate!
1012
"Lua runtime version."
1113
config.runtime.path = -- TODO: need translate!

locale/zh-cn/setting.lua

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ config.addonManager.repositoryBranch =
66
"指定插件管理器(Addon Manager)使用的git仓库分支"
77
config.addonManager.repositoryPath =
88
"指定插件管理器(Addon Manager)使用的git仓库路径"
9+
config.addonRepositoryPath =
10+
"指定插件仓库的路径(与 Addon Manager 无关)"
911
config.runtime.version =
1012
"Lua运行版本。"
1113
config.runtime.path =

locale/zh-tw/setting.lua

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ config.addonManager.repositoryBranch = -- TODO: need translate!
66
"Specifies the git branch used by the addon manager."
77
config.addonManager.repositoryPath = -- TODO: need translate!
88
"Specifies the git path used by the addon manager."
9+
config.addonRepositoryPath = -- TODO: need translate!
10+
"Specifies the addon repository path (not related to the addon manager)."
911
config.runtime.version =
1012
"Lua執行版本。"
1113
config.runtime.path =

script/config/template.lua

+1
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ local template = {
414414
},
415415
--testma
416416
["Lua.docScriptPath"] = Type.String,
417+
["Lua.addonRepositoryPath"] = Type.String,
417418
-- VSCode
418419
["Lua.addonManager.enable"] = Type.Boolean >> true,
419420
["Lua.addonManager.repositoryPath"] = Type.String,

script/files.lua

+19
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,25 @@ end
908908

909909
local addonsPath
910910

911+
---Updates the variable 'addonsPath' with the user's configuration.
912+
---The path is only updated if 'addonsPath' is not set and the provided path is a valid string.
913+
---It first expands the input path and then verifies its existence via fs.exists.
914+
---@param path string
915+
function m.updateAddonsPath(path)
916+
if addonsPath then
917+
return
918+
end
919+
if not (path and type(path) == "string") then
920+
return
921+
end
922+
923+
path = util.expandPath(fs.path(path):string())
924+
if fs.exists(fs.path(path)) then
925+
addonsPath = path
926+
log.info('Updating addon repository path to: ', path)
927+
end
928+
end
929+
911930
---Resolve path variables/placeholders like ${3rd} and ${addons}
912931
---@param path string
913932
---@return string resolvedPath

script/workspace/workspace.lua

+6
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ local globInteferFace = {
131131
end
132132
}
133133

134+
local addonRepositoryPathUpdated = false
134135
--- 创建排除文件匹配器
135136
---@param scp scope
136137
function m.getNativeMatcher(scp)
@@ -175,6 +176,11 @@ function m.getNativeMatcher(scp)
175176
end
176177
end
177178
for _, path in ipairs(config.get(scp.uri, 'Lua.workspace.library')) do
179+
if not addonRepositoryPathUpdated then
180+
addonRepositoryPathUpdated = true
181+
local addonRepositoryPath = config.get(scp.uri, 'Lua.addonRepositoryPath')
182+
files.updateAddonsPath(addonRepositoryPath)
183+
end
178184
path = m.getAbsolutePath(scp.uri, path)
179185
if path then
180186
log.debug('Ignore by library:', path)

0 commit comments

Comments
 (0)