From 84a85f3910a881ae15dd9cd4d6c58bf523ff936e Mon Sep 17 00:00:00 2001 From: abeldekat <58370433+abeldekat@users.noreply.github.com> Date: Sat, 19 Apr 2025 08:27:06 +0200 Subject: [PATCH] fix(core): no autoload on require when username is lua. Closes #1981 --- lua/lazy/core/plugin.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index 37d1a8f..583b088 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -390,12 +390,16 @@ function M.find(path, opts) return end opts = opts or {} - local lua = path:find("/lua/", 1, true) - if lua then - local name = path:sub(1, lua - 1) - local slash = name:reverse():find("/", 1, true) - if slash then - name = name:sub(#name - slash + 2) + -- Find start and end of "/name_of_plugin/" + -- Example: extract lualine.nvim from the following path: + -- "/home/user/.local/share/nvim/lazy/lualine.nvim/lua/lualine.lua" + -- "aul.enilaul/aul/mivn.enilaul/yzal/mivn/erahs/lacol./resu/emoh/"(reversed) + local reversed = path:reverse() + local rev_start, rev_end = reversed:find("/aul/", 1, true) -- find *last* "/lua/" + if rev_start then + local rev_next_slash = reversed:find("/", rev_end + 1, true) + if rev_next_slash then + local name = path:sub(#path - rev_next_slash + 2, #path - rev_end) if name then if opts.fast then return Config.spec.meta.plugins[name]