local command = vim.api.nvim_create_user_command local complete_plugin_names = function(arg, _, _) local inactive_plugs_starting_with_arg = vim.tbl_filter( function(p) return p.active == false and vim.startswith(p.spec.name, arg) end, vim.pack.get() ) return vim.tbl_map(function(p) return p.spec.name end, inactive_plugs_starting_with_arg) end command( "DiffOrig", [[ vert new setlocal buftype=nofile read ++edit # 0d_ diffthis wincmd p diffthis ]], { desc = "DiffOrig (see `:h DiffOrig`)" } ) command("Pup", function(_) vim.pack.update() end, { desc = "Update packages" }) command( "Pdel", function(opts) vim.pack.del(vim.split(opts.args, " ")) end, { nargs = "*", complete = complete_plugin_names } ) command( "LspLog", function() vim.cmd.tabnew(vim.lsp.log.get_filename()) end, { desc = "Opens the Nvim LSP client log." } ) command("Align", function(_) -- TODO end, { nargs = "*", range = true, desc = "align selection with respect to a substring", })