From ccf39b67693b13e42f724ed27ffda326c09b85ef Mon Sep 17 00:00:00 2001
From: Marc Jakobi <marc.jakobi@tiko.energy>
Date: Mon, 16 Sep 2024 11:05:35 +0200
Subject: [PATCH] fix(loader): look for themes on `package.path`

---
 lua/lualine/utils/loader.lua | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lua/lualine/utils/loader.lua b/lua/lualine/utils/loader.lua
index e0c0385e3..0f2d371d6 100644
--- a/lua/lualine/utils/loader.lua
+++ b/lua/lualine/utils/loader.lua
@@ -220,8 +220,12 @@ local function load_theme(theme_name)
   end
   local n_files = #files
   if n_files == 0 then
-    -- No match found
-    error(path .. ' Not found')
+    -- No match found on runtimepath. Fall back to package.path
+    local file = assert(
+      package.searchpath('lualine.themes.' .. theme_name, package.path),
+      'Theme ' .. theme_name .. ' not found'
+    )
+    retval = dofile(file)
   elseif n_files == 1 then
     -- when only one is found run that and return it's return value
     retval = dofile(files[1])