Skip to content
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

fix(plugin): Make the local_spec check reject similar config module names #1524

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lua/lazy/core/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ function Spec:import(spec)
---@type string[]
local modnames = {}

if spec.import:find(M.LOCAL_SPEC, 1, true) then
-- relies on `find_local_spec` to always insert a `/` before the local spec location
local local_spec_suffix = "/" .. M.LOCAL_SPEC
if spec.import:sub(-#local_spec_suffix) == local_spec_suffix then
modnames = { spec.import }
else
Util.lsmod(spec.import, function(modname)
Expand All @@ -415,8 +417,10 @@ function Spec:import(spec)
for _, modname in ipairs(modnames) do
imported = imported + 1
local name = modname
if modname:find(M.LOCAL_SPEC, 1, true) then
local is_local_spec = false
if modname:sub(-#local_spec_suffix) == local_spec_suffix then
name = vim.fn.fnamemodify(modname, ":~:.")
is_local_spec = true
end
Util.track({ import = name })
self.importing = modname
Expand All @@ -425,7 +429,7 @@ function Spec:import(spec)
package.loaded[modname] = nil
Util.try(function()
local mod = nil
if modname:find(M.LOCAL_SPEC, 1, true) then
if is_local_spec then
mod = M.local_spec(modname)
else
mod = require(modname)
Expand Down