Skip to content

Commit

Permalink
feat: show module source if loading source is under config
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 2, 2022
1 parent 64af691 commit 041a716
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lua/lazy/view/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 041a716

Please sign in to comment.