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
|
@ -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.
|
-- leave nil, to automatically select a browser depending on your OS.
|
||||||
-- If you want to use a specific browser, you can define it here
|
-- If you want to use a specific browser, you can define it here
|
||||||
browser = nil, ---@type string?
|
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 debug` | `require("lazy").debug()` | Show debug information |
|
||||||
| `:Lazy health` | `require("lazy").health()` | Run `:checkhealth lazy` |
|
| `:Lazy health` | `require("lazy").health()` | Run `:checkhealth lazy` |
|
||||||
| `:Lazy help` | `require("lazy").help()` | Toggle this help page |
|
| `: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 home` | `require("lazy").home()` | Go back to plugin list |
|
||||||
| `:Lazy install [plugins]` | `require("lazy").install(opts?)` | Install missing plugins |
|
| `: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. |
|
| `: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. |
|
||||||
|
|
|
@ -635,6 +635,9 @@ function:
|
||||||
|
|
||||||
:Lazy help require("lazy").help() Toggle this help page
|
: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 home require("lazy").home() Go back to plugin list
|
||||||
|
|
||||||
:Lazy install [plugins] require("lazy").install(opts?) Install missing plugins
|
:Lazy install [plugins] require("lazy").install(opts?) Install missing plugins
|
||||||
|
|
|
@ -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.
|
-- leave nil, to automatically select a browser depending on your OS.
|
||||||
-- If you want to use a specific browser, you can define it here
|
-- If you want to use a specific browser, you can define it here
|
||||||
browser = nil, ---@type string?
|
browser = nil, ---@type string?
|
||||||
|
|
|
@ -43,6 +43,9 @@ M.commands = {
|
||||||
help = function()
|
help = function()
|
||||||
View.show("help")
|
View.show("help")
|
||||||
end,
|
end,
|
||||||
|
locations = function()
|
||||||
|
View.urls()
|
||||||
|
end,
|
||||||
debug = function()
|
debug = function()
|
||||||
View.show("debug")
|
View.show("debug")
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -120,30 +120,37 @@ M.commands = {
|
||||||
key = "D",
|
key = "D",
|
||||||
toggle = true,
|
toggle = true,
|
||||||
},
|
},
|
||||||
|
locations = {
|
||||||
|
button = false,
|
||||||
|
desc = "Toggle plugin locations (URL)",
|
||||||
|
id = 11,
|
||||||
|
key = "T",
|
||||||
|
toggle = true,
|
||||||
|
},
|
||||||
help = {
|
help = {
|
||||||
button = true,
|
button = true,
|
||||||
desc = "Toggle this help page",
|
desc = "Toggle this help page",
|
||||||
id = 11,
|
id = 12,
|
||||||
key = "?",
|
key = "?",
|
||||||
toggle = true,
|
toggle = true,
|
||||||
},
|
},
|
||||||
clear = {
|
clear = {
|
||||||
desc = "Clear finished tasks",
|
desc = "Clear finished tasks",
|
||||||
id = 12,
|
id = 13,
|
||||||
},
|
},
|
||||||
load = {
|
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.",
|
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 = true,
|
||||||
plugins_required = true,
|
plugins_required = true,
|
||||||
},
|
},
|
||||||
health = {
|
health = {
|
||||||
desc = "Run `:checkhealth lazy`",
|
desc = "Run `:checkhealth lazy`",
|
||||||
id = 14,
|
id = 15,
|
||||||
},
|
},
|
||||||
build = {
|
build = {
|
||||||
desc = "Rebuild a plugin",
|
desc = "Rebuild a plugin",
|
||||||
id = 15,
|
id = 16,
|
||||||
plugins = true,
|
plugins = true,
|
||||||
plugins_required = true,
|
plugins_required = true,
|
||||||
key_plugin = "gb",
|
key_plugin = "gb",
|
||||||
|
@ -152,7 +159,7 @@ M.commands = {
|
||||||
desc = "Reload a plugin (experimental!!)",
|
desc = "Reload a plugin (experimental!!)",
|
||||||
plugins = true,
|
plugins = true,
|
||||||
plugins_required = true,
|
plugins_required = true,
|
||||||
id = 16,
|
id = 17,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,11 @@ local ViewConfig = require("lazy.view.config")
|
||||||
|
|
||||||
---@class LazyViewState
|
---@class LazyViewState
|
||||||
---@field mode string
|
---@field mode string
|
||||||
|
---@field urls boolean
|
||||||
---@field plugin? {name:string, kind?: LazyPluginKind}
|
---@field plugin? {name:string, kind?: LazyPluginKind}
|
||||||
local default_state = {
|
local default_state = {
|
||||||
mode = "home",
|
mode = "home",
|
||||||
|
urls = Config.options.ui.urls.enabled,
|
||||||
profile = {
|
profile = {
|
||||||
threshold = 0,
|
threshold = 0,
|
||||||
sort_time_taken = false,
|
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)
|
return M.view and M.view.win and vim.api.nvim_win_is_valid(M.view.win)
|
||||||
end
|
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
|
---@param mode? string
|
||||||
function M.show(mode)
|
function M.show(mode)
|
||||||
if Config.headless() then
|
if Config.headless() then
|
||||||
|
|
|
@ -424,6 +424,15 @@ function M:plugin(plugin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:diagnostics(plugin)
|
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()
|
self:nl()
|
||||||
|
|
||||||
if self.view:is_selected(plugin) then
|
if self.view:is_selected(plugin) then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue