diff --git a/lua/pack.lua b/lua/pack.lua index 18c9b9d..b1a78df 100644 --- a/lua/pack.lua +++ b/lua/pack.lua @@ -30,20 +30,30 @@ end ---@field name 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 local function load(plugin) - local name = plugin.name:match("[^.]+") + local name = normalize_name(plugin.name) if not name then log.error("Invalid plugin name: %s", plugin.name) return end - name = name:lower() local path = string.format("%s/lua/plugins/%s.lua", config_dir, name) if vim.uv.fs_stat(path) then local ok, err = exec(path) 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 @@ -126,7 +136,7 @@ end ---@type uv.uv_fs_event_t? local watcher = nil ----@type table +---@type table local timers = {} ---@class ow.Pack @@ -147,7 +157,13 @@ end ---@param name string 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 log.error("No config file found for %s", name)