From b46278751f7fe518380489e5d93b529e8444a8e7 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 19 Dec 2022 15:20:38 +0100 Subject: [PATCH] docs: added optional plugins to docs for commands and methods --- README.md | 30 +++++++++++++++--------------- lua/lazy/docs.lua | 34 +++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 4c26b29..ac2bc78 100644 --- a/README.md +++ b/README.md @@ -338,21 +338,21 @@ Alternatively you can start any operation with a specific command, sub command o -| Command | Lua | Key Mapping | Description | -| --------------- | --------------------------- | ----------- | --------------------------------------------------------------------------------------------- | -| `:Lazy home` | `require("lazy").home()` | `` | Go back to plugin list | -| `:Lazy install` | `require("lazy").install()` | `` | Install missing plugins | -| `:Lazy update` | `require("lazy").update()` | `` | Update all plugins. This will also update the lockfile | -| `:Lazy sync` | `require("lazy").sync()` | `` | Run install, clean and update | -| `:Lazy clean` | `require("lazy").clean()` | `` | Clean plugins that are no longer needed | -| `:Lazy check` | `require("lazy").check()` | `` | Check for updates and show the log (git fetch) | -| `:Lazy log` | `require("lazy").log()` | `` | Show recent updates for all plugins | -| `:Lazy restore` | `require("lazy").restore()` | `` | 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` | `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` | diff --git a/lua/lazy/docs.lua b/lua/lazy/docs.lua index 965f4e3..73090c5 100644 --- a/lua/lazy/docs.lua +++ b/lua/lazy/docs.lua @@ -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 = {}