diff --git a/README.md b/README.md index f7f709f..dc4f77a 100644 --- a/README.md +++ b/README.md @@ -370,6 +370,11 @@ return { "‒", }, }, + 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? @@ -525,6 +530,7 @@ Any operation can be started from the UI, with a sub command or an API function: | `:Lazy debug` | `require("lazy").debug()` | Show debug information | | `:Lazy health` | `require("lazy").health()` | Run `:checkhealth lazy` | | `:Lazy help` | `require("lazy").help()` | Toggle this help page | +| `:Lazy locations` | `require("lazy").locations()` | Toggle plugin URLs in plugin list | | `:Lazy home` | `require("lazy").home()` | Go back to plugin list | | `:Lazy install [plugins]` | `require("lazy").install(opts?)` | Install missing plugins | | `:Lazy load {plugins}` | `require("lazy").load(opts)` | Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim`. Use `:Lazy! load` to skip `cond` checks. | diff --git a/doc/lazy.nvim.txt b/doc/lazy.nvim.txt index 4eed594..b9cb449 100644 --- a/doc/lazy.nvim.txt +++ b/doc/lazy.nvim.txt @@ -634,6 +634,9 @@ function: :Lazy health require("lazy").health() Run :checkhealth lazy :Lazy help require("lazy").help() Toggle this help page + + :Lazy locations require("lazy").locations() Toggle plugin URLs in + plugin list :Lazy home require("lazy").home() Go back to plugin list diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index 4c4c394..2eea71a 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -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? diff --git a/lua/lazy/view/commands.lua b/lua/lazy/view/commands.lua index a826827..34a78d0 100644 --- a/lua/lazy/view/commands.lua +++ b/lua/lazy/view/commands.lua @@ -43,6 +43,9 @@ M.commands = { help = function() View.show("help") end, + locations = function() + View.urls() + end, debug = function() View.show("debug") end, diff --git a/lua/lazy/view/config.lua b/lua/lazy/view/config.lua index e834573..851e65e 100644 --- a/lua/lazy/view/config.lua +++ b/lua/lazy/view/config.lua @@ -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, }, } diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index 5753f5b..8cffad5 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -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 diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index 5d7e197..25eedf8 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -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