feat: show module source if loading source is under config

This commit is contained in:
Folke Lemaitre 2022-12-01 13:56:41 +01:00
parent 64af691be3
commit 041a716f4e
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 11 additions and 3 deletions

View File

@ -16,9 +16,7 @@ local Text = require("lazy.view.text")
---@field _diagnostics LazyDiagnostic[]
---@field plugin_range table<string, {from: number, to: number}>
---@field _details? string
local M = setmetatable({}, {
__index = Text,
})
local M = setmetatable({}, { __index = Text })
function M.new(buf, win, padding)
local self = setmetatable({}, { __index = M })
@ -201,6 +199,16 @@ function M:reason(reason, opts)
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")
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
end
local time = " " .. math.floor((reason.time or 0) / 1e6 * 100) / 100 .. "ms"
if not opts.time_right then