From 041a716f4e5291d6947c5f96b21a2c4db0aef6e3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 1 Dec 2022 13:56:41 +0100 Subject: [PATCH] feat: show module source if loading source is under config --- lua/lazy/view/render.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index 1f8fab52..26698362 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -16,9 +16,7 @@ local Text = require("lazy.view.text") ---@field _diagnostics LazyDiagnostic[] ---@field plugin_range table ---@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