Skip to content

Commit

Permalink
Add @lewis6991's improvement for lazy-load command completions
Browse files Browse the repository at this point in the history
  • Loading branch information
wbthomason committed Dec 7, 2022
1 parent 4e0cc24 commit 64ae65f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lua/packer/compile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -570,19 +570,20 @@ local function make_loaders(_, plugins, output_lua, should_profile)
for command, names in pairs(commands) do
local command_line
if string.match(command, '^%w+$') then
-- Better command completions here are due to @folke
-- Better command completions here are due to @folke and @lewis6991
command_line = fmt(
[[pcall(vim.api.nvim_create_user_command, '%s', function(cmdargs)
require('packer.load')({%s}, { cmd = '%s', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins)
end,
{nargs = '*', range = true, bang = true, complete = function()
require('packer.load')({%s}, { cmd = '%s' }, _G.packer_plugins)
vim.api.nvim_input('<space><bs><tab>')
return vim.fn.getcompletion('%s ', 'cmdline')
end})]],
command,
table.concat(names, ', '),
command,
table.concat(names, ', '),
command,
command
)
else
Expand Down

0 comments on commit 64ae65f

Please sign in to comment.