feat(ui): better detection of plugins/config files that loaded a plugin

This commit is contained in:
Folke Lemaitre 2022-12-02 08:54:27 +01:00
parent e22e8e4506
commit 723274efee
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 9 additions and 8 deletions

View File

@ -191,21 +191,22 @@ function M:reason(reason, opts)
---@type string? ---@type string?
local source = reason.source local source = reason.source
if source then if source then
local name = source:match("/([^/]-)/lua") source = vim.loop.fs_realpath(source) or source
for _, other in pairs(Config.plugins) do for _, other in pairs(Config.plugins) do
if name and other.name == name then if source:find(vim.loop.fs_realpath(other.dir), 1, true) then
reason.plugin = other.name reason.plugin = other.name
reason.source = nil reason.source = nil
break break
end end
end end
if reason.source then if reason.source then
source = vim.loop.fs_realpath(source) or source local config = vim.loop.fs_realpath(vim.fn.stdpath("config"))
local config = vim.loop.fs_realpath(vim.fn.stdpath("config") .. "/lua") if source == config .. "/init.lua" then
reason.source = "init.lua"
else
config = config .. "/lua"
if source:find(config, 1, true) == 1 then if source:find(config, 1, true) == 1 then
reason.source = source:sub(#config + 2):gsub("/", "."):gsub("%.lua$", "") reason.source = source:sub(#config + 2):gsub("/", "."):gsub("%.lua$", "")
if reason.source == "lua" then
reason.source = "init.lua"
end end
end end
end end