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?
local source = reason.source
if source then
local name = source:match("/([^/]-)/lua")
source = vim.loop.fs_realpath(source) or source
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.source = nil
break
end
end
if reason.source then
source = vim.loop.fs_realpath(source) or source
local config = vim.loop.fs_realpath(vim.fn.stdpath("config") .. "/lua")
local config = vim.loop.fs_realpath(vim.fn.stdpath("config"))
if source == config .. "/init.lua" then
reason.source = "init.lua"
else
config = config .. "/lua"
if source:find(config, 1, true) == 1 then
reason.source = source:sub(#config + 2):gsub("/", "."):gsub("%.lua$", "")
if reason.source == "lua" then
reason.source = "init.lua"
end
end
end