From cb97bd6d308b83ab4eca3f0462d2690dd66960b5 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 30 Jul 2026 22:48:00 +0800 Subject: improve plugin structure --- xmake/plugins/plugin/main.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'xmake/plugins/plugin/main.lua') diff --git a/xmake/plugins/plugin/main.lua b/xmake/plugins/plugin/main.lua index 0ea537a59..a21b4b264 100644 --- a/xmake/plugins/plugin/main.lua +++ b/xmake/plugins/plugin/main.lua @@ -81,8 +81,11 @@ function _save_manifest(manifest) end -- find a plugin directory in the given repository directory +-- +-- plugins in a repository follow the same layout as packages: +-- /plugins///xmake.lua function _find_plugin_in_repo(repodir, name) - local dir = path.join(repodir, "plugins", name) + local dir = path.join(repodir, "plugins", name:sub(1, 1):lower(), name) if os.isdir(dir) and os.isfile(path.join(dir, "xmake.lua")) then return dir end @@ -300,9 +303,13 @@ function _plugin_description(dir) end -- collect plugins (each subdirectory containing xmake.lua) under the given root -function _collect_plugins(root, seen) +-- +-- built-in/installed plugins are flat (/), while plugins in a +-- repository follow the packages layout (//) +function _collect_plugins(root, seen, nested) local entries = {} - for _, dir in ipairs(os.dirs(path.join(root, "*")) or {}) do + local pattern = nested and path.join(root, "*", "*") or path.join(root, "*") + for _, dir in ipairs(os.dirs(pattern) or {}) do local name = path.filename(dir) if os.isfile(path.join(dir, "xmake.lua")) and (not seen or not seen[name]) then if seen then @@ -338,7 +345,7 @@ function _list() local installed = _collect_plugins(plugindir, seen) local avail = {} for _, repo in ipairs(_repositories()) do - table.join2(avail, _collect_plugins(path.join(repo:directory(), "plugins"), seen)) + table.join2(avail, _collect_plugins(path.join(repo:directory(), "plugins"), seen, true)) end -- compute the alignment width from all plugin names -- cgit v1.3.1