Lately, the integration of renewable energy sources (e.g. photovoltaic and wind generation systems) has been raised into microgrids interconnected with plug-in electric vehicles (PEV). Such intermittent generation and charging/discharging PEV profiles are challenging to ensure the secure and optimal operation of microgrids. In this paper, an optimization approach is proposed to determine the optimal locations and sizes of photovoltaic and wind generation systems in microgrids with PEV-parking lots. The developed approach addresses 1) the uncertainty of generation profiles of photovoltaic and wind generation systems and loads, 2) the DSTATCOM feature of photovoltaic and wind generation systems, and 3) microgrid constraints. The feasible PEV conditions are also considered, i.e. initial and preset conditions of their state of charge (SOC), arriving and departing times, and various controlled/uncontrolled charging schemes. To solve the planning model, we have developed a bi-level metaheuristic-based approach. The upper-level and lower-level optimization tasks are to optimize the decision variables of renewable energy sources and PEV, respectively. Both energy losses through the lines and energy from the main grid are considered as sub-objectives to be minimized. Various simulations and study cases are performed to assess the effectiveness of the proposed approach. The outcomes show the efficacy of the proposed approach to simultaneously plan renewable energy sources and manage PEV to form an autonomous microgrid.