I would like to answer this question both for vegetarians and vegans from the Ayurvedic viewpoint (the only difference being vegans do not take dairy).
Ayurveda is a system of well-being and medicine that originates in India, and it recommends a vegetarian diet. According to Ayurveda, one can gain weight by eating vegetarian food that is grounding, warm, oily, smooth, stabilizing, and substantive. Other factors like a regular daily schedule and a light exercise routine are also involved.
It is recommened to eat three heavy meals at the same time everyday.
You can read more at this article:
...You will want to orient your diet around healthy, whole foods that are
deeply nutritious. Choose foods that are warm, moist, oily, grounding,
nourishing, smooth, and stabilizing, over foods that are cold, dry,
light, or rough. Favor the sweet, sour, and salty tastes over the
pungent, bitter, and astringent tastes. Build your meals around staple
foods that naturally taste sweet, such as fruits, grains, root
vegetables, milk, ghee, fresh yogurt, eggs, nuts, seeds, and
vata-pacifying meats. Nourishing and rejuvenating dishes such as Sweet
Potato Halva and Urad Dal (Split Black Gram) are fantastic, as are substantive soups and
stews. You can also include grounding, nutritive snacks in between
meals. For instance, fill a jar with dates, pour warm
Ghee (clarified butter) over them and let the ghee solidify. Eat one or two of these ghee
dates in the early morning or any time between meals for a
rejuvenative boost of energy. Other supportive snacks include soaked
and peeled almonds, soaked cashews, and date shakes.
Experiment with what works for you and keep snacks handy so that you
can reach for quality nourishment rather than a quick fix of empty
energy (i.e., sugar or junk food).
This page gives a list of fruit, vegetables, grains, legumes etc to be preferred and avoided for weight gain.