Skip to content

Commit

Permalink
feat: added completion for all lazy commands
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 19, 2022
1 parent b462787 commit 5ed9855
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lua/lazy/view/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,19 @@ M.commands = {
end,
}

function M.complete_unloaded(prefix)
function M.complete(cmd, prefix)
local with_plugins = false
for _, mode in ipairs(View.modes) do
if mode.name == cmd and mode.plugin then
with_plugins = true
end
end
if not with_plugins then
return
end
local plugins = {}
for name, plugin in pairs(Config.plugins) do
if not plugin._.loaded then
if cmd ~= "load" or not plugin._.loaded then
plugins[#plugins + 1] = name
end
end
Expand All @@ -91,9 +100,9 @@ function M.setup()
desc = "Lazy",
complete = function(_, line)
---@type string?
local prefix = line:match("^%s*Lazy load (%w*)")
local cmd, prefix = line:match("^%s*Lazy (%w+) (%w*)")
if prefix then
return M.complete_unloaded(prefix)
return M.complete(cmd, prefix)
end

if line:match("^%s*Lazy %w+ ") then
Expand Down

0 comments on commit 5ed9855

Please sign in to comment.