mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat: git log
This commit is contained in:
parent
54d5ff18f5
commit
3218c2d9ec
7 changed files with 83 additions and 6 deletions
|
@ -21,6 +21,9 @@ M.commands = {
|
|||
install = function()
|
||||
Manager.install({ clear = true, show = true })
|
||||
end,
|
||||
log = function()
|
||||
Manager.log({ clear = true, show = true })
|
||||
end,
|
||||
show = function()
|
||||
View.show()
|
||||
end,
|
||||
|
|
|
@ -119,6 +119,25 @@ function M:plugin(plugin)
|
|||
self:nl()
|
||||
end
|
||||
end
|
||||
elseif task.type == "log" then
|
||||
local log = vim.trim(task.output)
|
||||
if log ~= "" then
|
||||
local lines = vim.split(log, "\n")
|
||||
for l, line in ipairs(lines) do
|
||||
if l == 1 then
|
||||
self:nl()
|
||||
end
|
||||
local ref, msg, time = line:match("^(%w+) (.*) (%(.*%))$")
|
||||
self:append(" " .. ref .. " ", "@variable.builtin")
|
||||
local col = self:col()
|
||||
self:append(msg)
|
||||
-- string.gsub
|
||||
self:append(" " .. time, "Comment")
|
||||
if l ~= #lines then
|
||||
self:nl()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,6 +51,14 @@ return {
|
|||
end,
|
||||
title = "Running",
|
||||
},
|
||||
{
|
||||
filter = function(plugin)
|
||||
return has_task(plugin, function(task)
|
||||
return task.type == "log" and vim.trim(task.output) ~= ""
|
||||
end)
|
||||
end,
|
||||
title = "Log",
|
||||
},
|
||||
{
|
||||
filter = function(plugin)
|
||||
return plugin.installed and not plugin.uri
|
||||
|
|
|
@ -16,7 +16,7 @@ function Text.new()
|
|||
end
|
||||
|
||||
---@param str string
|
||||
---@param hl string|table
|
||||
---@param hl? string|table
|
||||
function Text:append(str, hl)
|
||||
if #self._lines == 0 then
|
||||
self:nl()
|
||||
|
@ -84,4 +84,19 @@ function Text:trim()
|
|||
end
|
||||
end
|
||||
|
||||
function Text:row()
|
||||
return #self._lines == 0 and 1 or #self._lines
|
||||
end
|
||||
|
||||
function Text:col()
|
||||
if #self._lines == 0 then
|
||||
return 0
|
||||
end
|
||||
local width = 0
|
||||
for _, segment in ipairs(self._lines[#self._lines]) do
|
||||
width = width + vim.fn.strlen(segment.str)
|
||||
end
|
||||
return width
|
||||
end
|
||||
|
||||
return Text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue