docs: added optional plugins to docs for commands and methods

This commit is contained in:
Folke Lemaitre 2022-12-19 15:20:38 +01:00
parent f29f3d2157
commit b46278751f
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 42 additions and 22 deletions

View File

@ -338,21 +338,21 @@ Alternatively you can start any operation with a specific command, sub command o
<!-- commands:start -->
| Command | Lua | Key Mapping | Description |
| --------------- | --------------------------- | ----------- | --------------------------------------------------------------------------------------------- |
| `:Lazy home` | `require("lazy").home()` | `<H>` | Go back to plugin list |
| `:Lazy install` | `require("lazy").install()` | `<I>` | Install missing plugins |
| `:Lazy update` | `require("lazy").update()` | `<U>` | Update all plugins. This will also update the lockfile |
| `:Lazy sync` | `require("lazy").sync()` | `<S>` | Run install, clean and update |
| `:Lazy clean` | `require("lazy").clean()` | `<X>` | Clean plugins that are no longer needed |
| `:Lazy check` | `require("lazy").check()` | `<C>` | Check for updates and show the log (git fetch) |
| `:Lazy log` | `require("lazy").log()` | `<L>` | Show recent updates for all plugins |
| `:Lazy restore` | `require("lazy").restore()` | `<R>` | Updates all plugins to the state in the lockfile |
| `:Lazy profile` | `require("lazy").profile()` | `<P>` | Show detailed profiling |
| `:Lazy debug` | `require("lazy").debug()` | `<D>` | Show debug information |
| `:Lazy help` | `require("lazy").help()` | `<?>` | Toggle this help page |
| `:Lazy clear` | `require("lazy").clear()` | | Clear finished tasks |
| `:Lazy load` | `require("lazy").load()` | | Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim` |
| Command | Lua | Description |
| ------------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------- |
| `:Lazy home` | `require("lazy").home()` | Go back to plugin list |
| `:Lazy install [plugins]` | `require("lazy").install(plugins?)` | Install missing plugins |
| `:Lazy update [plugins]` | `require("lazy").update(plugins?)` | Update all plugins. This will also update the lockfile |
| `:Lazy sync` | `require("lazy").sync()` | Run install, clean and update |
| `:Lazy clean [plugins]` | `require("lazy").clean(plugins?)` | Clean plugins that are no longer needed |
| `:Lazy check [plugins]` | `require("lazy").check(plugins?)` | Check for updates and show the log (git fetch) |
| `:Lazy log [plugins]` | `require("lazy").log(plugins?)` | Show recent updates for all plugins |
| `:Lazy restore [plugins]` | `require("lazy").restore(plugins?)` | Updates all plugins to the state in the lockfile |
| `:Lazy profile` | `require("lazy").profile()` | Show detailed profiling |
| `:Lazy debug` | `require("lazy").debug()` | Show debug information |
| `:Lazy help` | `require("lazy").help()` | Toggle this help page |
| `:Lazy clear` | `require("lazy").clear()` | Clear finished tasks |
| `:Lazy load {plugins}` | `require("lazy").load(plugins)` | Load a plugin that has not been loaded yet. Similar to `:packadd`. Like `:Lazy load foo.nvim` |
<!-- commands:end -->

View File

@ -77,17 +77,37 @@ function M.commands()
local commands = require("lazy.view.commands").commands
local modes = require("lazy.view").modes
local lines = {
{ "Command", "Lua", "Key Mapping", "Description" },
{ "Command", "Lua", "Description" },
{ "---", "---", "---", "---" },
}
local with_plugins = {}
for _, mode in ipairs(modes) do
if mode.plugin then
with_plugins[mode.name] = true
end
end
local plugins_required = { load = true }
for _, mode in ipairs(modes) do
if not mode.plugin and commands[mode.name] then
lines[#lines + 1] = {
("`:Lazy %s`"):format(mode.name),
([[`require("lazy").%s()`]]):format(mode.name),
mode.key and ("`<%s>`"):format(mode.key) or "",
mode.desc,
}
if plugins_required[mode.name] then
lines[#lines + 1] = {
("`:Lazy %s {plugins}`"):format(mode.name),
([[`require("lazy").%s(plugins)`]]):format(mode.name),
mode.desc,
}
elseif with_plugins[mode.name] then
lines[#lines + 1] = {
("`:Lazy %s [plugins]`"):format(mode.name),
([[`require("lazy").%s(plugins?)`]]):format(mode.name),
mode.desc,
}
else
lines[#lines + 1] = {
("`:Lazy %s`"):format(mode.name),
([[`require("lazy").%s()`]]):format(mode.name),
mode.desc,
}
end
end
end
local ret = {}