fix(pack): handle plugin name normalization properly

This commit is contained in:
2026-04-13 05:44:26 +02:00
parent a1dde4950c
commit 116325a38d
+21 -5
View File
@@ -30,20 +30,30 @@ end
---@field name string ---@field name string
---@field path string ---@field path string
---@param name string
---@return string?
local function normalize_name(name)
name = name:match("[^.]+")
if name then
return name:lower()
end
return nil
end
---@param plugin ow.Pack.Plugin ---@param plugin ow.Pack.Plugin
local function load(plugin) local function load(plugin)
local name = plugin.name:match("[^.]+") local name = normalize_name(plugin.name)
if not name then if not name then
log.error("Invalid plugin name: %s", plugin.name) log.error("Invalid plugin name: %s", plugin.name)
return return
end end
name = name:lower()
local path = string.format("%s/lua/plugins/%s.lua", config_dir, name) local path = string.format("%s/lua/plugins/%s.lua", config_dir, name)
if vim.uv.fs_stat(path) then if vim.uv.fs_stat(path) then
local ok, err = exec(path) local ok, err = exec(path)
if not ok then if not ok then
log.error("Failed to load %s: %s", name, err) log.error("Failed to load %s: %s", plugin.name, err)
end end
end end
end end
@@ -126,7 +136,7 @@ end
---@type uv.uv_fs_event_t? ---@type uv.uv_fs_event_t?
local watcher = nil local watcher = nil
---@type table<string, uv.uv_timer_t?> ---@type table<string, uv.uv_timer_t>
local timers = {} local timers = {}
---@class ow.Pack ---@class ow.Pack
@@ -147,7 +157,13 @@ end
---@param name string ---@param name string
function M.reload(name) function M.reload(name)
local path = string.format("%s/lua/plugins/%s.lua", config_dir, name) local normalized = normalize_name(name)
if not normalized then
log.error("Invalid plugin name: %s", name)
return
end
local path = string.format("%s/lua/plugins/%s.lua", config_dir, normalized)
if not vim.uv.fs_stat(path) then if not vim.uv.fs_stat(path) then
log.error("No config file found for %s", name) log.error("No config file found for %s", name)