mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-28 11:24:14 +00:00
feat(ui): toggle to show plugin URLs on home page
This commit is contained in:
parent
3f13f08043
commit
f9d3365c5f
7 changed files with 51 additions and 6 deletions
|
@ -79,6 +79,11 @@ M.defaults = {
|
|||
"‒",
|
||||
},
|
||||
},
|
||||
urls = {
|
||||
enabled = false, -- show URLs on home page by default
|
||||
front = "",
|
||||
back = "",
|
||||
},
|
||||
-- leave nil, to automatically select a browser depending on your OS.
|
||||
-- If you want to use a specific browser, you can define it here
|
||||
browser = nil, ---@type string?
|
||||
|
|
|
@ -43,6 +43,9 @@ M.commands = {
|
|||
help = function()
|
||||
View.show("help")
|
||||
end,
|
||||
locations = function()
|
||||
View.urls()
|
||||
end,
|
||||
debug = function()
|
||||
View.show("debug")
|
||||
end,
|
||||
|
|
|
@ -120,30 +120,37 @@ M.commands = {
|
|||
key = "D",
|
||||
toggle = true,
|
||||
},
|
||||
locations = {
|
||||
button = false,
|
||||
desc = "Toggle plugin locations (URL)",
|
||||
id = 11,
|
||||
key = "T",
|
||||
toggle = true,
|
||||
},
|
||||
help = {
|
||||
button = true,
|
||||
desc = "Toggle this help page",
|
||||
id = 11,
|
||||
id = 12,
|
||||
key = "?",
|
||||
toggle = true,
|
||||
},
|
||||
clear = {
|
||||
desc = "Clear finished tasks",
|
||||
id = 12,
|
||||
id = 13,
|
||||
},
|
||||
load = {
|
||||
desc = "Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`. Use `:Lazy! load` to skip `cond` checks.",
|
||||
id = 13,
|
||||
id = 14,
|
||||
plugins = true,
|
||||
plugins_required = true,
|
||||
},
|
||||
health = {
|
||||
desc = "Run `:checkhealth lazy`",
|
||||
id = 14,
|
||||
id = 15,
|
||||
},
|
||||
build = {
|
||||
desc = "Rebuild a plugin",
|
||||
id = 15,
|
||||
id = 16,
|
||||
plugins = true,
|
||||
plugins_required = true,
|
||||
key_plugin = "gb",
|
||||
|
@ -152,7 +159,7 @@ M.commands = {
|
|||
desc = "Reload a plugin (experimental!!)",
|
||||
plugins = true,
|
||||
plugins_required = true,
|
||||
id = 16,
|
||||
id = 17,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@ local ViewConfig = require("lazy.view.config")
|
|||
|
||||
---@class LazyViewState
|
||||
---@field mode string
|
||||
---@field urls boolean
|
||||
---@field plugin? {name:string, kind?: LazyPluginKind}
|
||||
local default_state = {
|
||||
mode = "home",
|
||||
urls = Config.options.ui.urls.enabled,
|
||||
profile = {
|
||||
threshold = 0,
|
||||
sort_time_taken = false,
|
||||
|
@ -29,6 +31,16 @@ function M.visible()
|
|||
return M.view and M.view.win and vim.api.nvim_win_is_valid(M.view.win)
|
||||
end
|
||||
|
||||
function M.urls()
|
||||
if Config.headless() then
|
||||
return
|
||||
end
|
||||
|
||||
M.view = M.visible() and M.view or M.create()
|
||||
M.view.state.urls = not M.view.state.urls
|
||||
M.view:update()
|
||||
end
|
||||
|
||||
---@param mode? string
|
||||
function M.show(mode)
|
||||
if Config.headless() then
|
||||
|
|
|
@ -424,6 +424,15 @@ function M:plugin(plugin)
|
|||
end
|
||||
end
|
||||
self:diagnostics(plugin)
|
||||
if plugin.url and self.view.state.urls and self.view.state.mode == "home" and not self.view:is_selected(plugin) then
|
||||
self:append(
|
||||
(plugin._.loaded and " " or "")
|
||||
.. Config.options.ui.urls.front
|
||||
.. (plugin.url:gsub("%.git$", ""))
|
||||
.. Config.options.ui.urls.back,
|
||||
"LazyComment"
|
||||
)
|
||||
end
|
||||
self:nl()
|
||||
|
||||
if self.view:is_selected(plugin) then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue