Skip to content

fix(core): no autoload on require when username is lua. Closes #1981 #1982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

abeldekat
Copy link
Contributor

Description

In plugin.find, do "reverse" one step earlier, in order to find the last /lua/ occurrence.

@phanen
Copy link

phanen commented Apr 19, 2025

local idx = bufname:find("/lua/", 1, true)

Maybe this one is also errorprone?

And... I don't think this way is a perfect fix, we should not always find the last /lua/, say I have a plugin have foo.nvim, I want to find this

-- ~/.local/share/lazy/foo.nvim/lua/foo/lua/bar.lua
pcall(require, 'foo.lua.bar')

A real world example: blink.cmp/lua/blink/cmp/fuzzy/lua/match_indices.lua

EDIT:
I didn't look into the lazy.nvim so all the above is just my guessing... (But I have a similar experience in neovim/neovim@c48cf18, hope it can be of helpful)

maybe a robust fix would look like this (if we can determine what the rtp is)

diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua
index 37d1a8f..07c9f28 100644
--- a/lua/lazy/core/plugin.lua
+++ b/lua/lazy/core/plugin.lua
@@ -390,7 +390,7 @@ function M.find(path, opts)
     return
   end
   opts = opts or {}
-  local lua = path:find("/lua/", 1, true)
+  local lua = path:trim_rtp():find("/lua/", 1, true)
   if lua then
     local name = path:sub(1, lua - 1)
     local slash = name:reverse():find("/", 1, true)

@abeldekat
Copy link
Contributor Author

Thanks @phanen!

I also think this is not the perfect fix. I can't answer your questions with confidence, so lets see what Folke has to say.

@abeldekat
Copy link
Contributor Author

abeldekat commented Apr 20, 2025

I am going to close this PR, as it breaks existing behavior.

Currently, imagining a local mod = require("blink.cmp.fuzzy.lua.match_indices"), the following holds true:

  1. mod is correct
  2. if blink.cmp is not yet present in rtp, it is added

With this PR:

  1. mod is correct
  2. if blink.cmp is not yet present in rtp, it is not added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: No autoload on require when username is lua
2 participants